Skip to content

Using Context in resource definitions results in inccorect resource template classification #1635

@aarondiel

Description

@aarondiel

Initial Checks

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`

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workingready for workEnough information for someone to start working on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions