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 <noreply@anthropic.com>
This commit is contained in:
parent
437b9185cc
commit
9743051f06
1 changed files with 7 additions and 1 deletions
|
|
@ -581,11 +581,17 @@ export class App extends Protocol<Request, Notification, Result> {
|
|||
params: CallToolRequest["params"],
|
||||
options?: RequestOptions,
|
||||
): Promise<CallToolResult> {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue