Skip to content

Commit 6c08e68

Browse files
committed
Update README snippets to match example files
Run scripts/update_readme_snippets.py to sync documentation with code changes.
1 parent 69f2ab9 commit 6c08e68

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,7 @@ Basic example showing how to mount StreamableHTTP server in Starlette.
12611261
Run from the repository root:
12621262
uvicorn examples.snippets.servers.streamable_http_basic_mounting:app --reload
12631263
"""
1264+
12641265
import contextlib
12651266

12661267
from starlette.applications import Starlette
@@ -1277,13 +1278,15 @@ def hello() -> str:
12771278
"""A simple hello tool"""
12781279
return "Hello from MCP!"
12791280

1281+
12801282
# Create lifespan context manager to initialize the session manager
12811283
@contextlib.asynccontextmanager
12821284
async def lifespan(app: Starlette):
12831285
"""Context manager for managing MCP session manager lifecycle."""
12841286
async with mcp.session_manager.run():
12851287
yield
12861288

1289+
12871290
# Mount the StreamableHTTP server to the existing ASGI server
12881291
app = Starlette(
12891292
routes=[
@@ -1306,6 +1309,7 @@ Example showing how to mount StreamableHTTP server using Host-based routing.
13061309
Run from the repository root:
13071310
uvicorn examples.snippets.servers.streamable_http_host_mounting:app --reload
13081311
"""
1312+
13091313
import contextlib
13101314

13111315
from starlette.applications import Starlette
@@ -1322,13 +1326,15 @@ def domain_info() -> str:
13221326
"""Get domain-specific information"""
13231327
return "This is served from mcp.acme.corp"
13241328

1329+
13251330
# Create lifespan context manager to initialize the session manager
13261331
@contextlib.asynccontextmanager
13271332
async def lifespan(app: Starlette):
13281333
"""Context manager for managing MCP session manager lifecycle."""
13291334
async with mcp.session_manager.run():
13301335
yield
13311336

1337+
13321338
# Mount using Host-based routing
13331339
app = Starlette(
13341340
routes=[
@@ -1351,6 +1357,7 @@ Example showing how to mount multiple StreamableHTTP servers with path configura
13511357
Run from the repository root:
13521358
uvicorn examples.snippets.servers.streamable_http_multiple_servers:app --reload
13531359
"""
1360+
13541361
import contextlib
13551362

13561363
from starlette.applications import Starlette
@@ -1380,6 +1387,7 @@ def send_message(message: str) -> str:
13801387
api_mcp.settings.streamable_http_path = "/"
13811388
chat_mcp.settings.streamable_http_path = "/"
13821389

1390+
13831391
# Create lifespan context manager to initialize both session managers
13841392
@contextlib.asynccontextmanager
13851393
async def lifespan(app: Starlette):
@@ -1389,6 +1397,7 @@ async def lifespan(app: Starlette):
13891397
await stack.enter_async_context(chat_mcp.session_manager.run())
13901398
yield
13911399

1400+
13921401
# Mount the servers
13931402
app = Starlette(
13941403
routes=[
@@ -1412,6 +1421,7 @@ Example showing path configuration during FastMCP initialization.
14121421
Run from the repository root:
14131422
uvicorn examples.snippets.servers.streamable_http_path_config:app --reload
14141423
"""
1424+
14151425
import contextlib
14161426

14171427
from starlette.applications import Starlette
@@ -1437,6 +1447,7 @@ async def lifespan(app: Starlette):
14371447
async with mcp_at_root.session_manager.run():
14381448
yield
14391449

1450+
14401451
# Mount at /process - endpoints will be at /process instead of /process/mcp
14411452
app = Starlette(
14421453
routes=[

0 commit comments

Comments
 (0)