From 9743051f0604cabb4d3d65f9c2d160a77624b496 Mon Sep 17 00:00:00 2001 From: Anton Pidkuiko MacBook Date: Fri, 5 Dec 2025 23:12:26 +0000 Subject: [PATCH] Fix callServerTool to handle wrapped JSON-RPC responses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some host implementations incorrectly return the full JSON-RPC envelope (with result, jsonrpc, id fields) instead of just the unwrapped result. This causes apps using callServerTool() to fail when accessing result.content. This fix detects wrapped responses and unwraps them automatically. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/app.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app.ts b/src/app.ts index c6fc931b..5ae64abb 100644 --- a/src/app.ts +++ b/src/app.ts @@ -581,11 +581,17 @@ export class App extends Protocol { params: CallToolRequest["params"], options?: RequestOptions, ): Promise { - return await this.request( + const response = await this.request( { method: "tools/call", params }, CallToolResultSchema, options, ); + // TEMPORAL HACK: Some host implementations incorrectly return the full + // JSON-RPC envelope instead of just the result. Unwrap if needed. + if (response && "result" in response && "jsonrpc" in response) { + return (response as unknown as { result: CallToolResult }).result; + } + return response; } /**