Repository navigation
fix(gateway): forward undeclared tool arguments to the child on the MCP path - #857
tu-trinh-scale wants to merge 8 commits into
Conversation
…CP path
The MCP proxy's argument model ignored keys the tool's schema didn't declare, so
a call such as {"query": ...} to a tool taking `q` reached the child as {} and
returned unfiltered results with isError false, while /step forwarded the same
call unchanged and the child refused it. The proxy now forwards the arguments
as sent, so the child's own input validation decides on both paths.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous commit gave every argument model the gateway builds the
forwarding base, including the ones for its own tools (get_time, the
scheduled-check tools, message_user, stay_quiet). Those are plain functions,
so a stray key such as get_time's {"timezone": ...} raised TypeError and /step
answered 500, which test_gateway_clock_extension pins as "an answer, not a
500". Only a child proxy now forwards undeclared keys; the gateway's own tools
drop them as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The proxy's argument model still declared the child's required fields, so over MCP a missing or misnamed required argument got the gateway's pydantic "Field required" error instead of the child's, and FastMCP's JSON pre-parsing turned a string that parses as JSON into an object. A child proxy's model now declares no fields and forwards every key exactly as sent, as /step does; the published inputSchema is unchanged and the gateway's own tools keep their model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ON-looking strings as sent node_child/server.mjs is a dependency-free Node MCP server over streamable HTTP that validates strictly and never re-parses JSON strings. Behind a real Gateway, over MCP and /step: declared arguments arrive unchanged, an undeclared key reaches the child (refused by name), and '["a"]' arrives as the string. On the merge base the undeclared key was dropped and the string arrived as a list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…parameter The forwarding model dropped FastMCP's pre-parsing, so strict non-FastMCP children such as @playwright/mcp refused a model's stringified array (browser_select_option.values, browser_fill_form.fields). Keep that one repair, only for parameters the child types array/object (not string) and only when the string decodes to that type; undeclared keys and every other value are still forwarded as sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…array or object definition Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tejas-latupalli
left a comment
There was a problem hiding this comment.
LGTM. The new tests fail against the base gateway.py and pass with the change, and forwarding is limited to _proxy_tool; the gateway's own tools still drop stray keys.
Nit: some JSON strings are no longer decoded. The old model typed every field Any, so FastMCP decoded any JSON string into a list/dict/None; the new repair only covers properties typed array/object. These now stay strings:
- an untyped property (
{}) sent'["a"]' - a property wrapped as
allOf: [{$ref}](older pydantic and zod output) sent'{"a":1}' - the string
"null", which used to becomeNone
Handling allOf in _schema_types, plus a test for these cases, would close it.
…s and "null"
As the typed model's FastMCP pre-parsing did for declared properties: a JSON string for a
declared property that takes no strings decodes to the list/dict/null it holds when the
property takes that, including allOf: [{$ref}] (older pydantic, zod) and untyped ({})
properties; "null" becomes None. Undeclared keys are still forwarded unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…JSON-string repair A property with no type but enum ["null", "auto"] got its valid "null" decoded to null; enum/const values now give the property their JSON types, so such strings stay strings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. Done in e697099: the JSON-string repair now also covers |
Makes the gateway forward a child tool's arguments unchanged over MCP, as
/stepalready does, so the child's own validation decides and agents learn when a call is wrong instead of getting silently dropped arguments.What changes
inputSchema: undeclared keys were dropped ({"query": ...}for a tool takingqreturned unfiltered results), missing/misnamed required keys got the gateway's own error, JSON-looking strings became lists/objects.inputSchemaagents see is unchanged.array/object(not alsostring) is decoded when it decodes to that type.@playwright/mcpneeds it; a string for a string parameter stays a string./step.get_time,schedule_check,message_user, ...) still drop stray keys and answer.Checks
unknown_arguments_test.py15 andnode_child_arguments_test.py14 (strict Node child) pass, MCP and/step; key cases fail on the old gateway.@playwright/mcp@0.0.41: stringifiedbrowser_select_option.valuesandbrowser_fill_form.fieldssucceed (fail before).Open items
Rollout
Release as usual (
bump-version→ tag → publish → scaleapi pin), then:agent-env --stage dev env gateway put --id gateway-pr857.agent-env --stage dev task run --id <task id> --k 3 --gateway-env-id gateway-pr857; every new tool error should be a bad-argument call.agent-env env gateway put --id gateway-pr857, then the same runs on a prod task set.agent-env env gateway put --id default(dev, then prod); check an unknown key getsinvalid_arguments, valid calls andget_timewith a stray key work,browser_select_optionwithvalues: '["x"]'selects.agent-env env gateway put --id default.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; the previous string-enum issue is fixed.Summary
The gateway forwards child tool arguments without dropping undeclared keys or checking required fields itself.
Reviews (12) · Last reviewed commit: "gateway: an enum or const of strings cou..." · Reviewed by Greptile