René's URL Explorer Experiment


Title: feat(server): expose lifespan / on_startup / on_shutdown hooks on serve() · Issue #709 · adcontextprotocol/adcp-client-python · GitHub

Open Graph Title: feat(server): expose lifespan / on_startup / on_shutdown hooks on serve() · Issue #709 · adcontextprotocol/adcp-client-python

X Title: feat(server): expose lifespan / on_startup / on_shutdown hooks on serve() · Issue #709 · adcontextprotocol/adcp-client-python

Description: A python library to interact with adcp servers. Contribute to adcontextprotocol/adcp-client-python development by creating an account on GitHub.

Open Graph Description: A python library to interact with adcp servers. Contribute to adcontextprotocol/adcp-client-python development by creating an account on GitHub.

X Description: A python library to interact with adcp servers. Contribute to adcontextprotocol/adcp-client-python development by creating an account on GitHub.

Opengraph URL: https://github.com/adcontextprotocol/adcp-client-python

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat(server): expose lifespan / on_startup / on_shutdown hooks on serve()","articleBody":"## Problem\n\nAdopters who need to run background work tied to the server lifecycle — schedulers, connection pools, cache warmers, message-queue consumers, telemetry exporters — have no public hook into `serve()`'s lifespan composition.\n\n`serve.py:1703` builds a private `_composed_lifespan` that chains the MCP inner app's lifespan with the A2A inner app's lifespan, mounts it on the parent Starlette, and offers no extension point for the caller.\n\n## What adopters do today\n\nSalesagent wires a 61-LOC `SchedulerLifespanMiddleware` (`core/middleware/scheduler_lifespan.py`) that intercepts ASGI `lifespan.startup` / `lifespan.shutdown` scope events, fires user-supplied coroutines, and forwards the events through. Every adopter who needs lifecycle-tied background work writes the same shape of middleware.\n\nSketch:\n\n```python\nclass SchedulerLifespanMiddleware:\n    def __init__(self, app, startups, shutdowns):\n        self.app = app\n        self.startups = startups\n        self.shutdowns = shutdowns\n\n    async def __call__(self, scope, receive, send):\n        if scope[\"type\"] == \"lifespan\":\n            async def wrapped_receive():\n                msg = await receive()\n                if msg[\"type\"] == \"lifespan.startup\":\n                    for hook in self.startups: await hook()\n                elif msg[\"type\"] == \"lifespan.shutdown\":\n                    for hook in self.shutdowns: await hook()\n                return msg\n            await self.app(scope, wrapped_receive, send)\n            return\n        await self.app(scope, receive, send)\n```\n\nThis works but:\n\n1. It re-implements what Starlette's `lifespan=` already provides.\n2. It's a middleware, so it's positionally fragile — adopters get the ordering wrong (e.g. wrapping it outside `SigningVerifyMiddleware` would put it in the wrong scope).\n3. It can't `await` background tasks correctly without explicit error propagation, so adopters write subtly different (and subtly broken) variants.\n\n## Proposed\n\nPick one of:\n\n### (a) Pass-through to Starlette's lifespan signature\n\n```python\nserve(\n    handler,\n    on_startup=[start_scheduler, warm_cache],\n    on_shutdown=[stop_scheduler],\n)\n```\n\n`serve` appends these to the lifespan it already composes. Simplest adopter surface, mirrors what Starlette/FastAPI users already know.\n\n### (b) Single composable lifespan kwarg\n\n```python\n@asynccontextmanager\nasync def lifespan(app):\n    await start_scheduler()\n    try:\n        yield\n    finally:\n        await stop_scheduler()\n\nserve(handler, lifespan=lifespan)\n```\n\n`serve` chains this *inside* its existing `_composed_lifespan`. Lets adopters share state via `yield`-bound resources.\n\n(a) and (b) are not mutually exclusive — Starlette supports both. The minimal-viable surface is (a).\n\n## Why this isn't just \\\"file an ASGI middleware example\\\"\n\nThe whole point of `serve()` is that it owns the lifespan composition (PR #680 made this explicit when callable `public_url` started breaking it). Forcing adopters to break that abstraction with middleware re-introduces exactly the ordering bugs PR #680 was meant to eliminate.\n\n## Acceptance\n\n- `serve(on_startup=..., on_shutdown=...)` accepted as kwargs and threaded into `_composed_lifespan`\n- (Optional follow-on) `serve(lifespan=...)` accepts an async context manager\n- Existing transport=\\\"both\\\" + callable `public_url` (now working in 5.3.0 per #680) continues to work\n- An example in `examples/` demonstrating a scheduler tied to lifespan, replacing the middleware pattern\n- Salesagent can delete `core/middleware/scheduler_lifespan.py` and pass `on_startup=[_start_schedulers], on_shutdown=[_stop_schedulers]` instead\n\n## Real-world demand\n\nFound while auditing the 5.3.0 bump in salesagent for SDK workarounds we could now rip out. This was the one workaround that couldn't be removed because the SDK exposes no extension point.","author":{"url":"https://github.com/bokelley","@type":"Person","name":"bokelley"},"datePublished":"2026-05-12T22:56:18Z","url":"https://github.com/adcontextprotocol/adcp-client-python/issues/709"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/issues/:id(.:format)
route-controllerissues
route-actionshow
fetch-noncev2:bbb943f5-8f83-14b8-b6f7-35d6b7f624e1
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id92AE:2C3566:D844A9:11F0CDC:6B00F8E6
html-safe-nonce0b801c2efd9a7f77e6e861a838c8d66425da2cad0f58be19f6a6d64f818d1528
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MkFFOjJDMzU2NjpEODQ0QTk6MTFGMENEQzo2QjAwRjhFNiIsInZpc2l0b3JfaWQiOiIyOTE3NDMyNzQ3NTAyOTI2MDU0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacd6ddee99bb2df225e0bcd6d8262c33bd388bc3cbb438cb322360dad43862851f
hovercard-subject-tagrepository:1090305973
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///issues/show
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/adcontextprotocol/adcp-client-python/issues/709
twitter:imagehttps://opengraph.githubassets.com/ad855be62f09a05c0db141a47c0256e3d9cc590ab5a26754e07365c6cd487083/adcontextprotocol/adcp-client-python
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/ad855be62f09a05c0db141a47c0256e3d9cc590ab5a26754e07365c6cd487083/adcontextprotocol/adcp-client-python
og:image:altA python library to interact with adcp servers. Contribute to adcontextprotocol/adcp-client-python development by creating an account on GitHub.
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonee208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187
turbo-cache-controlno-cache
go-importgithub.com/adcontextprotocol/adcp-client-python git https://github.com/adcontextprotocol/adcp-client-python.git
octolytics-dimension-user_id221690821
octolytics-dimension-user_loginadcontextprotocol
octolytics-dimension-repository_id1090305973
octolytics-dimension-repository_nwoadcontextprotocol/adcp-client-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1090305973
octolytics-dimension-repository_network_root_nwoadcontextprotocol/adcp-client-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7dafd017fb7809a839c443dba08622af38e63c09
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/adcontextprotocol/adcp-client-python/issues/709#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fadcontextprotocol%2Fadcp-client-python%2Fissues%2F709
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fadcontextprotocol%2Fadcp-client-python%2Fissues%2F709
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fissues%2Fshow&source=header-repo&source_repo=adcontextprotocol%2Fadcp-client-python
Reloadhttps://github.com/adcontextprotocol/adcp-client-python/issues/709
Reloadhttps://github.com/adcontextprotocol/adcp-client-python/issues/709
Reloadhttps://github.com/adcontextprotocol/adcp-client-python/issues/709
https://github.com/adcontextprotocol/adcp-client-python
New issuehttps://github.com/login?return_to=https://github.com/adcontextprotocol/adcp-client-python/issues/709
New issuehttps://github.com/login?return_to=https://github.com/adcontextprotocol/adcp-client-python/issues/709
#713https://github.com/adcontextprotocol/adcp-client-python/pull/713
feat(server): expose lifespan / on_startup / on_shutdown hooks on serve()https://github.com/adcontextprotocol/adcp-client-python/issues/709#top
#713https://github.com/adcontextprotocol/adcp-client-python/pull/713
claude-triagedhttps://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22claude-triaged%22
enhancementNew feature or requesthttps://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22enhancement%22
https://github.com/bokelley
bokelleyhttps://github.com/bokelley
on May 12, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/709#issue-4433201658
#680https://github.com/adcontextprotocol/adcp-client-python/pull/680
#680https://github.com/adcontextprotocol/adcp-client-python/pull/680
fix(server): preserve Starlette lifespan when public_url is callable #680https://github.com/adcontextprotocol/adcp-client-python/pull/680
bokelleyhttps://github.com/bokelley
enhancementNew feature or requesthttps://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22enhancement%22
claude-triagedhttps://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22claude-triaged%22
on May 12, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/709#event-25454407155
https://github.com/bokelley
bokelleyhttps://github.com/bokelley
on May 13, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/709#issuecomment-4437463803
Claude Codehttps://claude.ai/code
bokelleyhttps://github.com/bokelley
on May 13, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/709#event-25474595045
feat(server): on_startup / on_shutdown hooks on serve(transport='both…https://github.com/adcontextprotocol/adcp-client-python/commit/aca625edf18b7f62f44c829a2317fc770a72ee05
https://docs.github.com/articles/closing-issues-via-commit-messages
aca625ehttps://github.com/adcontextprotocol/adcp-client-python/commit/aca625edf18b7f62f44c829a2317fc770a72ee05
bokelleyhttps://github.com/bokelley
completedhttps://github.com/adcontextprotocol/adcp-client-python/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#713https://github.com/adcontextprotocol/adcp-client-python/pull/713
on May 13, 2026https://github.com/adcontextprotocol/adcp-client-python/issues/709#event-25474595074
Sign up for freehttps://github.com/signup?return_to=https://github.com/adcontextprotocol/adcp-client-python/issues/709
Sign in to commenthttps://github.com/login?return_to=https://github.com/adcontextprotocol/adcp-client-python/issues/709
claude-triagedhttps://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22claude-triaged%22
enhancementNew feature or requesthttps://github.com/adcontextprotocol/adcp-client-python/issues?q=state%3Aopen%20label%3A%22enhancement%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.