Skip to content

Conversation

omerc7
Copy link

@omerc7 omerc7 commented Mar 23, 2025

Tool input values in pre_parse_json should only be transformed or cast after the output of json.loads has been validated via Pydantic.

Motivation and Context

The input to the tool may undergo slight transformations in func_metadata.py::pre_parse_json.
For example, a field expected to be a string might be mistakenly cast to a different type. If the input arguments are {"field_name": "5"}, pre_parse_json will incorrectly cast the string "5" to the integer 5, resulting in an error when the field is expected to remain a string.

How Has This Been Tested?

Added num_annotated_with_str to test_func_metadata.py
Tested on local MCP server

Breaking Changes

No

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

@omerc7 omerc7 force-pushed the func-metadata-change-input-only-if-valid-type branch from 2442abc to 528afdd Compare March 25, 2025 08:23
@ihrpr ihrpr added this to the r-05-25 milestone May 13, 2025
Copy link
Contributor

@ihrpr ihrpr 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 for contributing to MCP Python SDK!

looks like typecheck and tests are failing

@ihrpr
Copy link
Contributor

ihrpr commented Jul 9, 2025

Closing this PR as it's stale now. Please re-open when changes are applied and this change is still needed.

@ihrpr ihrpr closed this Jul 9, 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