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
|
|
@ -6,6 +6,7 @@ from typing import Any
|
|||
import anyio
|
||||
import click
|
||||
import mcp.types as types
|
||||
import uvicorn
|
||||
from mcp.server.lowlevel import Server
|
||||
from mcp.server.streamable_http_manager import StreamableHTTPSessionManager
|
||||
from starlette.applications import Starlette
|
||||
|
|
@ -33,7 +34,7 @@ def main(
|
|||
port: int,
|
||||
log_level: str,
|
||||
json_response: bool,
|
||||
) -> int:
|
||||
) -> None:
|
||||
# Configure logging
|
||||
logging.basicConfig(
|
||||
level=getattr(logging, log_level.upper()),
|
||||
|
|
@ -118,9 +119,7 @@ def main(
|
|||
# Create an ASGI application using the transport
|
||||
starlette_app = Starlette(
|
||||
debug=True,
|
||||
routes=[
|
||||
Mount("/mcp", app=handle_streamable_http),
|
||||
],
|
||||
routes=[Mount("/mcp", app=handle_streamable_http)],
|
||||
lifespan=lifespan,
|
||||
)
|
||||
|
||||
|
|
@ -133,8 +132,4 @@ def main(
|
|||
expose_headers=["Mcp-Session-Id"],
|
||||
)
|
||||
|
||||
import uvicorn
|
||||
|
||||
uvicorn.run(starlette_app, host="127.0.0.1", port=port)
|
||||
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue