Files
OmniRoute/open-sse/mcp-server/__tests__/toolSearch.tool.test.ts
Diego Rodrigues de Sa e Souza 7c23dab64d Release v3.8.40
v3.8.40 cycle integration → main. All test gates green (Unit/Integration/Coverage/Node-compat/Quality-Ratchet). The only red check, 'PR Test Policy', is the test-masking heuristic firing on the cumulative ~57-commit release diff (legitimate assert consolidations already reviewed per-PR — Gemini CLI removal #5246, retired GPT models #5280, provider catalog refreshes); overridden with --admin per the documented release-PR convention. CodeQL/SonarQube advisory scans non-blocking; #5278's code already passed CodeQL on main. Homologated on VPS 192.168.0.15 (v3.8.40 healthy).
2026-06-29 08:40:06 -03:00

40 lines
1.5 KiB
TypeScript

import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
import { createMcpServer } from "../server.ts";
vi.mock("../audit.ts", () => ({
logToolCall: vi.fn().mockResolvedValue(undefined),
closeAuditDb: vi.fn(),
}));
describe("omniroute_tool_search", () => {
let client: Client;
beforeEach(async () => {
const [ct, st] = InMemoryTransport.createLinkedPair();
const server = createMcpServer();
await server.connect(st);
client = new Client({ name: "t", version: "1.0.0" });
await client.connect(ct);
});
afterEach(async () => {
await client.close();
});
it("appears in tools/list with read:tools scope", async () => {
const { tools } = await client.listTools();
expect(tools.find((t) => t.name === "omniroute_tool_search")).toBeTruthy();
});
it("returns relevant tool with a signature, not itself", async () => {
const res = await client.callTool({ name: "omniroute_tool_search", arguments: { query: "health" } });
const text = (res.content as Array<{ text: string }>)[0].text;
const parsed = JSON.parse(text);
expect(parsed.tools.some((t: any) => t.name === "omniroute_get_health")).toBe(true);
expect(parsed.tools.every((t: any) => t.name !== "omniroute_tool_search")).toBe(true);
expect(typeof parsed.tools[0].signature).toBe("string");
});
});