mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 20:33:58 +00:00
* feat(cli): openclaw attach — launch Claude Code bound to a gateway session with scoped MCP tools * fix(cli): use token-only MCP config for attach --------- Co-authored-by: Ayaan Zaidi <hi@obviy.us>
35 lines
1014 B
TypeScript
35 lines
1014 B
TypeScript
import { readFileSync } from "node:fs";
|
|
import { describe, expect, it } from "vitest";
|
|
import { writeClaudeMcpConfig } from "./attach-cli.js";
|
|
|
|
const MCP_CONFIG = {
|
|
mcpServers: {
|
|
openclaw: {
|
|
type: "http",
|
|
url: "http://127.0.0.1:54321/mcp",
|
|
headers: {
|
|
Authorization: "Bearer ${OPENCLAW_MCP_TOKEN}",
|
|
"x-session-key": "${OPENCLAW_MCP_SESSION_KEY}",
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
describe("writeClaudeMcpConfig", () => {
|
|
it("writes the gateway mcpConfig verbatim to a .mcp.json (placeholders preserved for Claude env substitution)", () => {
|
|
const { path, cleanup } = writeClaudeMcpConfig(MCP_CONFIG);
|
|
try {
|
|
expect(path.endsWith(".mcp.json")).toBe(true);
|
|
expect(JSON.parse(readFileSync(path, "utf8"))).toEqual(MCP_CONFIG);
|
|
} finally {
|
|
cleanup();
|
|
}
|
|
});
|
|
|
|
it("cleanup removes the temp config", () => {
|
|
const { path, cleanup } = writeClaudeMcpConfig(MCP_CONFIG);
|
|
cleanup();
|
|
expect(() => readFileSync(path, "utf8")).toThrow();
|
|
});
|
|
});
|