Skip to content

Fix run_tool dropping empty arguments for no-arg downstream tools#3

Merged
eshwar-sundar-glean merged 1 commit into
mainfrom
fix/run-tool-empty-arguments
Jun 14, 2026
Merged

Fix run_tool dropping empty arguments for no-arg downstream tools#3
eshwar-sundar-glean merged 1 commit into
mainfrom
fix/run-tool-empty-arguments

Conversation

@eshwar-sundar-glean

@eshwar-sundar-glean eshwar-sundar-glean commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Problem

run_tool failed for every downstream tool called with no arguments (e.g. slack_read_user_profile), returning:

Expected: object, given: null

Root cause

In src/tools/run-tool.ts, the payload assembly omitted the arguments key entirely when the resolved args were empty:

if (Object.keys(resolvedArgs).length > 0) {
  remoteArgs.arguments = resolvedArgs;
}

With the key absent, the backend run_tool meta-tool forwarded a downstream tools/call with no arguments, which serializes to null. Strict downstream MCP servers validate params.arguments as an object and reject null.

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 pure buildRemoteArgs() helper and added regression tests for the empty and populated cases.

Verification

  • npm run typecheck — clean
  • npm test — 134 passed, including 2 new buildRemoteArgs tests

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).
@eshwar-sundar-glean eshwar-sundar-glean marked this pull request as ready for review June 13, 2026 15:04
{
"name": "glean-experimental",
"version": "0.2.17",
"version": "0.2.18",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#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(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this file to gitignore.

@eshwar-sundar-glean eshwar-sundar-glean merged commit 5df0c3e into main Jun 14, 2026
2 checks passed
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