Skip to content

Commit 9743051

Browse files
antonpk1claude
andcommitted
Fix callServerTool to handle wrapped JSON-RPC responses
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 <[email protected]>
1 parent 437b918 commit 9743051

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/app.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,17 @@ export class App extends Protocol<Request, Notification, Result> {
581581
params: CallToolRequest["params"],
582582
options?: RequestOptions,
583583
): Promise<CallToolResult> {
584-
return await this.request(
584+
const response = await this.request(
585585
{ method: "tools/call", params },
586586
CallToolResultSchema,
587587
options,
588588
);
589+
// TEMPORAL HACK: Some host implementations incorrectly return the full
590+
// JSON-RPC envelope instead of just the result. Unwrap if needed.
591+
if (response && "result" in response && "jsonrpc" in response) {
592+
return (response as unknown as { result: CallToolResult }).result;
593+
}
594+
return response;
589595
}
590596

591597
/**

0 commit comments

Comments
 (0)