Skip to content

mcp: apply defaults to null tool arguments - #1343

Merged
guglielmo-san merged 1 commit into
modelcontextprotocol:mainfrom
pkarpovich:fix-null-tool-arguments
Oct 5, 2026
Merged

guglielmo-san merged 1 commit into
modelcontextprotocol:mainfrom
pkarpovich:fix-null-tool-arguments

Conversation

@pkarpovich

Copy link
Copy Markdown
Contributor

A tools/call request with "arguments": null for a tool whose input schema declares a default panics the server with assignment to entry in nil map. Unmarshaling null into the map in applySchema leaves it nil, and ApplyDefaults then writes into it.

This treats null arguments like missing ones, so the defaults are applied and the call proceeds.

The elicitation paths already skip ApplyDefaults on a nil Content (#1069), so applySchema is the only place that needed the check.

The two new TestApplySchema cases panic on main.

Fixes #1340

A tools/call request with "arguments": null for a tool whose input
schema declares a default panicked the server: unmarshaling null into
the map in applySchema leaves it nil, and ApplyDefaults then writes to
it. Treat null arguments like omitted ones.

Fixes modelcontextprotocol#1340
@guglielmo-san
guglielmo-san merged commit 0f18bc7 into modelcontextprotocol:main Oct 5, 2026
9 checks passed
@guglielmo-san

Copy link
Copy Markdown
Contributor

@pkarpovich thank you for the contribution!

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.

tools/call with "arguments": null panics the server when the tool schema has a default

2 participants