1
/** Chromium inspection and automation through the pinned Chrome DevTools MCP server. @module */3
import { fileURLToPath } from 'node:url'4
import type { Context } from '@deepseek-ai/cordis'5
import { BrowserMcpConfig, mountSessionMcp, validateBrowserMcpConfig } from '@deepseek-ai/dsh-experimental-browser-use-runtime/mcp'7
/** Cordis identity for the Chrome DevTools MCP browser provider. */8
export const name = 'experimental-browser-use-chrome-devtools-mcp'10
/** Services required for scoped MCP startup and prompt readiness checks. */11
export const inject = ['browserUse', 'agents', 'tools', 'systemPrompt']13
/** Fixed Chromium launch or existing-browser attachment settings. */14
export type Config = BrowserMcpConfig16
/** Validate the launch or attachment configuration before activation. */17
export const Config: typeof BrowserMcpConfig = BrowserMcpConfig19
/**20
* Expose Chrome DevTools' upstream catalog through one MCP process per live Session.21
* Attached browsers remain externally owned; the server disables usage statistics.22
* @param ctx - provider context supplying browser use, Agents, and tools.23
* @param config - validated browser choice and optional tool timeout.24
*/25
export function apply(ctx: Context, config: Config): void {26
validateBrowserMcpConfig(config)27
const cli = fileURLToPath(import.meta.resolve('chrome-devtools-mcp/build/src/bin/chrome-devtools-mcp.js'))28
const args = [cli, '--no-usage-statistics']29
if (config.mode === 'attach') {30
args.push(/^wss?:/u.test(config.endpoint) ? '--ws-endpoint' : '--browser-url', config.endpoint)31
} else {32
args.push('--isolated', `--headless=${String(config.headless)}`)33
if (config.executablePath !== undefined) args.push('--executable-path', config.executablePath)34
}35
mountSessionMcp(ctx, {36
name: 'chrome-devtools-mcp',37
exclusive: config.mode === 'attach',38
command: process.execPath,39
args,40
...config.toolCallTimeoutMs === undefined ? {} : { toolCallTimeoutMs: config.toolCallTimeoutMs },41
})42
}