Files
rea/scripts/lib/large-result-mcp.mjs
Ysopwnable a1ed4232de fix(mcp): retain complete application results across response limits
Retain complete authenticated application Evidence when the repeated MCP representation exceeds the default receive frame or Node string limit. Return a typed transport constraint, keep useful followup queries available, and stream full canonical bundles to atomic destinations.

Verify complete Notion and Obsidian workflows on Linux and native Windows, full CLI/Evidence parity, and real large Chrome screenshot recovery. Preserve complete success contracts and caller-selected evidence paths.

Refs #1065, #1053.
2026-10-08 23:46:02 +08:00

31 lines
851 B
JavaScript

import { Client } from "@modelcontextprotocol/client";
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
/** Own one SDK client with an explicit receive budget for a large complete result. */
export const withLargeResultMcp = async (
{ entrypoint, environment, maxBufferSize },
useClient,
) => {
const client = new Client({ name: "large-result-verifier", version: "1" });
const transport = new StdioClientTransport({
command: process.execPath,
args: [entrypoint, "mcp"],
env: {
...environment,
REA_MCP_MAX_RESPONSE_BYTES: String(maxBufferSize),
},
stderr: "inherit",
maxBufferSize,
});
try {
await client.connect(transport);
return await useClient(client);
} finally {
try {
await client.close();
} finally {
await transport.close();
}
}
};