We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent edd8ea1 commit 759f276Copy full SHA for 759f276
README.md
@@ -192,9 +192,10 @@ mcp = FastMCP("My App", lifespan=app_lifespan)
192
193
# Access type-safe lifespan context in tools
194
@mcp.tool()
195
-def query_db(ctx: Context) -> str:
+def query_db() -> str:
196
"""Tool that uses initialized resources"""
197
- db = ctx.request_context.lifespan_context.db
+ ctx = mcp.get_context()
198
+ db = ctx.request_context.lifespan_context["db"]
199
return db.query()
200
```
201
0 commit comments