Repository navigation
Conversation
|
This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #3813. If a maintainer assigns you to #3813, this PR reopens on its own and there's nothing more you need to do here. Assignment is a maintainer call based on capacity; comments that only ask to be assigned don't factor in. What does help is engaging on the issue itself by confirming the repro, explaining why it matters for your use case, or describing the approach you'd take. You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way. CONTRIBUTING.md has the full reasoning, but in short:
Maintainers: reopen, remove |
Fixes #3813.
ResourceManager.add_template()registers templates with a bare dict assignment, so a second@server.resource("file://doc/{id}")silently replaces the first handler.add_resource(),PromptManager.add_prompt()and the documentedwarn_on_duplicate_resourcessetting all do the opposite: warn (when enabled) and keep the handler that was registered first.That divergence is reachable without any unusual setup — two modules or extensions that both declare the same URI template end up with whichever one was imported last, and nothing in the logs says so:
Before: the static resource warns and keeps
doc1, the template is replaced bytemplate2with no warning. After: both warn and keep the first registration, andadd_template()returns the template that is actually registered (matchingadd_resource()'s return contract, now documented in the docstring).Tests added to
tests/server/mcpserver/resources/test_resource_manager.py, mirroring the existing resource-duplicate tests:test_add_duplicate_template— the second registration returns the first template,list_templates()has one entry, and the retained handler is the first one.test_warn_on_duplicate_templates— logsResource template already exists: ....test_disable_warn_on_duplicate_templates— silent whenwarn_on_duplicate_resources=False.Results: on
mainthe first two fail (2 failed, 12 passed); with the change the file is14 passed.ruff format/ruff check: clean.One judgement call worth flagging: I kept the existing template rather than replacing it, because that is what the sibling registration paths do and what the flag's docstring describes. If you would rather have last-registration-wins with a warning, the change is a one-line flip and I will adjust.