Harden MCP schema and wire Claude OAuth/token handling

This commit is contained in:
2026-02-23 14:48:01 -05:00
parent ef2a25b5fb
commit 62e2491cde
14 changed files with 770 additions and 56 deletions

90
tests/mcp-load.test.ts Normal file
View 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);
});