agentic-browser-mcp
Enables MCP clients to automate a real Chrome browser via Playwright, supporting session sharing and tools for navigation, clicking, typing, and more.
README
agentic-browser-mcp
A standalone MCP server that gives any MCP client (Codex, Claude, etc.) browser automation via Playwright. Drive a real, already-logged-in Chrome through the Chrome DevTools Protocol — share cookies and sessions across agents.
Originally extracted from the pi coding agent's browser extension, now a standalone server so Codex / pi / any MCP client can all use the same browser.
Features
- 11 tools:
browser_session,browser_navigate,browser_snapshot,browser_click,browser_type,browser_eval,browser_storage,browser_console,browser_wait_human,browser_screenshot,browser_close - Two session modes:
real—connectOverCDPto an existing Chrome on port9222(reuse your logged-in profile: cookies, sessions, 2FA)isolated—launchPersistentContextwith an independent profile (headed/headless)
- Auto-launch Chrome: if port 9222 is down, the server spawns your Chrome starter script and waits for it — no manual browser launch needed.
- Stable element targeting:
snapshotreturns an ARIA accessibility tree (YAML);click/typetarget byrole+name— no fragile ref/snapshot layers. - Transports:
stdio(default, for Codex-style spawn) andhttp(stateless streamable,--transport http --port 9223).
Requirements
- Node.js ≥ 18
- Playwright-compatible Chrome/Chromium installed (
google-chrome-stableworks) - For
realmode: a Chrome instance running with--remote-debugging-port=9222and a dedicateduser-data-dir(see Start Chrome with CDP)
Install
git clone https://github.com/q35888/agentic-browser-mcp.git
cd agentic-browser-mcp
npm install
Configure your MCP client
Codex (~/.codex/config.toml)
[mcp_servers.agentic-browser]
type = "stdio"
command = "/usr/bin/node"
args = [ "/path/to/agentic-browser-mcp/index.mjs" ]
Any MCP client (stdio)
Spawn node /path/to/agentic-browser-mcp/index.mjs over stdio — standard MCP initialize → tools/list → tools/call.
HTTP mode (long-running single instance)
node index.mjs --transport http --port 9223
# POST MCP requests to http://127.0.0.1:9223/mcp
Start Chrome with CDP (for real mode)
Chrome 150+ requires a non-default user-data-dir for remote debugging. Example starter script:
#!/usr/bin/env bash
PROFILE="$HOME/.agentic-browser-chrome-profile"
mkdir -p "$PROFILE"
# Fill in graphics session env if spawning from a non-graphical context
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
export WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-wayland-0}"
exec google-chrome-stable \
--remote-debugging-port=9222 \
--user-data-dir="$PROFILE" \
--ozone-platform=wayland \
"$@"
--ozone-platform=waylandis important when Chrome is spawned from a background process: otherwise Chrome's platform heuristic picks X11 and fails withMissing X server / Authorization required. Adjust for your display server (X11 users: drop the flag and ensureDISPLAY/XAUTHORITYare set).
If you don't start Chrome manually, the server will try to launch $HOME/.pi/agent/start-agent-chrome.sh automatically (override CHROME_STARTER in index.mjs to point at your own script).
Tools
| Tool | Description |
|---|---|
browser_session |
Start/switch a session (real / isolated, headless, incognito). No args = ensure default real. |
browser_navigate |
Open a URL. |
browser_snapshot |
Return the page's ARIA tree (YAML). Use role+name for click/type. |
browser_click |
Click an element by role (+name). |
browser_type |
Fill an input by role (+name). |
browser_eval |
Run a JS expression in the page (read DOM/storage/fire requests). |
browser_storage |
Read cookies / localStorage / sessionStorage. |
browser_console |
Read buffered console logs (optional level filter). |
browser_wait_human |
For CAPTCHAs/manual steps — returns a prompt; the calling agent pauses and waits for the user. |
browser_screenshot |
Save a PNG to disk. |
browser_close |
Close the current session (real only disconnects CDP, never kills your Chrome). |
Notes
browser_wait_human: this server has no GUI/TUI. It returns a text prompt; the client agent is expected to surface it and wait for the user to reply.- Session sharing: multiple MCP clients connecting to the same server share one Playwright session (and thus one Chrome). Tool calls are serialized to prevent races.
- Resource cleanup: on
stdinEOF, transport close, orSIGINT/SIGTERM, the server disposes the session (with a 3s timeout fallback) —isolatedbrowsers won't be orphaned.
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.