Using Browser Use MCP with OpenCode
In this article
Browser Use MCP lets OpenCode control a real browser through the Model Context Protocol, enabling AI-assisted web automation like filling forms, clicking buttons, and extracting data. This guide walks through setup and usage.
What You'll Need
- Node.js 18+ installed
- OpenCode CLI installed (
npm install -g opencode) - An Anthropic API key (or another LLM provider OpenCode supports)
- Basic familiarity with terminal commands
Step-by-Step
- Install Browser Use MCP
Runnpm install -g @browseruse/mcpto install the MCP server globally. Verify withbrowser-use-mcp --version. - Configure OpenCode to use the MCP server
Open your OpenCode config file (usually~/.config/opencode/config.json). Add amcpServerssection:{ "mcpServers": { "browser-use": { "command": "browser-use-mcp", "args": [] } } }Save the file. - Restart OpenCode
Exit and relaunch OpenCode so it picks up the new config. You should see a message confirming the MCP server connected. - Test the connection
In OpenCode, type/mcpto list available tools. You should see browser-use tools likebrowser_navigate,browser_click, andbrowser_extract_content. - Start a simple automation
Ask OpenCode: "Navigate to example.com and tell me the heading text." OpenCode will call the browser-use tool, open a real browser window, and return the result. - Use more complex actions
For multi-step tasks, describe the full workflow. Example: "Go to Google, search for 'weather', and read the temperature." OpenCode will chain the MCP calls. - Handle authentication or pop-ups
If a site requires login, manually log in during the session—the browser stays open and controlled. You can also instruct OpenCode to fill credentials, but never store sensitive data in prompts. - Stop the browser
When done, ask OpenCode to "close the browser" or end the session. This prevents background processes from lingering.
Common Mistakes
- Wrong config path – OpenCode config might be at
~/.opencode/config.jsondepending on version. Check withopencode --help. - Missing environment variables – Browser Use MCP may need
ANTHROPIC_API_KEYset. Add it to your shell profile or the config'senvfield. - Using quotes in JSON incorrectly – Ensure the config is valid JSON. Use double quotes only, no trailing commas.
- Assuming the browser is headless – By default, a visible browser opens. If you want headless, set
"headless": truein the MCP server args. - Not waiting for page loads – OpenCode might act before the page is ready. Add explicit waits in your prompt: "Wait for the page to load, then click..."
Tips
- Use specific selectors in prompts, like "click the button with id 'submit'" to reduce errors.
- Test with a simple site first to verify the setup works before tackling complex workflows.
- Keep your prompts concise but complete—OpenCode will translate them into MCP calls, so clarity matters.
- If you need to scrape data, ask for structured output: "Extract all product names and prices into a list."
- Check the browser-use MCP documentation for additional tools like
browser_scrollorbrowser_screenshot.
Troubleshooting
- MCP server not connecting – Run
browser-use-mcpmanually to see errors. Ensure the command is in your PATH. Reinstall if needed. - Tools not showing in OpenCode – Restart OpenCode after config changes. If still missing, check the config file for typos and that the path is correct.
- Browser opens but actions fail – The page might have dynamic elements. Try adding delays or using more robust selectors. Also, check if the site blocks automation (some sites detect headless browsers).
- Permission errors – On Linux/macOS, ensure the browser executable is allowed. You may need to grant accessibility permissions in system settings.
- Slow performance – Use headless mode for speed, but be aware some sites behave differently. Also, close unnecessary tabs.
Frequently Asked Questions
Can I use Browser Use MCP with other LLMs besides Anthropic?
Yes, OpenCode supports multiple providers. Configure your preferred provider in OpenCode settings; the MCP server works independently of the LLM.
Is it safe to enter passwords through OpenCode?
It's risky. Prefer manual login during the session. If you must automate, use environment variables and never hardcode credentials in prompts.
Does this work on Windows?
Yes, but you may need to adjust the command path in the config. Use the full path to browser-use-mcp.cmd if it's not in PATH.
Can I run multiple browser instances?
Yes, but each MCP server instance controls one browser. To run multiple, you'd need multiple server configurations with different names.
How do I update Browser Use MCP?
Run npm update -g @browseruse/mcp to get the latest version. Check the changelog for breaking changes.
What if the browser window doesn't close after the task?
Ask OpenCode to close it, or manually close it. You can also set a timeout in the MCP server config to auto-close after inactivity.