SIGN IN SIGN UP

fix: coerce MCP tool args to match schema string types (#11852)

* fix: coerce MCP tool args to match schema string types

When tool call arguments are parsed via JSON.parse(), string-typed
parameters containing valid JSON (e.g. file content for .json files)
get deeply parsed into objects. Built-in tools handle this via
getStringArg(), but MCP tools with dynamic schemas had no equivalent
fix, causing write_file and similar tools to receive objects instead
of strings.

Add coerceArgsToSchema() that checks the tool's inputSchema and
re-stringifies any values that should be strings before passing
args to the MCP client.

Fixes #8510

* fix: narrow coercion to only objects/arrays, not numbers/booleans

Only re-stringify values that are objects or arrays (the actual
deep-parsing issue). Numbers and booleans passed to a string-typed
parameter are left as-is so they surface as type errors rather than
being silently converted.
D
Dallin Romney committed
ff89a882995c6d7eb61f8b3df1fd1b8761d6ef27
Parent: b7fead5
Committed by GitHub <noreply@github.com> on 3/25/2026, 11:39:01 PM