feat(server): transport="both" — host MCP and A2A on a single binary (#354)#370
Merged
feat(server): transport="both" — host MCP and A2A on a single binary (#354)#370
Conversation
…354) JS sellers host both transports on one Express/Hono app; this is the Python parity. ``serve(transport="both")`` builds both apps from the same handler and routes by URL path on a single Starlette parent: ``/mcp`` and ``/mcp/...`` go to FastMCP's streamable-http app, everything else (``/``, ``/.well-known/agent.json``, A2A push endpoints) goes to the a2a-sdk app. Adopters writing context_factory, middleware, AccountStore, BuyerAgentRegistry, etc., wire one place and reach both transports automatically. * New ``"both"`` value on ``serve(transport=)``. * Internal ``_build_mcp_and_a2a_app`` constructs the dispatcher; ``_serve_mcp_and_a2a`` drives uvicorn against it. * Lifespan composition: FastMCP's session manager and a2a-sdk's stores both initialize via a composed asynccontextmanager on the parent Starlette. Without this, requests to the MCP path fail with ``Task group is not initialized``. * 8 tests via Starlette TestClient. Closes #354. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
JS sellers host both transports on one Express/Hono app; this PR brings Python parity. `serve(transport="both")` routes by URL path on a single Starlette parent — `/mcp` and `/mcp/...` to FastMCP, everything else (`/`, `/.well-known/agent.json`, A2A push) to a2a-sdk. Both apps share one handler instance, so context_factory / middleware / AccountStore / BuyerAgentRegistry wire once and reach both transports.
Closes #354.
Test plan
🤖 Generated with Claude Code