Fix lifespan_context access example in README (#437)

This commit is contained in:
Nyakku Shigure 2025-04-09 16:58:17 +08:00 • committed by GitHub
commit 58b989c0a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -194,7 +194,7 @@ mcp = FastMCP("My App", lifespan=app_lifespan)
@mcp.tool()
def query_db(ctx: Context) -> str:
"""Tool that uses initialized resources"""
db = ctx.request_context.lifespan_context["db"]
db = ctx.request_context.lifespan_context.db
return db.query()
```