You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mismatch between uri parameters set() and function parameters {'ctx'} #1215
I'm experiencing the same issue as others:
mismatch between uri parameters set() and function parameters {'ctx'}
I am using the latest version, and when using the example from the documentation, I get this error.
Example Code
fromfastmcpimportFastMCP, Contextmcp=FastMCP(name="Context Demo")
@mcp.resource("resource://user-data")asyncdefget_user_data(ctx: Context) ->dict:
"""Fetch personalized user data based on the request context."""# Context is available as the ctx parameterreturn {"user_id": "example"}
@mcp.resource("resource://users/{user_id}/profile")asyncdefget_user_profile(user_id: str, ctx: Context) ->dict:
"""Fetch user profile with context-aware logging."""# Context is available as the ctx parameterreturn {"id": user_id}
fn = <function define_mcp_server.<locals>.read_file_resource at 0x000001637F9E5760>
def decorator(fn: AnyFunction) -> AnyFunction:
# Check if this should be a template
has_uri_params = "{" in uri and "}" in uri
has_func_params = bool(inspect.signature(fn).parameters)
if has_uri_params or has_func_params:
# Validate that URI params match function params
uri_params = set(re.findall(r"{(\w+)}", uri))
func_params = set(inspect.signature(fn).parameters.keys())
if uri_params != func_params:
> raise ValueError(
f"Mismatch between URI parameters {uri_params} " f"and function parameters {func_params}"
)
E ValueError: Mismatch between URI parameters {'path'} and function parameters {'path', 'context'}
Activity
Spark-Liang commentedon Aug 1, 2025
seem this also happen in 1.9.4 .
Python 3.11
relative code:
error message:
@app.resource()does not acceptctx: Context#244