Skip to content

Conversation

@adamwulf
Copy link
Contributor

Motivation and Context

When receiving a request for ListTools, if the json omits the params, then the tool handler will fail to decode the request. The ListTools request does decode with this json format, however the ListTools.Parameters does not decode the params json value (null) because the NotRequired is handled when decoding the method not when decoding the parameters directly.

How Has This Been Tested?

test added. If commit with the test is checked out, then the test will fail. the following commit contains the fix.

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

…equired parameters to properly decode from null, which wouldn't be possible when decoding from the 'null' JSON encoding directly.
@mattt
Copy link
Contributor

mattt commented Mar 31, 2025

This looks great, @adamwulf. Thank you for your help with all of this, and for your patience as we got this all sorted.

@mattt mattt merged commit 19857af into modelcontextprotocol:main Mar 31, 2025
1 check passed
@adamwulf adamwulf deleted the fix/decode-tool-call branch March 31, 2025 21:39
@adamwulf
Copy link
Contributor Author

Thanks for working through it with me! 🙌

devyhan pushed a commit to devyhan/swift-sdk that referenced this pull request Apr 4, 2025
* Adding unit test

* Decode entire request to strongly typed Method call. This allows NotRequired parameters to properly decode from null, which wouldn't be possible when decoding from the 'null' JSON encoding directly.
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