Browser-Use is a powerful tool that enables AI agents to control web browsers, automate tasks, and interact with websites just like a human would. It provides a seamless way to create AI agents that can navigate the web, fill forms, extract information, and perform complex sequences of actions.
To install Browser-Use, you'll need Python 3.11 or higher:
pip install browser-use
If you don't already have Chrome or Chromium installed, you can download the latest Chromium using playwright's install shortcut:
uvx playwright install chromium --with-deps --no-shell
First, create a .env
file in your project directory and add your API key:
OPENAI_API_KEY=your_openai_api_key_here
Here's a basic example to create an agent that finds the number of stars on the Browser-Use repository:
import asyncio
from dotenv import load_dotenv
load_dotenv()
from browser_use import Agent, ChatOpenAI
async def main():
agent = Agent(
task="Find the number of stars of the browser-use repo",
llm=ChatOpenAI(model="gpt-4.1-mini"),
)
await agent.run()
asyncio.run(main())
Browser-Use supports the Model Context Protocol (MCP), allowing integration with Claude Desktop and other MCP-compatible clients.
Add Browser-Use to your Claude Desktop configuration:
{
"mcpServers": {
"browser-use": {
"command": "uvx",
"args": ["browser-use[cli]", "--mcp"],
"env": {
"OPENAI_API_KEY": "sk-..."
}
}
}
}
You can extend your agent's capabilities by connecting to multiple external MCP servers:
import asyncio
from browser_use import Agent, Controller, ChatOpenAI
from browser_use.mcp.client import MCPClient
async def main():
# Initialize controller
controller = Controller()
# Connect to multiple MCP servers
filesystem_client = MCPClient(
server_name="filesystem",
command="npx",
args=["-y", "@modelcontextprotocol/server-filesystem", "/Users/me/documents"]
)
github_client = MCPClient(
server_name="github",
command="npx",
args=["-y", "@modelcontextprotocol/server-github"],
env={"GITHUB_TOKEN": "your-github-token"}
)
# Connect and register tools from both servers
await filesystem_client.connect()
await filesystem_client.register_to_controller(controller)
await github_client.connect()
await github_client.register_to_controller(controller)
# Create agent with MCP-enabled controller
agent = Agent(
task="Find the latest pdf report in my documents and create a GitHub issue about it",
llm=ChatOpenAI(model="gpt-4.1-mini"),
controller=controller # Controller has tools from both MCP servers
)
# Run the agent
await agent.run()
# Cleanup
await filesystem_client.disconnect()
await github_client.disconnect()
asyncio.run(main())
Browser-Use can handle various automation tasks, such as:
For more detailed examples and inspiration, you can check out the examples folder in the repository or visit the official documentation.
If you prefer to skip the local setup, you can use the Browser-Use Cloud for faster, scalable, and stealth-enabled browser automation.
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.json
2. 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