mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-24 06:24:18 +02:00
Add lifespan property to app
This commit is contained in:
parent
a31b423358
commit
c3e9bdb49e
4 changed files with 23 additions and 16 deletions
|
|
@ -124,7 +124,7 @@ app = Starlette(
|
|||
Mount("/mcp-server", app=mcp_app),
|
||||
# Add other routes as needed
|
||||
],
|
||||
lifespan=mcp_app.router.lifespan_context,
|
||||
lifespan=mcp_app.lifespan,
|
||||
)
|
||||
```
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ mcp_app = mcp.http_app(path='/mcp')
|
|||
inner_app = Starlette(routes=[Mount("/inner", app=mcp_app)])
|
||||
app = Starlette(
|
||||
routes=[Mount("/outer", app=inner_app)],
|
||||
lifespan=mcp_app.router.lifespan_context,
|
||||
lifespan=mcp_app.lifespan,
|
||||
)
|
||||
```
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ mcp = FastMCP("MyServer")
|
|||
mcp_app = mcp.http_app(path='/mcp')
|
||||
|
||||
# Create a FastAPI app and mount the MCP server
|
||||
app = FastAPI(lifespan=mcp_app.router.lifespan_context)
|
||||
app = FastAPI(lifespan=mcp_app.lifespan)
|
||||
app.mount("/mcp-server", mcp_app)
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue