Skip to content

Conversation

@KamdynS
Copy link
Contributor

@KamdynS KamdynS commented Aug 13, 2025

mcp/tool: duplicate tools should not error

These changes touch SetSchema, since that was the best place that I could find resolve this issue.

This is my first time contributing to open source, I hope that I've followed expected formatting and if not I would happy to fix whatever you all need :)

All tests are passing and I duplicated tools in one of the examples(was hello/) and it ran without error.

Fixes #217

@findleyr findleyr requested a review from jba August 13, 2025 17:12
Copy link
Contributor

@findleyr findleyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

mcp/mcp_test.go Outdated
_, cs := basicConnection(t, func(s *Server) {
tool := &Tool{Name: "dup", InputSchema: &jsonschema.Schema{}}
s.AddTool(tool, nopHandler)
s.AddTool(tool, nopHandler)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bug was only in the json schema resolution, right? Meaning, it would also be reprouced if we use a different Tool instance? In that case, use a different description and assert that the tool value is the last tool that was added, by checking its description.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. Made the change and tests are passing.

mcp/tool.go Outdated
if orig == nil {
return nil, nil
}
b, err := json.Marshal(orig)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is the best way to handle this, but @jba will know. Added him as a reviewer.

Copy link
Contributor

@jba jba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@jba jba merged commit 16f2857 into modelcontextprotocol:main Aug 14, 2025
5 checks passed
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.

Adding the same tool results in a jsonschema: Resolve: root already resolved error

3 participants