Overview
The MCP (Model Context Protocol) Server exposes OpenBrowser’s browser automation to AI assistants like Claude Desktop, Claude Code, and other MCP-compatible clients. A 2026-07-28 client callscreate_context to get a server-minted context_id, passes that handle to execute_code, get_status, and reset_browser, and calls close_context when finished. execute_code runs Python to navigate, interact with, and extract data from web pages. get_status reports lifecycle and tab state without starting a browser, and reset_browser recovers a stuck browser while preserving scalar and scalar-only container variables by default; functions, modules, browser-bound objects, cyclic values, and shadowed framework names are dropped and reported in namespace_transfer. Older clients that negotiate 2024-11-05, 2025-03-26, 2025-06-18, or 2025-11-25 receive the original three-tool catalog with a legacy no-handle context. Any other protocol version is rejected with MCP error -32602; it is not downgraded to legacy. No external LLM API keys required — the MCP client provides the intelligence. The server uses the official mcp Python SDK 2.3 and negotiates protocol version 2026-07-28 with modern clients.
Quick Start
Start MCP Server
Claude Desktop Integration
Add this configuration to your Claude Desktop config file:macOS
Edit~/Library/Application Support/Claude/claude_desktop_config.json:
Windows
Edit%APPDATA%\Claude\claude_desktop_config.json:
Claude Code
Add to your project’s.mcp.json:
Environment Variables
Optional configuration:Tools
Modern 2026-07-28 clients see five tools. Older clients see the original three.
If a browser connection fails, call
get_status before retrying. A page-changing action may have partially run, so do not replay it blindly. get_status includes config.startup, config.current, and config.restart_required.
When a profile has been resolved, get_status includes profile.resolution. Each entry has a source key plus a value, or a mode and optional count. The source is default, config, environment, managed, or cli. Sensitive and unbounded fields expose only a mode and source: storage_state is file, memory, or none, proxy is configured or none, and args is configured or none with a count. Cookies, proxy credentials, and argument values are never included.
When a browser session exists, browser.cdp reports root transport health. cdp.healthy is the last accepted connect or probe observation while the lifecycle preserves an active health claim; an inactive snapshot can report null and keeps the history fields. Use cdp.last_probe_at to tell whether a probe has run and how recent it is. Use cdp.healthy, cdp.phase, cdp.last_probe_at, and cdp.last_error_code before retrying. cdp.phase is one of disconnected, resolving, connecting, connected, degraded, or failed. cdp.last_error_code is null or one of not_connected, timeout, connection_closed, session_not_found, probe_failed, connect_failed, or cancelled. session_not_found can come from target attachment during connect setup, not from the root probe alone. cdp_connected is only a pointer-presence alias. Root CDP health does not prove a target session, tab, or page can accept commands. MCP probes an existing session before execution when time remains. get_status itself is read-only and does not probe or start a browser.
get_status adds browser.health when a session exists. health.phase is unknown, healthy, degraded, crashed, stopped, or failed. The block records page-target crash history, the latest focus-recovery outcome, and a status-time process check. health.healthy=true means setup or focus recovery completed, not that a page is ready. Wait while recovery is pending. After a failed recovery, use reset_browser only when no usable target exists. process_present is null when the current CDP root is not bound to the recorded local owner or when process identity is inconclusive, including remote, stopped, and ambiguous local sessions. A missing health block means no context has a browser session.
A legacy, invalid, or unreadable config file blocks browser startup and is never rewritten automatically. Execute calls return a config_* error with a repair hint. Run uvx openbrowser-ai config status to inspect the selected path. Repair the file in place when possible, or move it to a unique backup name before restarting the MCP server. Moving it aside creates a new default and does not migrate old settings. A running MCP server does not hot reload config.
When a browser session exists, get_status also includes browser.navigation, the active or last navigation transaction. It distinguishes the requested URL from the observed document URL and reports its generation, phase, and error. Navigation waits for the declared document milestone rather than a fixed delay. A download outcome is a handoff, not confirmation that a file finished downloading. A document milestone does not establish application hydration.
For a forbidden committed redirect, browser.navigation.containment records security cleanup separately. A cancelled or timed-out request may still own a sent cleanup action. An unconfirmed action keeps the old runtime failed rather than allowing an unsafe replacement. Read get_status before retrying. Status exposes error text, not a dedicated recovery-hint field.
For a managed local browser, use reset_browser to close the owned browser before replacement. If cleanup fails, the old runtime remains retained. For a remote browser, close the actual browser before creating a replacement BrowserSession. Do not assume cancelling a waiter or losing a connection proves that browser execution stopped.
Available Functions
Prefer indexed actions whenever an element index exists. Coordinate actions use CSS viewport pixels, not screenshot pixels. If a screenshot uses a
devicePixelRatio other than 1, divide its coordinates by window.devicePixelRatio before calling an *_xy function.
Bundled libraries: json, csv, re, datetime, asyncio, Path, requests, numpy, pandas. Only if installed: matplotlib, BeautifulSoup, pypdf (openbrowser-ai[pdf]), tabulate.
Variables and state persist between execute_code calls within the same context. A context is process-local: it lives until close_context or server exit, and a new MCP server process cannot resume the same handle. The browser session inside a context auto-closes after 10 minutes without an execute_code call. get_status does not refresh that timer. The handle and scalar variables remain, and the next execute_code call starts a fresh browser. A successful close_context invalidates the handle. If cleanup fails, the result is close_failed with retryable: true. Retry close_context to finish cleanup; the handle cannot be used for execute_code, get_status, or reset_browser. The default limit is 16 open contexts total, including the legacy no-handle context; set OPENBROWSER_MCP_MAX_CONTEXTS to a positive integer to change it. Default workspaces are under ~/Downloads/openbrowser-mcp/workspace/<owner-id> and default downloads are under ~/Downloads/openbrowser-mcp/<owner-id>. Each context also has a managed browser profile under ~/.config/openbrowser/profiles/mcp-<owner-id>. Close retains the profile, workspace, and downloaded files. The owner ID is internal and is not the context_id handle. Read the resolved profile path from get_status.profile.user_data_dir. There is no disk quota or expiry cleanup for retained files. close_context waits for in-flight calls to finish before it closes the browser and profile. New calls while closing fail with context_closing. After a failed close, non-close calls fail with context_close_failed; retry close_context only. A second close after success returns context_not_found. Server shutdown closes every context and can enter a failed shutdown state if cleanup still fails.
Example Usage
Once configured with Claude Desktop or Claude Code, you can ask the AI to perform browser automation tasks:execute_code tool to write Python code that navigates, interacts, and extracts data.
Programmatic Usage
You can also connect to the MCP server programmatically:2024-11-05, 2025-03-26, 2025-06-18, or 2025-11-25 keep the original ClientSession flow and call execute_code without context_id.
CLI Execute Mode
For Bash-based workflows without an MCP client, use the CLI Daemon instead. It provides the sameexecute_code functions via openbrowser-ai -c "code" with a persistent browser daemon.
Troubleshooting
Common Issues
“MCP SDK is required” Error MCP is included in the base package since v0.1.30. Update to the latest version:- Check that you have Chrome/Chromium installed
- Try setting
OPENBROWSER_HEADLESS=falseto see browser window - Ensure no other browser instances are using the same profile
- Restart Claude Desktop after config changes
- Check the config file syntax is valid JSON
- Verify the file path is correct for your OS
Debug Mode
The MCP server keeps Python logging off the stdio channel so JSON-RPC stays valid.OPENBROWSER_LOG_LEVEL is not read by the MCP server. To debug a client integration, inspect the client’s captured server stderr or run uvx openbrowser-ai --mcp directly in a terminal.
Security Considerations
- The MCP server has access to your browser and file system
- Only connect trusted MCP clients
- Be cautious with sensitive websites and data
- Use
OPENBROWSER_ALLOWED_DOMAINSto restrict navigation
Next Steps
- Explore the examples directory for more usage patterns
- Check out MCP documentation to learn more about the protocol
- Join our Discord for support and discussions