Adds chrome-devtools-mcp 1.11.0 to the Claude runner so the owner (or a single-mode room) can open pages, click/fill, take screenshots and read console/network errors. Reviewer, arbiter and read-only runtimes do not get it. Chrome runs headless with an isolated temp profile under TMPDIR, Google usage statistics and CrUX lookups are off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
74 lines
2.4 KiB
TypeScript
74 lines
2.4 KiB
TypeScript
import fs from 'fs';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { EJCLAW_ENV } from 'ejclaw-runners-shared';
|
|
|
|
import {
|
|
buildChromeDevtoolsMcpServerConfig,
|
|
buildEjclawMcpServerConfig,
|
|
resolveChromeDevtoolsMcpEntry,
|
|
shouldEnableChromeDevtoolsMcp,
|
|
} from '../src/mcp-config.js';
|
|
|
|
describe('ejclaw MCP config', () => {
|
|
it('always loads EJClaw MCP tools on turn one and preserves runtime env', () => {
|
|
expect(
|
|
buildEjclawMcpServerConfig('/runner/dist/ipc-mcp-stdio.js', {
|
|
chatJid: 'dc:room',
|
|
groupFolder: 'ejclaw',
|
|
agentType: 'claude-code',
|
|
roomRole: 'reviewer',
|
|
ipcDir: '/tmp/ipc/task',
|
|
hostIpcDir: '/tmp/ipc/host',
|
|
}),
|
|
).toEqual({
|
|
command: 'node',
|
|
args: ['/runner/dist/ipc-mcp-stdio.js'],
|
|
alwaysLoad: true,
|
|
env: {
|
|
[EJCLAW_ENV.chatJid]: 'dc:room',
|
|
[EJCLAW_ENV.groupFolder]: 'ejclaw',
|
|
[EJCLAW_ENV.agentType]: 'claude-code',
|
|
[EJCLAW_ENV.roomRole]: 'reviewer',
|
|
[EJCLAW_ENV.ipcDir]: '/tmp/ipc/task',
|
|
[EJCLAW_ENV.hostIpcDir]: '/tmp/ipc/host',
|
|
},
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('chrome-devtools MCP config', () => {
|
|
it('is enabled only for the owner or a single-mode room', () => {
|
|
expect(shouldEnableChromeDevtoolsMcp('owner', false)).toBe(true);
|
|
expect(shouldEnableChromeDevtoolsMcp(undefined, false)).toBe(true);
|
|
expect(shouldEnableChromeDevtoolsMcp('reviewer', false)).toBe(false);
|
|
expect(shouldEnableChromeDevtoolsMcp('arbiter', false)).toBe(false);
|
|
expect(shouldEnableChromeDevtoolsMcp('owner', true)).toBe(false);
|
|
});
|
|
|
|
it('resolves the installed server entry', () => {
|
|
const entry = resolveChromeDevtoolsMcpEntry();
|
|
expect(entry).toMatch(
|
|
/chrome-devtools-mcp\/build\/src\/bin\/chrome-devtools-mcp\.js$/,
|
|
);
|
|
expect(fs.existsSync(entry!)).toBe(true);
|
|
});
|
|
|
|
it('runs headless with an isolated profile and telemetry off', () => {
|
|
const config = buildChromeDevtoolsMcpServerConfig('/x/entry.js', [
|
|
'/work',
|
|
'/home/claude/.tmp',
|
|
]);
|
|
expect(config.command).toBe('node');
|
|
expect(config.args).toEqual([
|
|
'/x/entry.js',
|
|
'--headless',
|
|
'--isolated',
|
|
'--no-usage-statistics',
|
|
'--no-performance-crux',
|
|
'--workspace=/work',
|
|
'--workspace=/home/claude/.tmp',
|
|
]);
|
|
expect(config.env?.CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS).toBe('1');
|
|
});
|
|
});
|