chore: import upstream snapshot with attribution
Deploy Docs / deploy-docs (push) Failing after 1s
Conformance Tests / client-conformance (push) Failing after 3s
Conformance Tests / server-conformance (push) Failing after 1s
GitHub Actions Security Analysis / zizmor (push) Failing after 1s
CI / checks (push) Failing after 59m20s
CI / all-green (push) Waiting to run
Deploy Docs / deploy-docs (push) Failing after 1s
Conformance Tests / client-conformance (push) Failing after 3s
Conformance Tests / server-conformance (push) Failing after 1s
GitHub Actions Security Analysis / zizmor (push) Failing after 1s
CI / checks (push) Failing after 59m20s
CI / all-green (push) Waiting to run
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""Example showing path configuration when mounting MCPServer.
|
||||
|
||||
Run from the repository root:
|
||||
uvicorn examples.snippets.servers.streamable_http_path_config:app --reload
|
||||
"""
|
||||
|
||||
from starlette.applications import Starlette
|
||||
from starlette.routing import Mount
|
||||
|
||||
from mcp.server.mcpserver import MCPServer
|
||||
|
||||
# Create a simple MCPServer server
|
||||
mcp_at_root = MCPServer("My Server")
|
||||
|
||||
|
||||
@mcp_at_root.tool()
|
||||
def process_data(data: str) -> str:
|
||||
"""Process some data"""
|
||||
return f"Processed: {data}"
|
||||
|
||||
|
||||
# Mount at /process with streamable_http_path="/" so the endpoint is /process (not /process/mcp)
|
||||
# Transport-specific options like json_response are passed to streamable_http_app()
|
||||
app = Starlette(
|
||||
routes=[
|
||||
Mount(
|
||||
"/process",
|
||||
app=mcp_at_root.streamable_http_app(json_response=True, streamable_http_path="/"),
|
||||
),
|
||||
]
|
||||
)
|
||||
Reference in New Issue
Block a user