50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
inferTransport,
|
|
toClaudeServerConfig,
|
|
toCodexServerConfig,
|
|
} from "../src/mcp/converters.js";
|
|
|
|
test("infers stdio transport when url is absent", () => {
|
|
const transport = inferTransport({
|
|
command: "npx",
|
|
args: ["-y", "@modelcontextprotocol/server-memory"],
|
|
});
|
|
assert.equal(transport, "stdio");
|
|
});
|
|
|
|
test("infers http transport when url is present", () => {
|
|
const transport = inferTransport({
|
|
url: "http://localhost:3000/mcp",
|
|
});
|
|
assert.equal(transport, "http");
|
|
});
|
|
|
|
test("throws for stdio codex server without command", () => {
|
|
assert.throws(
|
|
() => toCodexServerConfig("bad-server", { type: "stdio" }),
|
|
/requires "command" for stdio transport/,
|
|
);
|
|
});
|
|
|
|
test("maps shared headers to codex http_headers", () => {
|
|
const codexConfig = toCodexServerConfig("headers-server", {
|
|
url: "http://localhost:3000/mcp",
|
|
headers: {
|
|
Authorization: "Bearer token",
|
|
},
|
|
});
|
|
|
|
assert.deepEqual(codexConfig.http_headers, {
|
|
Authorization: "Bearer token",
|
|
});
|
|
});
|
|
|
|
test("throws for claude http server without url", () => {
|
|
assert.throws(
|
|
() => toClaudeServerConfig("bad-http", { type: "http" }),
|
|
/requires "url" for http transport/,
|
|
);
|
|
});
|