Add missing add_resource_template() to MCPServer - #3208
Open
okapies wants to merge 2 commits into
Open
Conversation
okapies
force-pushed
the
feature/mcpserver-add-template
branch
from
July 29, 2026 11:47
ff9d657 to
d13e0c4
Compare
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/server/mcpserver/test_server.py">
<violation number="1" location="tests/server/mcpserver/test_server.py:1017">
P2: Missing assertions: `test_add_resource_template` never verifies the template was actually registered. Call `await mcp.list_resource_templates()` and assert the expected count, or use `Client` to read a resource through the template, so the test catches regressions. Without assertions the test will pass even if `add_resource_template` is a no-op.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
| return "Data" | ||
|
|
||
| template = ResourceTemplate.from_function(get_data, "resource://{param}") | ||
| mcp.add_resource_template(template) |
There was a problem hiding this comment.
P2: Missing assertions: test_add_resource_template never verifies the template was actually registered. Call await mcp.list_resource_templates() and assert the expected count, or use Client to read a resource through the template, so the test catches regressions. Without assertions the test will pass even if add_resource_template is a no-op.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/server/mcpserver/test_server.py, line 1017:
<comment>Missing assertions: `test_add_resource_template` never verifies the template was actually registered. Call `await mcp.list_resource_templates()` and assert the expected count, or use `Client` to read a resource through the template, so the test catches regressions. Without assertions the test will pass even if `add_resource_template` is a no-op.</comment>
<file context>
@@ -1004,6 +1004,18 @@ def get_csv(user: str) -> str:
+ return "Data"
+
+ template = ResourceTemplate.from_function(get_data, "resource://{param}")
+ mcp.add_resource_template(template)
+
</file context>
Author
There was a problem hiding this comment.
MCPServer.add_resource_template() returns None, just like add_resource().
okapies
force-pushed
the
feature/mcpserver-add-template
branch
from
July 29, 2026 12:37
d13e0c4 to
7132c85
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Add the missing
add_resource_template()method toMCPServerandResourceManagerto manage resource template implementations manually and independently without using the@mcp.resourcedecorator.Note that this PR leaves
add_template()in place to maintain backward compatibility.How Has This Been Tested?
n/a
Breaking Changes
Non-breaking changes.
Types of changes
Checklist
Additional context