python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

Using `Context` in resource definitions results in inccorect resource template classification

Open aarondiel opened this issue 3 months ago • 0 comments

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.

Image

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`

aarondiel avatar Nov 16 '25 11:11 aarondiel