# Modernize MCP Browser-Use
## 1. Primary Request and Intent
Igor requested modernization of mcp-browser-use MCP server:
- Update browser-use dependency from 0.1.41 to 0.10.1
- Remove LangChain ecosystem dependencies
- Simplify codebase by removing custom wrappers
- Remove deep research feature
- Use browser-use's native LLM providers
- Reduce codebase from ~3200 lines to ~300 lines
**Current handoff purpose**: Create a validation plan before committing the changes.
## 2. Key Technical Concepts
- **browser-use 0.10.1**: Complete API rewrite with native LLM providers
- **MCP (Model Context Protocol)**: Server exposes browser-use as tools
- **FastMCP**: MCP server framework used
- **BrowserProfile**: Replaces old BrowserConfig
- **Native Chat models**: ChatOpenAI, ChatAnthropic, ChatGoogle, ChatOllama (no LangChain)
- **Pydantic Settings**: Configuration management
## 3. Files and Code Sections
### `/Users/igortarasenko/Projects/mcp-browser-use/pyproject.toml`
- **Why important**: Defines dependencies - core of the simplification
- **Changes made**: Reduced from 9+ dependencies to 4, version bumped to 0.2.0
- **Code snippet**:
```toml
dependencies = [
"browser-use>=0.10.1",
"mcp>=1.10.1",
"pydantic-settings>=2.0.0",
"typer>=0.12.0",
]
```
### `/Users/igortarasenko/Projects/mcp-browser-use/src/mcp_server_browser_use/server.py`
- **Why important**: Main MCP server - exposes `run_browser_agent` tool
- **Changes made**: Complete rewrite using native browser-use API (86 lines)
- **Code snippet**:
```python
from browser_use import Agent, BrowserProfile
from mcp.server.fastmcp import Context, FastMCP
from .providers import get_llm
@server.tool()
async def run_browser_agent(ctx: Context, task: str, max_steps: Optional[int] = None) -> str:
llm = get_llm(provider=settings.llm.provider, model=settings.llm.model_name, api_key=settings.llm.get_api_key())
profile = BrowserProfile(headless=settings.browser.headless)
agent = Agent(task=task, llm=llm, browser_profile=profile, max_steps=steps)
result = await agent.run()
return result.final_result() or "Task completed without explicit result."
```
### `/Users/igortarasenko/Projects/mcp-browser-use/src/mcp_server_browser_use/providers.py`
- **Why important**: LLM factory using browser-use native providers
- **Changes made**: New file (49 lines), replaces 327-line LangChain-based llm_provider.py
- **Code snippet**:
```python
from browser_use import ChatAnthropic, ChatGoogle, ChatOllama, ChatOpenAI
def get_llm(provider: str, model: str, api_key: str | None = None) -> "BaseChatModel":
if provider == "openai":
return ChatOpenAI(model=model, api_key=api_key)
elif provider == "anthropic":
return ChatAnthropic(model=model, api_key=api_key)
# ... etc
```
### `/Users/igortarasenko/Projects/mcp-browser-use/src/mcp_server_browser_use/config.py`
- **Why important**: Simplified configuration (61 lines vs 226 lines)
- **Changes made**: Reduced to 4 LLM providers, removed deep research settings, removed CDP settings
- **Code snippet**:
```python
ProviderType = Literal["openai", "anthropic", "google", "ollama"]
class LLMSettings(BaseSettings):
provider: ProviderType = Field(default="anthropic")
model_name: str = Field(default="claude-sonnet-4-20250514")
api_key: Optional[SecretStr] = Field(default=None)
```
### `/Users/igortarasenko/Projects/mcp-browser-use/src/mcp_server_browser_use/cli.py`
- **Why important**: CLI interface for testing
- **Changes made**: Simplified from 320 lines to 63 lines
### Deleted Files (via `trash` command)
- `_internal/agent/deep_research/deep_research_agent.py` (1015 lines)
- `_internal/agent/browser_use/browser_use_agent.py` (177 lines)
- `_internal/browser/custom_browser.py` (130 lines)
- `_internal/browser/custom_context.py` (116 lines)
- `_internal/controller/custom_controller.py` (178 lines)
- `_internal/utils/llm_provider.py` (327 lines)
- `_internal/utils/mcp_client.py` (267 lines)
## 4. Problem Solving
- **Solved**: Identified browser-use API changes (0.1.x → 0.10.x)
- **Solved**: Removed LangChain dependency entirely
- **Solved**: All linting/type checking passes
- **Ongoing**: Need validation before commit
## 5. Pending Tasks
- Validate implementation works end-to-end before committing
- Create commit with proper message
- Optionally update README for breaking changes
## 6. Current Work
Implementation is COMPLETE but NOT COMMITTED. All checks pass:
- `ruff format .` ✓
- `ruff check .` ✓
- `pyright` ✓ (0 errors)
- Import test ✓
- CLI config command ✓
- Line count: 298 lines total
Git status shows all changes staged but uncommitted.
## 7. Validation Plan (Next Steps)
Before committing, validate:
### 1. Test missing API key error handling
```bash
uv run python -c "
from mcp_server_browser_use.providers import get_llm
from mcp_server_browser_use.exceptions import LLMProviderError
try:
get_llm('openai', 'gpt-4', None)
except LLMProviderError as e:
print('✓ Error handling works:', e)
"
```
### 2. Test MCP server starts
```bash
MCP_LLM_API_KEY=test-key timeout 5 uv run mcp-server-browser-use || echo "Server started (timeout expected)"
```
### 3. Test CLI with real API key (if available)
```bash
MCP_LLM_PROVIDER=anthropic MCP_LLM_API_KEY=$ANTHROPIC_API_KEY MCP_BROWSER_HEADLESS=false uv run mcp-browser-cli run "Navigate to example.com"
```
### 4. Verify browser-use Agent API compatibility
```bash
uv run python -c "
from browser_use import Agent, BrowserProfile
from mcp_server_browser_use import get_llm, settings
# Test that we can construct the objects
profile = BrowserProfile(headless=True)
print('✓ BrowserProfile works')
# Test LLM construction (will fail without API key, but tests imports)
try:
llm = get_llm('anthropic', 'claude-sonnet-4-20250514', 'test-key')
print('✓ LLM construction works')
except Exception as e:
print('LLM construction:', e)
"
```
### 5. After validation, commit with:
```bash
git add -A
git commit -m 'feat: modernize to browser-use 0.10.1, remove LangChain
- Update browser-use 0.1.41 → 0.10.1
- Remove LangChain ecosystem (langchain-*, langgraph)
- Use native browser-use LLM providers
- Remove deep research feature
- Simplify from ~3200 lines to 298 lines
- Support 4 providers: OpenAI, Anthropic, Google, Ollama
BREAKING CHANGES:
- Deep research tool removed
- CDP connection removed
- keep_open mode removed
- LLM providers reduced to 4 core providers
- Environment variable MCP_LLM_*_API_KEY → MCP_LLM_API_KEY
'
```