fix(mcp): deliver tool errors within advertised schema contracts
Retain complete typed JSON error content while omitting non-conforming structured errors at the public transport boundary. Recover oversized diagnostics into Evidence before removing their private structured carrier. Update schema-validated client readers and cover actual stdio delivery. Closes #1261 Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
This commit is contained in:
@@ -124,7 +124,18 @@ class ErrorEvidenceTransport implements Transport {
|
||||
: undefined;
|
||||
const tool = id === undefined ? undefined : this.pendingTools.get(id);
|
||||
try {
|
||||
await this.transport.send(this.recoverError(message, tool), options);
|
||||
const recovered = this.recoverError(message, tool);
|
||||
if (
|
||||
isJSONRPCResultResponse(recovered) &&
|
||||
isCallToolResult(recovered.result) &&
|
||||
recovered.result.isError === true
|
||||
) {
|
||||
// Keep the complete typed JSON in content. Error projections are not
|
||||
// success outputSchema data; oversized recovery must consume their
|
||||
// private structured carrier before it is removed from the wire.
|
||||
const { structuredContent: _diagnostic, ...result } = recovered.result;
|
||||
await this.transport.send({ ...recovered, result }, options);
|
||||
} else await this.transport.send(recovered, options);
|
||||
} finally {
|
||||
if (!isJSONRPCRequest(message) && id !== undefined)
|
||||
this.pendingTools.delete(id);
|
||||
|
||||
Reference in New Issue
Block a user