|
| 1 | +/** |
| 2 | + * Snapshot the public MCP surface so a future rename or accidental drop |
| 3 | + * (between TOOLS, OOXML_TOOL_DEFS, and the docs) fails CI. |
| 4 | + * |
| 5 | + * No DB access; we exercise tools/list and the initialize handler. tools/call |
| 6 | + * is covered by the per-tool tests in ooxml-queries.test.ts. |
| 7 | + */ |
| 8 | + |
| 9 | +import { expect, test } from "bun:test"; |
| 10 | +import { handleMcpRequest } from "../../apps/mcp-server/src/mcp.ts"; |
| 11 | + |
| 12 | +const EXPECTED_TOOL_NAMES = [ |
| 13 | + // Prose search (over the spec PDFs) |
| 14 | + "ooxml_search", |
| 15 | + "ooxml_section", |
| 16 | + "ooxml_parts", |
| 17 | + // Schema lookup (over the parsed XSDs) |
| 18 | + "ooxml_element", |
| 19 | + "ooxml_type", |
| 20 | + "ooxml_children", |
| 21 | + "ooxml_attributes", |
| 22 | + "ooxml_enum", |
| 23 | + "ooxml_namespace", |
| 24 | +] as const; |
| 25 | + |
| 26 | +interface JsonRpcResponse { |
| 27 | + jsonrpc: string; |
| 28 | + id: number | string | null; |
| 29 | + result?: { tools?: Array<{ name: string }>; serverInfo?: { name: string } }; |
| 30 | + error?: { code: number; message: string }; |
| 31 | +} |
| 32 | + |
| 33 | +async function rpc(method: string, params?: unknown): Promise<JsonRpcResponse> { |
| 34 | + const req = new Request("https://example.invalid/mcp", { |
| 35 | + method: "POST", |
| 36 | + headers: { "Content-Type": "application/json" }, |
| 37 | + body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }), |
| 38 | + }); |
| 39 | + // Env is unused for tools/list and initialize. |
| 40 | + const env = { DATABASE_URL: "", VOYAGE_API_KEY: "" } as never; |
| 41 | + const res = await handleMcpRequest(req, env); |
| 42 | + return (await res.json()) as JsonRpcResponse; |
| 43 | +} |
| 44 | + |
| 45 | +test("tools/list returns the full ooxml_* tool set in the documented order", async () => { |
| 46 | + const r = await rpc("tools/list"); |
| 47 | + const names = r.result?.tools?.map((t) => t.name) ?? []; |
| 48 | + expect(names).toEqual([...EXPECTED_TOOL_NAMES]); |
| 49 | +}); |
| 50 | + |
| 51 | +test("initialize advertises serverInfo.name as 'ooxml'", async () => { |
| 52 | + const r = await rpc("initialize"); |
| 53 | + expect(r.result?.serverInfo?.name).toBe("ooxml"); |
| 54 | +}); |
0 commit comments