Skip to content

Filter MCPServer capabilities by registered primitives#2477

Open
MukundaKatta wants to merge 1 commit intomodelcontextprotocol:mainfrom
MukundaKatta:codex/mcpserver-capability-filter
Open

Filter MCPServer capabilities by registered primitives#2477
MukundaKatta wants to merge 1 commit intomodelcontextprotocol:mainfrom
MukundaKatta:codex/mcpserver-capability-filter

Conversation

@MukundaKatta
Copy link
Copy Markdown

Summary

  • stop MCPServer from advertising prompt, resource, and tool capabilities when nothing has been registered for that primitive
  • keep the low-level Server behavior unchanged by making the filtering opt-in
  • add coverage for empty, tool-only, prompt-only, and resource-template-only MCPServer initialization

Testing

  • python3 -m py_compile src/mcp/server/lowlevel/server.py src/mcp/server/mcpserver/server.py tests/server/mcpserver/test_server.py
  • pytest tests/server/mcpserver/test_server.py -k capability (not run locally: pytest is not installed in this environment)

@rendina-io
Copy link
Copy Markdown

Advertising capabilities that have no registered handlers is a sneaky source of compatibility issues — clients that enumerate capabilities and then try to call an unregistered primitive get confusing 'method not found' errors instead of a clean capability negotiation failure. Filtering at the capability advertisement level is the right place to fix this. Does the change affect the list_changed notification behavior, or is that still gated on the same registered-primitive check?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants