MCP server for agent-browser
npm install mcp-agent-browserMCP server for the agent-browser CLI.
Install the Vercel agent-browser CLI:
https://github.com/vercel-labs/agent-browser
Ensure Playwright browser binaries are installed:
``bash`
agent-browser install
`bash`
pnpm install
pnpm build
`bash`
npm install -g mcp-agent-browser
`bash`
codex mcp add mcp-agent-browser
: Override the agent-browser CLI path.
- AGENT_BROWSER_MCP_LOG: Write JSONL logs for all tool calls.
- AGENT_BROWSER_MCP_TIMEOUT_MS: Per-command timeout in ms (default: 30000).Smoke test (stdio)
`bash
npm run build
npm run smoke
`The smoke test sends a correct MCP
initialize request (including protocolVersion) and then lists tools.Run
`bash
node dist/mcp.js
`Run with npx
Once published:
`bash
npx mcp-agent-browser
`Electron/CDP usage:
`bash
Start Electron with a remote debugging port (example)
./YourElectronApp --remote-debugging-port=9222Connect once, then run commands
agent-browser connect 9222Or pass --cdp on each command
agent-browser --cdp 9222 snapshot
`MCP usage with Electron/CDP:
`json
{ "name": "browser.connect", "arguments": { "port": 9222, "session": "agent1" } }
{ "name": "browser.snapshot", "arguments": { "session": "agent1", "cdpPort": 9222 } }
`MCP JSON-RPC example (stdio):
`json
{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "browser.connect", "arguments": { "port": 9222, "session": "agent1" } } }
{ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "browser.snapshot", "arguments": { "session": "agent1", "cdpPort": 9222 } } }
`MCP tool payloads (decoded from
content.text):`json
{ "ok": true, "port": 9222 }
``json
{
"ok": true,
"elements": [{ "ref": "e1", "role": "button", "name": "Submit", "selectorHint": "@e1" }],
"raw": {
"snapshot": "...",
"refs": { "e1": { "role": "button", "name": "Submit" } }
}
}
`See
docs/mcp-agent-browser.md` for tool definitions, error handling, and configuration.