URI templates with hyphenated parameter names fail at registration time.
@mcp.resource("data://{user-id}/profile")
def get_profile(user_id: str) -> str:
return f"profile for {user_id}"
# ValueError: URI template must contain at least one parameter
The regex in template.py:505 uses \w+ which matches [a-zA-Z0-9_] — hyphens are excluded:
path_params = set(re.findall(r"{(\w+)(?:\*)?}", uri_template))
So {user-id} is not recognized as a parameter, and the template appears to have zero parameters.
RFC 6570 allows hyphens in variable names. The fix is [\w-]+ or [\w.-]+ in the regex.
URI templates with hyphenated parameter names fail at registration time.
The regex in
template.py:505uses\w+which matches[a-zA-Z0-9_]— hyphens are excluded:So
{user-id}is not recognized as a parameter, and the template appears to have zero parameters.RFC 6570 allows hyphens in variable names. The fix is
[\w-]+or[\w.-]+in the regex.