Fix run_tool dropping empty arguments for no-arg downstream tools#3
Merged
Merged
Conversation
The run_tool handler omitted the `arguments` key entirely when the
resolved args were empty (Object.keys(...).length > 0 guard). The backend
run_tool meta-tool then forwarded a downstream tools/call with no
arguments, which serializes to null — and strict MCP servers reject it
with "Expected: object, given: null". This broke every no-argument
downstream tool (e.g. slack_read_user_profile).
Always include `arguments`, defaulting to an explicit {} when empty,
matching what the MCP SDK sends for direct tool calls. Extracted the
payload assembly into a pure buildRemoteArgs() helper and added
regression tests covering empty and populated args.
Rebuilt both shipped bundles and aligned all three plugin manifests to
0.2.18 (max prior version + mandatory version bump).
mohit-gupta-glean
approved these changes
Jun 13, 2026
| { | ||
| "name": "glean-experimental", | ||
| "version": "0.2.17", | ||
| "version": "0.2.18", |
There was a problem hiding this comment.
#suggestion, in a separate PR, can we add a check to make sure that the 3 versions remain in sync.
| throw err; | ||
| } | ||
| const remoteArgs = { | ||
| return callRemoteTool( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
run_toolfailed for every downstream tool called with no arguments (e.g.slack_read_user_profile), returning:Root cause
In
src/tools/run-tool.ts, the payload assembly omitted theargumentskey entirely when the resolved args were empty:With the key absent, the backend
run_toolmeta-tool forwarded a downstreamtools/callwith noarguments, which serializes tonull. Strict downstream MCP servers validateparams.argumentsas an object and rejectnull.The key's presence, not its value, was the only difference between a failing and succeeding call — passing any non-empty object (the prior workaround) incidentally tripped the guard true.
Fix
Always include
arguments, defaulting to an explicit{}when empty — matching what the MCP SDK sends for direct tool calls. Extracted the assembly into a purebuildRemoteArgs()helper and added regression tests for the empty and populated cases.Verification
npm run typecheck— cleannpm test— 134 passed, including 2 newbuildRemoteArgstests