The Browser-Use MCP server is a powerful tool that allows you to run browser automation agents that can perform tasks on your behalf. These agents can fill out forms, shop for groceries, search for information, and much more through a browser interface, all controlled through API calls.
First, create a Python environment (Python 3.11 or newer required) using uv:
uv init
Install the Browser-Use package:
uv add browser-use
uv sync
Obtain your API key from Browser Use Cloud. New signups receive $10 in free credits.
Add the API key to your .env file:
# .env
BROWSER_USE_API_KEY=your-key
Install the required Chromium browser:
uvx browser-use install
Here's a simple example to get started with Browser-Use:
from browser_use import Agent, Browser, ChatBrowserUse
import asyncio
async def example():
browser = Browser(
# use_cloud=True, # Uncomment to use a stealth browser on Browser Use Cloud
)
llm = ChatBrowserUse()
agent = Agent(
task="Find the number of stars of the browser-use repo",
llm=llm,
browser=browser,
)
history = await agent.run()
return history
if __name__ == "__main__":
history = asyncio.run(example())
Browser-Use provides sandboxes for easy deployment. Sandboxes handle agents, browsers, persistence, auth, cookies, and LLMs:
from browser_use import Browser, sandbox, ChatBrowserUse
from browser_use.agent.service import Agent
import asyncio
@sandbox()
async def my_task(browser: Browser):
agent = Agent(task="Find the top HN post", browser=browser, llm=ChatBrowserUse())
await agent.run()
# Call it like any async function
asyncio.run(my_task())
Generate ready-to-run templates for faster development:
uvx browser-use init --template default
This creates a browser_use_default.py file with a working example. Available templates include:
default - Minimal setup to get started quicklyadvanced - All configuration options with detailed commentstools - Examples of custom tools and extending the agentYou can specify a custom output path:
uvx browser-use init --template default --output my_agent.py
You can extend the agent's capabilities with custom tools:
from browser_use import Tools
tools = Tools()
@tools.action(description='Description of what this tool does.')
def custom_tool(param: str) -> str:
return f"Result: {param}"
agent = Agent(
task="Your task",
llm=llm,
browser=browser,
tools=tools,
)
For websites requiring login, you can:
To sync your auth profile with a remote browser:
curl -fsSL https://browser-use.com/profile.sh | BROWSER_USE_API_KEY=XXXX sh
(Replace XXXX with your actual API key)
For better CAPTCHA handling, use Browser Use Cloud which provides stealth browsers designed to avoid detection and CAPTCHA challenges by utilizing better browser fingerprinting and proxies.
Browser-Use offers an optimized model specifically for browser automation tasks:
llm = ChatBrowserUse()
This model typically completes tasks 3-5x faster than other models with state-of-the-art accuracy.
For other LLM providers, you can check the supported models documentation on the official website.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "browser-use" '{"command":"uvx","args":["browser-use[cli]","--mcp"],"env":{"OPENAI_API_KEY":"sk-..."}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:
{
"mcpServers": {
"browser-use": {
"command": "uvx",
"args": [
"browser-use[cli]",
"--mcp"
],
"env": {
"OPENAI_API_KEY": "sk-..."
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json2. Add this to your configuration file:
{
"mcpServers": {
"browser-use": {
"command": "uvx",
"args": [
"browser-use[cli]",
"--mcp"
],
"env": {
"OPENAI_API_KEY": "sk-..."
}
}
}
}
3. Restart Claude Desktop for the changes to take effect