python-sdk
python-sdk copied to clipboard
Using `Context` in resource definitions results in inccorect resource template classification
Initial Checks
- [x] I confirm that I'm using the latest version of MCP Python SDK
- [x] I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Description
expected behaivor / actual behavior
looking at the provided sample code i would assume current_time would show up as a regular resource, because it needs no arguments from the llm / user.
however, is is only being listed as a resource template and cannot be invoked via the inspector.
Example Code
from contextlib import asynccontextmanager
from mcp import ServerSession
from mcp.server import FastMCP
from mcp.server.fastmcp import Context
class AppContext:
pass
@asynccontextmanager
async def lifespan(server: FastMCP):
yield AppContext()
mcp = FastMCP("Demo", lifespan=lifespan)
@mcp.resource("time://current")
async def current_time(ctx: Context[ServerSession, AppContext]):
return "11:41"
Python & MCP Python SDK
`uv run python` shows `3.13.8`
`uv pip freeze` shows `mcp==1.21.1`