Skip to content

Treat omitted MCP tool arguments as empty object#2680

Open
KirtiRamchandani wants to merge 1 commit into
github:mainfrom
KirtiRamchandani:fix/empty-tool-arguments
Open

Treat omitted MCP tool arguments as empty object#2680
KirtiRamchandani wants to merge 1 commit into
github:mainfrom
KirtiRamchandani:fix/empty-tool-arguments

Conversation

@KirtiRamchandani

@KirtiRamchandani KirtiRamchandani commented Jun 13, 2026

Copy link
Copy Markdown

Problem

Zero-parameter MCP tools such as get_me fail when a client omits the arguments field entirely. Some MCP clients send no arguments payload for tools with an empty input schema, which is valid JSON-RPC but breaks server-side unmarshaling.

Root cause

NewServerToolWithContextHandler unmarshals req.Params.Arguments directly into the handler argument struct. When the field is missing or empty, json.Unmarshal receives nil/empty bytes and returns an error before the tool handler runs.

Fix

Default nil or empty Arguments payloads to {} before unmarshaling. This matches the MCP expectation that tools with no required parameters can be invoked without an explicit arguments object.

Testing

  • go test ./pkg/inventory/...

Fixes #2587

Zero-parameter tools like get_me fail when clients omit the arguments
field entirely. Default empty/missing JSON payloads to {} before
unmarshaling.

Fixes github#2587
@KirtiRamchandani KirtiRamchandani requested a review from a team as a code owner June 13, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants