feat: add openclaw channel mcp bridge

This commit is contained in:
Peter Steinberger
2026-03-28 02:41:06 +00:00
parent a65d603b31
commit 71f37a59ca
11 changed files with 1839 additions and 3 deletions

View File

@@ -9,11 +9,16 @@ import { createCliRuntimeCapture } from "./test-runtime-capture.js";
const { defaultRuntime, resetRuntimeCapture } = createCliRuntimeCapture();
const mockLog = defaultRuntime.log;
const mockError = defaultRuntime.error;
const serveOpenClawChannelMcp = vi.fn();
vi.mock("../runtime.js", () => ({
defaultRuntime,
}));
vi.mock("../mcp/channel-server.js", () => ({
serveOpenClawChannelMcp,
}));
const tempDirs: string[] = [];
async function createWorkspace(): Promise<string> {
@@ -74,4 +79,33 @@ describe("mcp cli", () => {
);
});
});
it("starts the channel bridge with parsed serve options", async () => {
await withTempHome("openclaw-cli-mcp-home-", async () => {
const workspaceDir = await createWorkspace();
const tokenFile = path.join(workspaceDir, "gateway.token");
vi.spyOn(process, "cwd").mockReturnValue(workspaceDir);
await fs.writeFile(tokenFile, "secret-token\n", "utf-8");
await runMcpCommand([
"mcp",
"serve",
"--url",
"ws://127.0.0.1:18789",
"--token-file",
tokenFile,
"--claude-channel-mode",
"on",
"--verbose",
]);
expect(serveOpenClawChannelMcp).toHaveBeenCalledWith({
gatewayUrl: "ws://127.0.0.1:18789",
gatewayToken: "secret-token",
gatewayPassword: undefined,
claudeChannelMode: "on",
verbose: true,
});
});
});
});