mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-03 05:45:04 +03:00
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).
40 lines
1.5 KiB
TypeScript
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");
|
|
});
|
|
});
|