Files
reverse-engineering-anything/tests/boundary/mcp/toolInputCapacityStdio.test.ts
T
gensokyo-dev f60e42a9ae fix(mcp)!: bound validation work before tool dispatch (#7905)
Reuse the pinned SDK's combined array-element and object-member admission
before canonical validation, deferred runtime loading and tool execution.
Share a configurable finite allowance across eager/deferred HTTP and stdio,
and project refusals to bounded, actionable transport resource errors.

Preserve canonical CLI/application contracts, caller-selected input values,
ordinary validation semantics and complete Evidence access. Exercise actual
transport boundaries, real artifact/TShark workflows, packaged installation,
continued service and downstream identity/capacity regressions.

Fixes #7882

BREAKING CHANGE: MCP tool arguments now default to 1,024 combined array
elements and object members per call. Select a larger positive finite
REA_MCP_MAX_INPUT_ELEMENTS allowance and restart for larger inline inputs,
or use retained/file selectors where supported. Inputs are never truncated.

Assisted-by: Reimu (gensokyo-skills:reimu-incident-triage)
Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis)
2026-10-29 05:56:38 +00:00

59 lines
2.1 KiB
TypeScript

import { Client } from "@modelcontextprotocol/client";
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
import { join, resolve } from "node:path";
import { expect, it, onTestFinished } from "vitest";
import { parseMcpToolError } from "../../fixtures/mcpToolError.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
it("applies the selected input allowance through the public deferred stdio entry point", async () => {
const root = await createTestTempDirectory("rea-input-capacity-stdio-");
const transport = new StdioClientTransport({
command: process.execPath,
args: [resolve("scripts/rea.mjs"), "mcp"],
env: {
PATH: process.env.PATH ?? "",
HOME: root,
USERPROFILE: root,
XDG_CONFIG_HOME: join(root, "config"),
XDG_CACHE_HOME: join(root, "cache"),
XDG_DATA_HOME: join(root, "data"),
HOPPER_LAUNCHER_PATH: "/rea-unconfigured-deep-provider/hopper",
NODE_OPTIONS: "--max-old-space-size=3072",
REA_LOG_LEVEL: "silent",
REA_MCP_MAX_INPUT_ELEMENTS: "8192",
},
stderr: "pipe",
});
transport.stderr?.on("data", () => undefined);
const client = new Client({ name: "input-capacity-stdio", version: "1" });
onTestFinished(async () => {
try {
await client.close();
} finally {
await transport.close();
}
});
await client.connect(transport);
const result = await client.callTool({
name: "compare_bundles",
arguments: {
left_bundle_path: join(root, "absent-left"),
right_bundle_path: join(root, "absent-right"),
record_pairs: Array.from({ length: 8192 }, () => 0),
},
});
const { error } = parseMcpToolError(result);
expect(error.code).toBe("resource_constraint");
expect(error.details).toMatchObject({
resource: "transport",
reported_limits: { max_input_elements: 8192 },
});
expect(Buffer.byteLength(JSON.stringify(result))).toBeLessThan(4096);
await client.ping();
const healthy = await client.callTool({
name: "inspect_analysis_settings",
arguments: {},
});
expect(healthy.isError).not.toBe(true);
}, 90_000);