Total 1465 LOC + 616 test LOC, 78/78 tests pass. - @keisei/mcp-server (25 tests) — Rust-CLI bridge via execa, stdio+HTTP, HMAC auth, kei() meta-tool - @keisei/telegram-adapter (16 tests) — grammy Bot, 7 tools - @keisei/recall-adapter (8 tests) — Zoom via Recall.ai, 5 tools - @keisei/grok-adapter (6 tests) — xAI OpenAI-compatible, 2 tools - @keisei/gmail-adapter (11 tests) — googleapis OAuth2, 6 tools (new — LBM gap) - @keisei/youtube-adapter (12 tests) — YouTube Data API v3, 5 tools (new — LBM gap) RULE 0.2 exception #4 (TS for MCP/API layer documented in _ts_packages/README.md). RULE 0.8 — env vars only (TELEGRAM_BOT_TOKEN, XAI_API_KEY, GMAIL_*, YOUTUBE_API_KEY). Strict TypeScript: strict + exactOptionalPropertyTypes + noUncheckedIndexedAccess. Genesis-scan clean (0 hits).
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { McpServer } from "../src/server.js";
|
|
|
|
describe("server auth", () => {
|
|
it("rejects calls without a token when auth is enabled", async () => {
|
|
const srv = new McpServer({ rustBinDir: "/tmp/stub", authToken: "secret" });
|
|
const resp = await srv.handle({ tool: "kei-ledger", args: { args: {} } });
|
|
expect(resp.ok).toBe(false);
|
|
expect(resp.error?.code).toBe(-32001);
|
|
});
|
|
|
|
it("rejects calls with a wrong token", async () => {
|
|
const srv = new McpServer({ rustBinDir: "/tmp/stub", authToken: "secret" });
|
|
const resp = await srv.handle({
|
|
tool: "kei-ledger",
|
|
args: { args: {} },
|
|
authHeader: "wrong",
|
|
});
|
|
expect(resp.ok).toBe(false);
|
|
expect(resp.error?.code).toBe(-32001);
|
|
});
|
|
|
|
it("allows calls when auth is disabled (stdio mode)", async () => {
|
|
const srv = new McpServer({ rustBinDir: "/tmp/stub" });
|
|
const resp = await srv.handle({ tool: "does-not-exist", args: {} });
|
|
// auth passes → fails on tool lookup instead
|
|
expect(resp.ok).toBe(false);
|
|
expect(resp.error?.code).toBe(-32601);
|
|
});
|
|
});
|