Merge pull request #82 from modelcontextprotocol/fix-callservertool-unwrap
Temporal fix: Handle wrapped JSON-RPC responses in callServerTool
This commit is contained in:
commit
19b9360f40
1 changed files with 7 additions and 1 deletions
|
|
@ -581,11 +581,17 @@ export class App extends Protocol<Request, Notification, Result> {
|
||||||
params: CallToolRequest["params"],
|
params: CallToolRequest["params"],
|
||||||
options?: RequestOptions,
|
options?: RequestOptions,
|
||||||
): Promise<CallToolResult> {
|
): Promise<CallToolResult> {
|
||||||
return await this.request(
|
const response = await this.request(
|
||||||
{ method: "tools/call", params },
|
{ method: "tools/call", params },
|
||||||
CallToolResultSchema,
|
CallToolResultSchema,
|
||||||
options,
|
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