fix!: answer non-object tools/call params instead of ending the server - #19
Merged
Martin Bens (SpiGAndromeda) merged 1 commit intoSep 12, 2026
Merged
Conversation
handle_tools_call read `.name` and `.arguments` before checking the type of params. Under `set -o posix` bash inherits errexit into the command substitutions those extractions run in, so jq's failure to index a number, string, array or `true` with those keys ended the whole server with no response, and the request that followed was never answered. In the default mode the server survived and answered `-32602 Invalid tool name: `, but jq wrote its `Cannot index ...` diagnostics straight to the process's stderr, outside `log`.
params is now gated as an object before either field is read, on the same footing as process_request's request-object gate, so the extractions cannot fail in any shell mode and the call answers `-32602 Invalid params: expected an object`. A present `null` or `false` params is normalized to `{}` before dispatch and keeps the `Invalid tool name: ` answer. POSIX mode is not a configuration the SDK claims to support, but it no longer ends the server on this path.
BREAKING CHANGE: the answer for a tools/call whose params is a number, string, array or `true` changes from `-32602 Invalid tool name: ` to `-32602 Invalid params: expected an object`. A consumer matching on that message text updates it; the error code is unchanged.
Fixes #15.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Martin Bens (SpiGAndromeda)
deleted the
fix/tools-call-params-object-gate
branch
September 13, 2026 10:50
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.
Fixes #15.
handle_tools_callread.nameand.argumentsbefore checking the type ofparams. Underset -o posixbash inherits errexit into the command substitutions those extractions run in, so jq's failure to index a number, string, array ortrueended the whole server with no response, and the request that followed was never answered. In the default mode the server survived and answered-32602 Invalid tool name:, but jq wrote itsCannot index ...diagnostics straight to the process's stderr, outsidelog.paramsis now gated as an object at the top ofhandle_tools_call, on the same footing asprocess_request's request-object gate, so the extractions cannot fail in any shell mode and the call answers-32602 Invalid params: expected an object. The gate also fails closed for a direct caller passing invalid JSON. A presentnullorfalseparamsis normalized to{}before dispatch and keeps theInvalid tool name:answer. POSIX mode is not a configuration the SDK claims to support, but it no longer ends the server on this path.Breaking: the answer for a
tools/callwhoseparamsis a number, string, array ortruechanges from-32602 Invalid tool name:to-32602 Invalid params: expected an object. A consumer matching on that message text updates it; the error code is unchanged.New suite
tests/tools_call_params.bats(5 tests): the-32602envelope for number/string/arrayparamsthroughprocess_request, server survival plus a follow-uppinganswered underset -o posixthroughrun_mcp_server, and a clean stderr in the default mode.The sibling defect where a non-object tools or config file document ends the server is #18 and stays separate.