modelcontextprotocol / modelcontextprotocol/python-sdk

Add add_resource_template() to MCPServer

Open
#3,333 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

v2
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.