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 9ae4df8 commit 7b968d9Copy full SHA for 7b968d9
README.md
@@ -152,6 +152,7 @@ from dataclasses import dataclass
152
from fake_database import Database # Replace with your actual DB type
153
154
from mcp.server.fastmcp import Context, FastMCP
155
+from mcp.server.session import ServerSessionT
156
157
# Create a named server
158
mcp = FastMCP("My App")
@@ -183,7 +184,7 @@ mcp = FastMCP("My App", lifespan=app_lifespan)
183
184
185
# Access type-safe lifespan context in tools
186
@mcp.tool()
-def query_db(ctx: Context) -> str:
187
+def query_db(ctx: Context[ServerSessionT, AppContext]) -> str:
188
"""Tool that uses initialized resources"""
189
db = ctx.request_context.lifespan_context["db"]
190
return db.query()
0 commit comments