modelcontextprotocol / modelcontextprotocol/python-sdk
Add add_resource_template() to MCPServer
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.3k
- Forks
- 4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 31
Description
Description
MCPServer and ResourceManager have add_resource() method for static Resources, but there is no way to handle ResourceTemplate without using @resource decorator.
I am implementing the following workaround using the decorator for my usecase, but it is a bit odd.
server = MCPServer("...")
# Configure resources (implemented in other files)
server.resource("resource://users")(resources.list_users)
server.resource("resource://users/{id}")(resources.get_user)
References
It was implemented in #3208.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MCPServer and ResourceManager add_resource() entry points, then read the implementation from #3208. Determine how ResourceTemplate is handled through the existing decorator path and define the matching direct API. Done means callers can register a ResourceTemplate without using @resource, with coverage for the new behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100