Skip to content

Commit 5ff5484

Browse files
committed
add MCP stdio integration test and fix optional execute options
1 parent bd0d1f8 commit 5ff5484

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { describe, expect, it } from "vitest";
2+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
3+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
4+
import { resolve } from "node:path";
5+
6+
const repoRoot = resolve(import.meta.dirname, "../../../..");
7+
const cliEntry = resolve(repoRoot, "apps/cli/src/main.ts");
8+
const testScope = resolve(repoRoot, "apps/local");
9+
10+
describe("MCP stdio integration", () => {
11+
it("execute tool returns result over stdio transport", async () => {
12+
const transport = new StdioClientTransport({
13+
command: "bun",
14+
args: ["run", cliEntry, "mcp", "--scope", testScope],
15+
});
16+
17+
const client = new Client(
18+
{ name: "test-client", version: "1.0.0" },
19+
{ capabilities: {} },
20+
);
21+
22+
await client.connect(transport);
23+
24+
try {
25+
const { tools } = await client.listTools();
26+
expect(tools.map((t) => t.name)).toContain("execute");
27+
28+
const result = await client.callTool({
29+
name: "execute",
30+
arguments: { code: "return 2+2" },
31+
});
32+
33+
const text = (result.content as Array<{ type: string; text: string }>)[0]?.text;
34+
expect(text).toContain("4");
35+
expect(result.isError).toBeFalsy();
36+
} finally {
37+
await transport.close();
38+
}
39+
}, 30_000);
40+
});

0 commit comments

Comments
 (0)