Skip to content

Avoiding to parse string arguments containing valid JSON if the argument annotation is str #1113

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

Merged
merged 1 commit into from
Jul 10, 2025

Conversation

cjg
Copy link
Contributor

@cjg cjg commented Jul 9, 2025

Every time a parameter of a tool is passed as a string containing a valid JSON it is parsed and replaced. From the comment of pre_parse_json() "This is to handle cases like ["a", "b", "c"] being passed in as JSON inside a string rather than an actual list"

Nevertheless this method doesn't check if the annotation of parameters indicates that it is supposed to be a str rather than a dict or a list

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

@bhosmer-ant bhosmer-ant self-requested a review July 10, 2025 16:21
Copy link
Contributor

@bhosmer-ant bhosmer-ant left a comment

Choose a reason for hiding this comment

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

@cjg thank you for this!

@bhosmer-ant bhosmer-ant merged commit 0a4e8d4 into modelcontextprotocol:main Jul 10, 2025
19 of 20 checks passed
@bhosmer-ant bhosmer-ant mentioned this pull request Jul 10, 2025
9 tasks
ihrpr pushed a commit that referenced this pull request Jul 11, 2025
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