From 04d0819744afe8870eb36f1c92f9baddb18a490f Mon Sep 17 00:00:00 2001 From: anticafeformat-dev <249614758+anticafeformat-dev@users.noreply.github.com> Date: Thu, 14 May 2026 13:18:34 +0000 Subject: [PATCH] fix(mcp): wrap tools/call result in spec-required content array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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)`. --- src/mcp/server.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mcp/server.ts b/src/mcp/server.ts index bcb0d09..84b62da 100644 --- a/src/mcp/server.ts +++ b/src/mcp/server.ts @@ -123,7 +123,9 @@ export class McpServer { } const args: unknown = record.arguments ?? {}; const result: unknown = await tool.handler(args); - return result; + return { + content: [{ type: "text", text: JSON.stringify(result) }] + }; } private sendResult(id: JsonRpcId, result: unknown): void {