-
Notifications
You must be signed in to change notification settings - Fork 89
Raise an error when duplicate tool names are registered #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Raise an error when duplicate tool names are registered #199
Conversation
|
Won't this make the default tool names overly verbose, as they're presented to the LLM? Can't developers use the existing escape hatch of defining a custom name when registering a tool? I also don't see a single MCP server/controller exposing tools with the same names as being a common use case. If the use case is an MCP gateway, then it could be the responsibility of the gateway (acting as host AND server) to apply a convention for prefixing tool names from upstream MCP servers. |
|
Thank you for the well-reasoned feedback. I do have concerns about tool names becoming longer. However, the effect applies only to default tool names when no explicit name such as As reported in #197, current default tool naming can cause tools to be unexpectedly dropped, and that outcome is concerning from a user-experience standpoint. If a tool name that is more suitable for an LLM (or simply shorter and more concise) is preferred, it should be advisable to specify one explicitly with There is also a possibility of providing a warning from MCP server to the LLM when a configuration such as |
|
How about we raise an exception when a duplicate tool name is registered? So the developer would know and override the name. Anything we do to prevent the silent ignoring of tools is better here. |
Yeah, this does seem like a good approach. Since " After this, I will update the PR with this approach! |
This raises an exception when duplicate tool names are registered, instead of silently overwriting tools. Tool names are required to be unique within a server, so this behavior aligns with the MCP specification. > Tool names SHOULD be unique within a server. https://modelcontextprotocol.io/specification/2025-11-25/server/tools#tool-names Validation for tool names could be made more strictly spec-compliant in a separate effort. Fixes modelcontextprotocol#197
2b21cd1 to
8e6dfa9
Compare
|
I've updated this PR to raise an error when duplicate tool names are registered. NOTE: Validation for tool names could be made more strictly spec-compliant in a separate effort. |
Motivation and Context
This raises an exception when duplicate tool names are registered, instead of silently overwriting tools. Tool names are required to be unique within a server, so this behavior aligns with the MCP specification.
https://modelcontextprotocol.io/specification/2025-11-25/server/tools#tool-names
Validation for tool names could be made more strictly spec-compliant in a separate effort.
Fixes #197
How Has This Been Tested?
Regression and updating tests pass.
Breaking Changes
None.
Types of changes
Checklist