User Agents

Web browsers and everyday web tech, explained

Agent Browser MCP with Claude Code Setup Guide

· 7 min read · Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Integrating the Agent Browser Model Context Protocol (MCP) with Claude Code allows your command-line interface to interact directly with a live web browser. This setup enables the agent to navigate websites, extract real-time data, click elements, and perform complex web-based workflows that would otherwise require manual copy-pasting or static API calls. By bridging the gap between a local terminal environment and a headless or headed browser instance, you can automate documentation searches, test web applications in real-time, and scrape dynamic content directly within your coding session.

What You'll Need

  • Claude Code installed and authenticated on your local machine.
  • Node.js (LTS version recommended) installed to run the MCP server.
  • An active internet connection.
  • The @modelcontextprotocol/server-puppeteer package or a similar browser-based MCP implementation.
  • Administrator or sudo privileges to install necessary browser dependencies (specifically for Chromium/Puppeteer).

Step-by-Step

  1. Install the Browser MCP Server: Begin by installing the Puppeteer-based MCP server. Open your terminal and run npm install -g @modelcontextprotocol/server-puppeteer. This package provides the necessary tools for Claude to control a Chromium browser instance. Ensure you are using a global installation so the executable is accessible from any directory where Claude Code is launched.
  2. Configure the Claude Code Config File: Claude Code relies on a configuration file to know which MCP servers to initialize. You must locate your claude_desktop_config.json (or the equivalent config file used by your specific Claude Code installation). Add the browser server to the mcpServers object. The configuration should look like this:
    {
          "mcpServers": {
            "browser": {
              "command": "npx",
              "args": ["-y", "@modelcontextprotocol/server-puppeteer"]
            }
          }
        }
    Save the file and ensure there are no syntax errors, as a trailing comma or missing bracket will prevent the agent from starting.
  3. Initialize Claude Code: Launch Claude Code in your terminal by typing claude. Upon startup, the tool scans the configuration file and attempts to establish a connection with the defined MCP servers. You should see a notification or log entry indicating that the "browser" server has been successfully connected.
  4. Verify Browser Capabilities: To ensure the connection is active, issue a simple command to the agent. Type: "Use the browser to go to google.com and tell me what the doodle is today." If the setup is correct, Claude will call the navigate tool, followed by a screenshot or click tool, and return the text result to your terminal.
  5. Execute Complex Web Tasks: Now that the basic connection is verified, you can use the browser for development tasks. For example, you can ask Claude to "Go to the latest React documentation, find the section on UseEffect, and summarize the best practices for cleanup functions." The agent will navigate the DOM, read the text content, and synthesize the information directly into your current project context.
  6. Manage Browser State: If you need to perform tasks that require a specific session or login, you can instruct the agent to interact with specific cookies or local storage if the MCP server supports it. Otherwise, remember that most Puppeteer-based MCPs start a fresh incognito-style session each time the server restarts.

Common Mistakes

One of the most frequent errors is failing to install the Chromium dependencies required by Puppeteer. On Linux systems, Puppeteer often requires several system-level libraries (like libX11 or libnss3) that are not included in the npm package. If the browser fails to launch, check your system logs for missing .so files.

Another common mistake is using an outdated version of Node.js. MCP servers often utilize modern JavaScript features and ESM modules; using a version of Node older than 18 can lead to "Unexpected token" errors during the server boot process. Always verify your version with node -v before installation.

Users often forget that the browser is running in a "headless" mode by default. This means you won't see a window pop up on your screen. Many users assume the tool isn't working because they don't see a browser opening, when in reality, the agent is interacting with the page in the background. If you need to see the action, you must specifically configure the server to run in "headful" mode via environment variables or config flags.

Finally, there is the issue of selector ambiguity. When asking Claude to "click the button," the agent may struggle if there are multiple buttons with similar text. Providing specific instructions, such as "click the button with the ID 'submit-form'" or "click the third link in the navigation menu," significantly improves reliability.

Tips

To maximize efficiency, combine the browser MCP with local file editing. For instance, you can tell Claude: "Search the Tailwind CSS documentation for the correct utility class for a sticky header, and then apply that class to the header element in src/components/Header.tsx." This creates a seamless loop between research and implementation.

Utilize screenshots for debugging. If the agent claims it cannot find an element on a page, ask it to "take a screenshot of the current page and describe what you see." This allows you to verify if the page has a pop-up, a cookie consent banner, or a CAPTCHA that is blocking the agent's view of the actual content.

Be mindful of rate limiting and bot detection. Some websites employ aggressive anti-bot measures that can detect Puppeteer. To mitigate this, avoid rapid-fire requests to the same domain. If you encounter a block, try asking the agent to wait a few seconds between actions or navigate to a different mirror of the site.

For better precision, use the inspect tool if available in your MCP implementation. By asking the agent to print the HTML structure of a specific div, you can give it the exact CSS selector it needs to interact with a complex web app, reducing the number of trial-and-error attempts.

Troubleshooting

If the browser server fails to start, the first step is to check the Claude Code logs. Look for errors like "Command not found: npx". This usually indicates that Node.js is not in the system PATH that Claude Code is using. Try providing the absolute path to the npx executable in your claude_desktop_config.json instead of just using the command name.

When the agent reports that a page is "blank" or "unable to load," it is often due to a timeout. Large, JavaScript-heavy sites (like those built with Next.js or Nuxt) may take longer to render. Instruct the agent to "wait for the network to be idle" or "wait 5 seconds for the page to load" before attempting to read the content.

If you encounter a "Protocol Error" or "Target Closed" message, it typically means the browser instance crashed. This can happen due to memory exhaustion if the agent opens too many tabs or handles extremely large pages. Restart Claude Code to kill any orphaned Chromium processes and clear the memory cache.

In cases where the agent is stuck in a loop (e.g., clicking the same button repeatedly without success), manually intervene by giving a corrective command. Tell the agent: "Stop clicking that button; it is not responding. Try refreshing the page or looking for an alternative navigation path to the target information." This resets the agent's internal logic and forces it to re-evaluate the DOM.

Frequently Asked Questions

Can the browser MCP handle CAPTCHAs?

Generally, no. Most automated browser tools are blocked by CAPTCHAs. You may need to manually solve the CAPTCHA in a headful browser session or use a service that provides session cookies to bypass the initial check.

Does this use my local browser's history and logins?

No, the Puppeteer MCP server typically launches a clean, isolated Chromium instance. It does not share cookies, bookmarks, or saved passwords with your primary browser (like Chrome or Firefox) unless you specifically configure it to use a persistent user data directory.

Is the browser MCP safe to use on internal company sites?

Yes, as long as you are aware that the agent is sending the page content back to the model for processing. Ensure your company's data privacy policies allow the transmission of internal page text to the model provider.

Can I use this to automate form submissions?

Yes, the browser MCP can fill out text fields and click submit buttons. However, be cautious with sensitive data; avoid asking the agent to enter passwords or credit card information in plain text within the terminal.

What is the difference between this and a standard web search tool?

A search tool typically returns a list of snippets from a search engine. The browser MCP allows the agent to actually visit the page, interact with JavaScript elements, navigate through multiple pages, and see the page exactly as a human user would.

How do I stop the browser if it gets stuck?

The easiest way is to exit the Claude Code session (usually via Ctrl+C or typing /exit). If the browser process persists in the background, you can manually kill it using your system's activity monitor or by running pkill chromium in your terminal.