Repository navigation
fix(mcp): wrap tools/call result in spec-required content array - #2
Open
anticafeformat-dev wants to merge 1 commit into
Open
anticafeformat-dev wants to merge 1 commit into
anticafeformat-dev wants to merge 1 commit into
Conversation
`callTool` in `src/mcp/server.ts` returned the tool handler's payload
as the JSON-RPC `result` directly (e.g. `{user: {...}}` for
`get_current_user`). The MCP specification requires `tools/call` to
return:
```json
{
"content": [{"type": "text", "text": "..."}],
"isError": false // optional, defaults to false
}
```
Strict MCP clients (e.g. Claude Code) ignore non-spec result shapes
and surface tool calls as `(completed with no output)` — silent
failure with no error to debug. Affects all 13 registered tools.
This patch wraps the handler's return value in the required envelope
at a single point (the central `callTool` method), so every tool gets
spec-compliant output without per-tool changes.
## Verification
stdin smoke test (`initialize` + `tools/call get_current_user`):
- Before:
`{"result":{"user":{"id":1,"name":"Григорий",...}}}`
- After:
`{"result":{"content":[{"type":"text","text":"{\"user\":{\"id\":1,...}}"}]}}`
Claude Code now displays the JSON payload to the model; previously
returned `(no output)`.
This was referenced May 14, 2026
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
callToolinsrc/mcp/server.tsreturns the tool handler's payload as the JSON-RPCresultdirectly:For example,
get_current_userends up sending:{"jsonrpc":"2.0","id":2,"result":{"user":{"id":1,"name":"...","email":"..."}}}The MCP specification requires a
tools/callresponse to use the standard content envelope:{ "content": [{"type": "text", "text": "..."}], "isError": false }Strict MCP clients (e.g., Claude Code) ignore non-spec result shapes and surface tool calls as
(completed with no output)— silent failure with no error to debug. This affects all 13 registered tools, not a specific one.Fix
Wrap the handler's return value in the required envelope at a single point — the central
callToolmethod — so every tool gets spec-compliant output without per-tool changes:Verification
stdin smoke test (
initialize+tools/call get_current_user):{"jsonrpc":"2.0","id":2,"result":{"user":{"id":1,"name":"...","email":"..."}}}{"jsonrpc":"2.0","id":2,"result":{"content":[{"type":"text","text":"{\"user\":{\"id\":1,\"name\":\"...\"}}"}]}}Claude Code now displays the JSON payload to the model; previously returned silent
(no output).Note
This is an independent fix from #1 (capabilities shape). Both are MCP-spec compliance issues but in different code paths and can be merged independently.