mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-01 12:21:25 +00:00
feat: add openclaw channel mcp bridge
This commit is contained in:
@@ -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,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user