44 lines
2.0 KiB
TypeScript
44 lines
2.0 KiB
TypeScript
/** Chromium inspection and automation through the pinned Chrome DevTools MCP server. @module */
|
|
|
|
import { fileURLToPath } from 'node:url'
|
|
import type { Context } from '@deepseek-ai/cordis'
|
|
import { BrowserMcpConfig, mountSessionMcp, validateBrowserMcpConfig } from '@deepseek-ai/dsh-experimental-browser-use-runtime/mcp'
|
|
import type {} from '@deepseek-ai/dsh-working-directory'
|
|
|
|
/** Cordis identity for the Chrome DevTools MCP browser provider. */
|
|
export const name = 'experimental-browser-use-chrome-devtools-mcp'
|
|
|
|
/** Services required for scoped MCP startup and prompt readiness checks. */
|
|
export const inject = ['browserUse', 'agents', 'tools', 'systemPrompt', 'workingDirectory']
|
|
|
|
/** Fixed Chromium launch or existing-browser attachment settings. */
|
|
export type Config = BrowserMcpConfig
|
|
|
|
/** Validate the launch or attachment configuration before activation. */
|
|
export const Config: typeof BrowserMcpConfig = BrowserMcpConfig
|
|
|
|
/**
|
|
* Expose Chrome DevTools' upstream catalog through one MCP process per live Session.
|
|
* Attached browsers remain externally owned; the server disables usage statistics.
|
|
* @param ctx - provider context supplying browser use, Agents, and tools.
|
|
* @param config - validated browser choice and optional tool timeout.
|
|
*/
|
|
export function apply(ctx: Context, config: Config): void {
|
|
validateBrowserMcpConfig(config)
|
|
const cli = fileURLToPath(import.meta.resolve('chrome-devtools-mcp/build/src/bin/chrome-devtools-mcp.js'))
|
|
const args = [cli, '--no-usage-statistics']
|
|
if (config.mode === 'attach') {
|
|
args.push(/^wss?:/u.test(config.endpoint) ? '--ws-endpoint' : '--browser-url', config.endpoint)
|
|
} else {
|
|
args.push('--isolated', `--headless=${String(config.headless)}`)
|
|
if (config.executablePath !== undefined) args.push('--executable-path', config.executablePath)
|
|
}
|
|
mountSessionMcp(ctx, {
|
|
name: 'chrome-devtools-mcp',
|
|
exclusive: config.mode === 'attach',
|
|
command: process.execPath,
|
|
args,
|
|
...config.toolCallTimeoutMs === undefined ? {} : { toolCallTimeoutMs: config.toolCallTimeoutMs },
|
|
})
|
|
}
|