Merge pull request #82 from modelcontextprotocol/fix-callservertool-unwrap

Temporal fix: Handle wrapped JSON-RPC responses in callServerTool
This commit is contained in:
Anton Pidkuiko 2025-12-05 23:15:14 +00:00 • committed by GitHub
commit 19b9360f40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;
}
/**