Files

30 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

2026-07-12 06:53:31 +08:00
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
import { describe, expect, it } from "vitest";
2026-07-12 21:12:18 +00:00
import { observed as ok } from "./fixtures/analysisExecution.js";
import { createServer } from "../src/server/createServer.js";
2026-07-12 19:32:13 +08:00
const analysis = {
execute: () => Promise.resolve(ok(null)),
};
2026-07-16 20:09:14 +08:00
describe("MCP server composition", () => {
it("constructs independent MCP server instances", () => {
2026-07-12 19:32:13 +08:00
expect(createServer(analysis)).not.toBe(createServer(analysis));
});
2026-07-12 06:53:31 +08:00
it("does not advertise unavailable session tools", async () => {
2026-07-12 19:32:13 +08:00
const server = createServer(analysis);
2026-07-12 06:53:31 +08:00
const client = new Client({ name: "composition-test", version: "1.0.0" });
const [clientTransport, serverTransport] =
InMemoryTransport.createLinkedPair();
await server.connect(serverTransport);
await client.connect(clientTransport);
expect(client.getInstructions()).not.toContain("open_binary");
const names = (await client.listTools()).tools.map(({ name }) => name);
expect(names).not.toContain("compare_managed_members");
expect(names).not.toContain("plan_managed_runtime_correlation");
2026-07-12 06:53:31 +08:00
await client.close();
await server.close();
});
});