refactor: move transport-specific parameters from FastMCP constructor to run() (#1898)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
5d80f4efc8
commit
8adb5bdce8
1 changed files with 339 additions and 231 deletions
|
|
@ -13,7 +13,7 @@ from starlette.routing import Mount
|
|||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
# Create MCP server
|
||||
mcp = FastMCP("My App", json_response=True)
|
||||
mcp = FastMCP("My App")
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
|
|
@ -30,9 +30,10 @@ async def lifespan(app: Starlette):
|
|||
|
||||
|
||||
# Mount the StreamableHTTP server to the existing ASGI server
|
||||
# Transport-specific options are passed to streamable_http_app()
|
||||
app = Starlette(
|
||||
routes=[
|
||||
Mount("/", app=mcp.streamable_http_app()),
|
||||
Mount("/", app=mcp.streamable_http_app(json_response=True)),
|
||||
],
|
||||
lifespan=lifespan,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue