Harden MCP schema and wire Claude OAuth/token handling
This commit is contained in:
90
tests/mcp-load.test.ts
Normal file
90
tests/mcp-load.test.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtemp, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { resolve } from "node:path";
|
||||
import { loadConfig } from "../src/config.js";
|
||||
import { loadMcpConfigFromEnv } from "../src/mcp.js";
|
||||
|
||||
test("warns when Claude ignores codex-specific shared MCP fields", async () => {
|
||||
const root = await mkdtemp(resolve(tmpdir(), "ai-ops-mcp-load-"));
|
||||
const mcpConfigPath = resolve(root, "mcp.config.json");
|
||||
|
||||
await writeFile(
|
||||
mcpConfigPath,
|
||||
JSON.stringify(
|
||||
{
|
||||
servers: {
|
||||
"local-tools": {
|
||||
type: "stdio",
|
||||
command: "node",
|
||||
args: ["server.js"],
|
||||
enabled_tools: ["read_file"],
|
||||
startup_timeout_sec: 15,
|
||||
},
|
||||
},
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
const warnings: string[] = [];
|
||||
const config = loadConfig({ MCP_CONFIG_PATH: mcpConfigPath });
|
||||
|
||||
const loaded = loadMcpConfigFromEnv(
|
||||
{
|
||||
providerHint: "claude",
|
||||
},
|
||||
{
|
||||
config,
|
||||
warn: (message) => warnings.push(message),
|
||||
},
|
||||
);
|
||||
|
||||
assert.ok(loaded.claudeMcpServers);
|
||||
assert.equal(warnings.length, 2);
|
||||
assert.match(warnings[0] ?? "", /enabled_tools/);
|
||||
assert.match(warnings[1] ?? "", /timeouts/);
|
||||
});
|
||||
|
||||
test("does not warn about Claude-only limitations when provider hint is codex", async () => {
|
||||
const root = await mkdtemp(resolve(tmpdir(), "ai-ops-mcp-load-codex-"));
|
||||
const mcpConfigPath = resolve(root, "mcp.config.json");
|
||||
|
||||
await writeFile(
|
||||
mcpConfigPath,
|
||||
JSON.stringify(
|
||||
{
|
||||
servers: {
|
||||
"local-tools": {
|
||||
type: "stdio",
|
||||
command: "node",
|
||||
args: ["server.js"],
|
||||
enabled_tools: ["read_file"],
|
||||
startup_timeout_sec: 15,
|
||||
},
|
||||
},
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
const warnings: string[] = [];
|
||||
const config = loadConfig({ MCP_CONFIG_PATH: mcpConfigPath });
|
||||
|
||||
loadMcpConfigFromEnv(
|
||||
{
|
||||
providerHint: "codex",
|
||||
},
|
||||
{
|
||||
config,
|
||||
warn: (message) => warnings.push(message),
|
||||
},
|
||||
);
|
||||
|
||||
assert.equal(warnings.length, 0);
|
||||
});
|
||||
Reference in New Issue
Block a user