-
Notifications
You must be signed in to change notification settings - Fork 105
Tools with the same name in different modules override each other #197
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Tools sharing the same name across different modules aren’t working, likely because of this line: https://github.com/modelcontextprotocol/ruby-sdk/blob/main/lib/mcp/server.rb#L54
To Reproduce
If your tool structure looks like this, for example
app/tools
├── application_tool.rb
├── clients
│ ├── create_tool.rb
│ ├── destroy_tool.rb
│ ├── index_tool.rb
│ ├── show_tool.rb
│ └── update_tool.rb
├── projects
│ ├── create_tool.rb
│ ├── destroy_tool.rb
│ ├── index_tool.rb
│ ├── show_tool.rb
│ └── update_tool.rb
Only the most recently registered tool remains in the tools list:
[Clients::UpdateTool, Projects::UpdateTool].to_h { |t| [t.name_value, t] }
# => {"update_tool" => Projects::UpdateTool}This happens because name_value returns update_tool for both classes.
Expected behavior
We should probably use a more robust key here to properly handle this case. I could open a PR if needed and adapt the tests, but let me know first what you think about it!
Thanks for this gem! 🙌
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working