fix: add validation and warnings for large MCP tool arguments #6116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #6108
Problem
MCP tool calls were being truncated around 4000 characters when passing large JSON arguments. This was happening because some language models have internal limits on the size of tool call arguments they can generate.
Solution
Added validation in the MCP tool handler to:
Changes
useMcpToolTool.ts
to add truncation detection and validationTesting
This provides a better user experience by clearly explaining when and why MCP tool calls fail due to size limitations.
Important
Adds validation and warnings for large MCP tool arguments in
useMcpToolTool.ts
, improving error handling for truncated JSON.useMcpToolTool.ts
to detect truncated JSON arguments and warn users for large but valid JSON (over 3800 chars).useMcpToolTool.spec.ts
for large JSON warnings, truncated JSON errors, incomplete array detection, and normal invalid JSON.This description was created by
for 266ee8e. You can customize this summary. It will automatically update as commits are pushed.