The agent that turns websites into APIs!
feat: chrome devtools mcp support (WWWWWW!)
kalil0321e446d01d6f7f
diff --git a/src/reverse_api/auto_engineer.py b/src/reverse_api/auto_engineer.pyindex 62518bf..60d3944 100644--- a/src/reverse_api/auto_engineer.py+++ b/src/reverse_api/auto_engineer.py@@ -33,14 +33,13 @@ class ClaudeAutoEngineer(ClaudeEngineer):prompt: str,model: str,output_dir: str | None = None,+ agent_provider: str = "auto",**kwargs,):"""Initialize auto engineer with expected HAR path (created by MCP)."""- # Calculate expected HAR path - MCP will create it during executionhar_dir = get_har_dir(run_id, output_dir)har_path = har_dir / "recording.har"- # Initialize with expected HAR path (created by MCP via --run-id flag)super().__init__(run_id=run_id,har_path=har_path,@@ -50,6 +49,7 @@ class ClaudeAutoEngineer(ClaudeEngineer):**kwargs,)self.mcp_run_id = run_id+ self.agent_provider = agent_providerdef _build_auto_prompt(self) -> str:"""Build autonomous browsing + engineering prompt."""@@ -223,6 +223,194 @@ Your final response should confirm the files were created and provide a brief su- Any limitations or caveats"""+ def _build_chrome_mcp_prompt(self) -> str:+ """Build autonomous browsing + engineering prompt for Chrome DevTools MCP."""+ language_name = {+ "python": "Python",+ "javascript": "JavaScript",+ "typescript": "TypeScript",+ }.get(self.output_language, "Python")++ client_filename = self._get_client_filename()+ run_command = self._get_run_command()++ if self.output_language == "javascript":+ generation_instructions = f"""2. **Generate JavaScript API client** at `{self.scripts_dir}/{client_filename}`:+ - Use modern JavaScript (ES2022+) with ESM modules (import/export)+ - Use native `fetch` API for HTTP requests (Node.js 18+ built-in)+ - If advanced features needed (retries, interceptors), use `axios`+ - Include proper authentication handling+ - Create separate async functions for each API endpoint+ - Add JSDoc comments for type documentation+ - Include example usage in main section+ - Make it production-ready and maintainable+ - If using external dependencies, generate package.json++3. **Create documentation** at `{self.scripts_dir}/README.md`:+ - Explain what APIs were discovered+ - How authentication works+ - How to use each function+ - Requirements: Node.js 18++ - Any limitations or requirements++4. **Test your implementation**:+ - If package.json was generated, first run: npm install+ - Run with: {run_command}+ - You have up to 5 attempts to fix any issues+ - If initial implementation fails, analyze errors and iterate"""+ output_files = f"""1. `{self.scripts_dir}/{client_filename}` - Production JavaScript API client+2. `{self.scripts_dir}/README.md` - Documentation with usage examples+3. `{self.scripts_dir}/package.json` - Only if external dependencies are needed"""++ elif self.output_language == "typescript":+ generation_instructions = f"""2. **Generate TypeScript API client** at `{self.scripts_dir}/{client_filename}`:+ - Use TypeScript with strict typing enabled+ - Use ESM modules (import/export syntax)+ - Use native `fetch` API for HTTP requests (Node.js 18+ built-in)+ - If advanced features needed, use `axios`+ - Define TypeScript interfaces for all request/response types+ - Include proper authentication handling+ - Create separate async functions for each API endpoint+ - Export a class-based API client with proper encapsulation+ - Include example usage in main section+ - Make it production-ready and maintainable+ - Generate package.json with tsx, typescript, @types/node++3. **Create documentation** at `{self.scripts_dir}/README.md`:+ - Explain what APIs were discovered+ - How authentication works+ - How to use each function+ - Requirements: Node.js 18++ - Any limitations or requirements++4. **Test your implementation**:+ - Run: npm install && {run_command}+ - You have up to 5 attempts to fix any issues+ - If initial implementation fails, analyze errors and iterate"""+ output_files = f"""1. `{self.scripts_dir}/{client_filename}` - Production TypeScript API client+2. `{self.scripts_dir}/README.md` - Documentation with usage examples+3. `{self.scripts_dir}/package.json` - Dependencies and run scripts"""++ else: # python+ generation_instructions = f"""2. **Generate Python API client** at `{self.scripts_dir}/{client_filename}`:+ - Use `requests` library as default (or Playwright if needed for bot detection)+ - Include proper authentication handling+ - Create separate functions for each API endpoint+ - Add type hints, docstrings, error handling+ - Include example usage in main section+ - Make it production-ready and maintainable++3. **Create documentation** at `{self.scripts_dir}/README.md`:+ - Explain what APIs were discovered+ - How authentication works+ - How to use each function+ - Example usage+ - Any limitations or requirements++4. **Test your implementation**:+ - After generating the code, test it to ensure it works+ - Run with: {run_command}+ - You have up to 5 attempts to fix any issues+ - If initial implementation fails, analyze errors and iterate"""+ output_files = f"""1. `{self.scripts_dir}/{client_filename}` - Production Python API client+2. `{self.scripts_dir}/README.md` - Documentation with usage examples"""++ return f"""You are an autonomous AI agent with browser control via Chrome DevTools MCP tools.+You are connected to the user's REAL Chrome browser with their existing sessions, cookies, and authentication.+Your mission is to browse, monitor network traffic, and generate production-ready {language_name} API code.++<mission>+{self.prompt}+</mission>++<output_directory>+{self.scripts_dir}+</output_directory>++## WORKFLOW++Follow this workflow step-by-step:++### Phase 1: BROWSE+Use Chrome DevTools MCP tools to accomplish the mission goal. Available tools:+- `navigate_page` - Navigate to a URL (type: "url", url: "..."), go back/forward/reload+- `click` - Click an element by its uid+- `fill` - Type text into an input, textarea, or select (uid, value)+- `fill_form` - Fill multiple form elements at once+- `hover` - Hover over an element+- `press_key` - Press a key or combination (e.g. "Enter", "Control+A")+- `new_page` - Open a new page/tab+- `list_pages` - List open browser pages+- `select_page` - Switch to a specific page/tab+- `wait_for` - Wait for text to appear on the page+- `take_snapshot` - Get accessibility tree (useful for understanding page structure and element uids)+- `take_screenshot` - Take a screenshot for visual context+- `evaluate_script` - Execute JavaScript in the current page+- `list_console_messages` - Check console for errors/logs++**IMPORTANT: You are controlling the user's actual Chrome browser. Their existing login sessions and cookies are available - you do NOT need to log in to sites where they are already authenticated.**++**Screenshot Guidelines:**+- Screenshots have a 1MB size limit - avoid full-page screenshots when possible+- Use `take_snapshot()` when you need page structure information without visual details+- The snapshot gives you element `uid` values needed for `click`, `fill`, etc.++### Phase 2: MONITOR+While browsing, periodically call `list_network_requests()` to monitor API traffic in real-time:+- Filter by type (e.g. "xhr", "fetch") to focus on API calls+- Analyze request URLs, methods, and response status codes+- Identify authentication patterns (cookies, tokens, headers)+- Note API endpoints and parameters++For detailed inspection, use `get_network_request(reqid)` to get:+- Full request headers and body+- Full response headers and body+- Timing information++### Phase 3: CAPTURE+When you have sufficient data or have accomplished the mission goal:+1. Call `list_network_requests()` one final time to get all requests+2. For each important API request, call `get_network_request(reqid)` to capture full details+3. Pay special attention to: authentication headers, API endpoints, request/response bodies++**There is no HAR file.** You must capture all network data you need using these tools before proceeding.++### Phase 4: REVERSE ENGINEER+Based on the network traffic you observed, generate production-ready {language_name} code:++1. **Analyze the captured network data**+ - Review all API calls you collected via list_network_requests and get_network_request+ - Extract authentication patterns, endpoints, parameters, response structures++{generation_instructions}++## IMPORTANT NOTES++- Think step-by-step and narrate your actions as you browse+- Call `list_network_requests()` frequently to monitor traffic+- Use `get_network_request(reqid)` to capture full request/response details for important API calls+- Don't rush - ensure you capture all necessary API calls before generating code+- After generating code, always test it to verify it works+- **Screenshot size limit**: Screenshots must be under 1MB. Prefer `take_snapshot()` over screenshots when possible+- You have access to the user's real browser sessions - leverage existing auth when possible++## OUTPUT FILES REQUIRED++{output_files}++Your final response should confirm the files were created and provide a brief summary of:+- What APIs were discovered+- The authentication method used+- Whether the implementation works+- Any limitations or caveats+"""++ def _get_active_prompt(self) -> str:+ """Return the appropriate prompt based on agent_provider."""+ if self.agent_provider == "chrome-mcp":+ return self._build_chrome_mcp_prompt()+ return self._build_auto_prompt()+async def _handle_tool_permission(self, tool_name: str, input_data: dict[str, Any], context: ToolPermissionContext) -> PermissionResultAllow:"""Handle tool permission requests, with interactive UI for AskUserQuestion."""if tool_name == "AskUserQuestion":@@ -234,16 +422,15 @@ Your final response should confirm the files were created and provide a brief su# Auto-approve all other toolsreturn PermissionResultAllow(updated_input=input_data)- async def analyze_and_generate(self) -> dict[str, Any] | None:- """Run auto mode with MCP browser integration.-- Reuses _process_streaming_response and follow-up loop from ClaudeEngineer.- """- self.ui.header(self.run_id, self.prompt, self.model, mode="agent")- self.ui.start_analysis()- self.message_store.save_prompt(self._build_auto_prompt())-- mcp_config = {+ def _get_mcp_config(self) -> tuple[str, dict]:+ """Return (server_name, mcp_config) based on agent_provider."""+ if self.agent_provider == "chrome-mcp":+ return "chrome-devtools", {+ "type": "stdio",+ "command": "npx",+ "args": ["chrome-devtools-mcp@latest", "--autoConnect", "--no-usage-statistics"],+ }+ return "playwright", {"type": "stdio","command": "npx","args": [@@ -254,8 +441,21 @@ Your final response should confirm the files were created and provide a brief su],}+ async def analyze_and_generate(self) -> dict[str, Any] | None:+ """Run auto mode with MCP browser integration.++ Reuses _process_streaming_response and follow-up loop from ClaudeEngineer.+ """+ self.ui.header(self.run_id, self.prompt, self.model, mode="agent")+ self.ui.start_analysis()++ active_prompt = self._get_active_prompt()+ self.message_store.save_prompt(active_prompt)++ mcp_name, mcp_config = self._get_mcp_config()+options = ClaudeAgentOptions(- mcp_servers={"playwright": mcp_config},+ mcp_servers={mcp_name: mcp_config},permission_mode="bypassPermissions",can_use_tool=self._handle_tool_permission,cwd=str(self.scripts_dir.parent.parent), # Project root@@ -268,7 +468,7 @@ Your final response should confirm the files were created and provide a brief sutry:async with ClaudeSDKClient(options=options) as client:- await client.query(self._build_auto_prompt())+ await client.query(active_prompt)# Process initial responselast_result = await self._process_streaming_response(client)@@ -305,7 +505,11 @@ Your final response should confirm the files were created and provide a brief su"[dim]Consider using browser_snapshot() for accessibility tree information when screenshots aren't needed.[/dim]")elif "MCP server" in error_msg or "npx" in error_msg:- self.ui.console.print("\n[dim]Make sure rae-playwright-mcp is installed: npm install -g rae-playwright-mcp[/dim]")+ if self.agent_provider == "chrome-mcp":+ self.ui.console.print("\n[dim]Make sure chrome-devtools-mcp is available: npx chrome-devtools-mcp@latest[/dim]")+ self.ui.console.print("[dim]Chrome 146+ required with auto-connect enabled at chrome://inspect/#remote-debugging[/dim]")+ else:+ self.ui.console.print("\n[dim]Make sure rae-playwright-mcp is installed: npm install -g rae-playwright-mcp[/dim]")else:self.ui.console.print("\n[dim]Make sure Claude Code CLI is installed: npm install -g @anthropic-ai/claude-code[/dim]")return None@@ -314,9 +518,8 @@ Your final response should confirm the files were created and provide a brief suclass OpenCodeAutoEngineer(OpenCodeEngineer):"""Auto mode using OpenCode SDK: Register MCP server dynamically."""- def __init__(self, run_id: str, prompt: str, output_dir: str | None = None, **kwargs):+ def __init__(self, run_id: str, prompt: str, output_dir: str | None = None, agent_provider: str = "auto", **kwargs):"""Initialize auto engineer with expected HAR path (created by MCP)."""- # Calculate expected HAR path - MCP will create it during executionhar_dir = get_har_dir(run_id, output_dir)har_path = har_dir / "recording.har"@@ -328,18 +531,55 @@ class OpenCodeAutoEngineer(OpenCodeEngineer):**kwargs,)self.mcp_run_id = run_id- self.mcp_name = None # Will be set to unique name per session+ self.agent_provider = agent_provider+ self.mcp_name = Nonedef _build_auto_prompt(self) -> str:- """Build autonomous browsing + engineering prompt."""- # Reuse the same prompt from ClaudeAutoEngineerreturn ClaudeAutoEngineer._build_auto_prompt(self)+ def _get_active_prompt(self) -> str:+ if self.agent_provider == "chrome-mcp":+ return ClaudeAutoEngineer._build_chrome_mcp_prompt(self)+ return self._build_auto_prompt()++ def _get_opencode_mcp_config(self) -> dict:+ """Return OpenCode MCP registration payload based on agent_provider."""+ if self.agent_provider == "chrome-mcp":+ self.mcp_name = f"chrome-devtools-{self._session_id}"+ return {+ "name": self.mcp_name,+ "config": {+ "type": "local",+ "command": ["npx", "-y", "chrome-devtools-mcp@latest", "--autoConnect", "--no-usage-statistics"],+ "enabled": True,+ "timeout": 30000,+ },+ }+ self.mcp_name = f"playwright-{self._session_id}"+ return {+ "name": self.mcp_name,+ "config": {+ "type": "local",+ "command": [+ "npx",+ "-y",+ "rae-playwright-mcp@latest",+ "run-mcp-server",+ "--run-id",+ self.mcp_run_id,+ ],+ "enabled": True,+ "timeout": 30000,+ },+ }+async def analyze_and_generate(self) -> dict[str, Any] | None:"""Run auto mode with OpenCode MCP integration."""self.opencode_ui.header(self.run_id, self.prompt, self.opencode_model, mode="agent")self.opencode_ui.start_analysis()- self.message_store.save_prompt(self._build_auto_prompt())++ active_prompt = self._get_active_prompt()+ self.message_store.save_prompt(active_prompt)try:auth = self._get_auth()@@ -371,25 +611,7 @@ class OpenCodeAutoEngineer(OpenCodeEngineer):self._session_id = session_data["id"]self.opencode_ui.session_created(self._session_id)- # Register MCP server with unique name- # Format per OpenCode docs: { name, config: { type: "local", command: [...] } }- self.mcp_name = f"playwright-{self._session_id}"- mcp_config = {- "name": self.mcp_name,- "config": {- "type": "local",- "command": [- "npx",- "-y",- "rae-playwright-mcp@latest",- "run-mcp-server",- "--run-id",- self.mcp_run_id,- ],- "enabled": True,- "timeout": 30000, # 30 seconds for MCP to start- },- }+ mcp_config = self._get_opencode_mcp_config()try:debug_log(f"Registering MCP server: {self.mcp_name}")@@ -406,14 +628,13 @@ class OpenCodeAutoEngineer(OpenCodeEngineer):# Give event stream a moment to connectawait asyncio.sleep(0.1)- # Send auto promptmodel_id = self.MODEL_MAP.get(self.opencode_model, self.opencode_model)prompt_body = {"model": {"providerID": self.opencode_provider,"modelID": model_id,},- "parts": [{"type": "text", "text": self._build_auto_prompt()}],+ "parts": [{"type": "text", "text": active_prompt}],}prompt_r = await client.post(f"/session/{self._session_id}/message", json=prompt_body)@@ -538,6 +759,7 @@ class CopilotAutoEngineer:prompt: str,copilot_model: str | None = None,output_dir: str | None = None,+ agent_provider: str = "auto",**kwargs: Any,):from .copilot_engineer import CopilotEngineer@@ -554,6 +776,7 @@ class CopilotAutoEngineer:**kwargs,)self.mcp_run_id = run_id+ self.agent_provider = agent_providerdef start_sync(self) -> None:self._engineer.start_sync()@@ -575,7 +798,10 @@ class CopilotAutoEngineer:eng.ui.header(eng.run_id, eng.prompt, eng.copilot_model, eng.sdk, mode="agent")eng.ui.start_analysis()- auto_prompt = ClaudeAutoEngineer._build_auto_prompt(eng)+ if self.agent_provider == "chrome-mcp":+ auto_prompt = ClaudeAutoEngineer._build_chrome_mcp_prompt(eng)+ else:+ auto_prompt = ClaudeAutoEngineer._build_auto_prompt(eng)eng.message_store.save_prompt(auto_prompt)done_event = asyncio.Event()@@ -612,19 +838,30 @@ class CopilotAutoEngineer:)await client.start()- mcp_config = {- "type": "local",- "command": "npx",- "args": [- "-y",- "rae-playwright-mcp@latest",- "run-mcp-server",- "--run-id",- self.mcp_run_id,- ],- "tools": ["*"],- "timeout": 30000,- }+ if self.agent_provider == "chrome-mcp":+ mcp_server_name = "chrome-devtools"+ mcp_config = {+ "type": "local",+ "command": "npx",+ "args": ["-y", "chrome-devtools-mcp@latest", "--autoConnect", "--no-usage-statistics"],+ "tools": ["*"],+ "timeout": 30000,+ }+ else:+ mcp_server_name = "playwright"+ mcp_config = {+ "type": "local",+ "command": "npx",+ "args": [+ "-y",+ "rae-playwright-mcp@latest",+ "run-mcp-server",+ "--run-id",+ self.mcp_run_id,+ ],+ "tools": ["*"],+ "timeout": 30000,+ }async def on_pre_tool_use(input: dict, _invocation: dict) -> dict:tool_name = input.get("toolName", "unknown")@@ -646,7 +883,7 @@ class CopilotAutoEngineer:"model": eng.copilot_model,"streaming": True,"infinite_sessions": {"enabled": True},- "mcp_servers": {"playwright": mcp_config},+ "mcp_servers": {mcp_server_name: mcp_config},"on_permission_request": PermissionHandler.approve_all,"hooks": {"on_pre_tool_use": on_pre_tool_use,diff --git a/src/reverse_api/cli.py b/src/reverse_api/cli.pyindex 3db0006..0d6754c 100644--- a/src/reverse_api/cli.py+++ b/src/reverse_api/cli.py@@ -694,9 +694,10 @@ def handle_settings(mode_color=THEME_PRIMARY):elif action == "agent_provider":provider_choices = [+ Choice(title="auto (Playwright MCP)", value="auto"),+ Choice(title="chrome-mcp (Chrome DevTools MCP)", value="chrome-mcp"),Choice(title="browser-use", value="browser-use"),Choice(title="stagehand", value="stagehand"),- Choice(title="auto", value="auto"),Choice(title="back", value="back"),]provider = questionary.select(@@ -713,7 +714,20 @@ def handle_settings(mode_color=THEME_PRIMARY):).ask()if provider and provider != "back":config_manager.set("agent_provider", provider)- console.print(f" [dim]updated[/dim] agent provider: {provider}\n")+ console.print(f" [dim]updated[/dim] agent provider: {provider}")+ if provider == "chrome-mcp":+ console.print()+ console.print(" [bold yellow]Chrome DevTools MCP Setup[/bold yellow]")+ console.print()+ console.print(" [white]1.[/white] Open Chrome (version 146 or newer)")+ console.print(" [white]2.[/white] Navigate to [cyan]chrome://inspect/#remote-debugging[/cyan]")+ console.print(' [white]3.[/white] Click [bold]"Enable auto-connect"[/bold]')+ console.print(" [white]4.[/white] Make sure Node.js v20.19+ is installed")+ console.print()+ console.print(" [dim]The agent will connect to your real Chrome browser via auto-connect.[/dim]")+ console.print(" [dim]Your existing sessions, cookies, and auth will be available.[/dim]")+ console.print(" [dim]Avoid browsing sensitive sites while the agent is active.[/dim]")+ console.print()elif action == "opencode_provider":current = config_manager.get("opencode_provider", "anthropic")@@ -1360,13 +1374,13 @@ def run_agent_capture(prompt=None, url=None, reverse_engineer=False, model=None,stagehand_model = config_manager.get("stagehand_model", "openai/computer-use-preview-2025-03-11")agent_provider = config_manager.get("agent_provider", "browser-use")- # Route to auto mode if configured- if agent_provider == "auto":+ if agent_provider in ("auto", "chrome-mcp"):return run_auto_capture(prompt=prompt,url=url,model=model,output_dir=output_dir,+ agent_provider=agent_provider,)# Record initial session@@ -1511,7 +1525,7 @@ def run_collector(prompt=None, model=None, output_dir=None):traceback.print_exc()-def run_auto_capture(prompt=None, url=None, model=None, output_dir=None):+def run_auto_capture(prompt=None, url=None, model=None, output_dir=None, agent_provider="auto"):"""Auto mode: LLM-driven browser automation + real-time reverse engineering."""output_dir = output_dir or config_manager.get("output_dir")@@ -1519,7 +1533,7 @@ def run_auto_capture(prompt=None, url=None, model=None, output_dir=None):options = prompt_interactive_options(prompt=prompt,url=url,- reverse_engineer=False, # Not applicable for auto mode+ reverse_engineer=False,model=model,)if "command" in options:@@ -1528,24 +1542,38 @@ def run_auto_capture(prompt=None, url=None, model=None, output_dir=None):url = options.get("url")model = options["model"]+ if agent_provider == "chrome-mcp":+ console.print()+ console.print(" [dim]chrome devtools mcp (auto-connect)[/dim]")+ console.print(" [dim]controlling your real chrome browser[/dim]")+ console.print(" [dim]existing sessions, cookies, and auth available[/dim]")+ console.print()+ console.print(" [dim]auto-connect setup:[/dim]")+ console.print(" [dim] 1. chrome 146+ required[/dim]")+ console.print(" [dim] 2. go to chrome://inspect/#remote-debugging[/dim]")+ console.print(' [dim] 3. click "Enable auto-connect"[/dim]')+ console.print(" [dim] 4. node.js v20.19+[/dim]")+ console.print()+ console.print(" [dim]warning: the agent will execute actions on your browser[/dim]")+ console.print(" [dim]avoid browsing sensitive sites during the session[/dim]")+ console.print()+run_id = generate_run_id()timestamp = get_timestamp()- # Record initial session with mode="auto"+ mode_label = "chrome-mcp" if agent_provider == "chrome-mcp" else "auto"session_manager.add_run(run_id=run_id,prompt=prompt,timestamp=timestamp,url=url,model=model,- mode="auto", # Track auto mode in history+ mode=mode_label,paths={"har_dir": str(get_har_dir(run_id, output_dir))},)- # Get SDK configurationsdk = config_manager.get("sdk", "claude")- # Run auto engineer based on SDKtry:output_language = config_manager.get("output_language", "python")if sdk == "opencode":@@ -1555,6 +1583,7 @@ def run_auto_capture(prompt=None, url=None, model=None, output_dir=None):run_id=run_id,prompt=prompt,output_dir=output_dir,+ agent_provider=agent_provider,opencode_provider=config_manager.get("opencode_provider", "anthropic"),opencode_model=config_manager.get("opencode_model", "claude-opus-4-6"),enable_sync=config_manager.get("real_time_sync", False),@@ -1569,6 +1598,7 @@ def run_auto_capture(prompt=None, url=None, model=None, output_dir=None):prompt=prompt,copilot_model=config_manager.get("copilot_model", "gpt-5"),output_dir=output_dir,+ agent_provider=agent_provider,enable_sync=config_manager.get("real_time_sync", False),sdk=sdk,output_language=output_language,@@ -1581,6 +1611,7 @@ def run_auto_capture(prompt=None, url=None, model=None, output_dir=None):prompt=prompt,model=model or config_manager.get("claude_code_model", "claude-sonnet-4-6"),output_dir=output_dir,+ agent_provider=agent_provider,enable_sync=config_manager.get("real_time_sync", False),sdk=sdk,output_language=output_language,diff --git a/src/reverse_api/config.py b/src/reverse_api/config.pyindex 3d6cbe0..de77b28 100644--- a/src/reverse_api/config.py+++ b/src/reverse_api/config.py@@ -5,7 +5,7 @@ from pathlib import Pathfrom typing import AnyDEFAULT_CONFIG = {- "agent_provider": "auto", # "auto" (default, MCP-based browser + engineering), "browser-use", or "stagehand"+ "agent_provider": "auto", # "auto" (Playwright MCP), "chrome-mcp" (Chrome DevTools MCP), "browser-use", or "stagehand""browser_use_model": "bu-llm", # "bu-llm" or "{provider}/{model_name}" (e.g. "openai/gpt-5-mini")"claude_code_model": "claude-sonnet-4-6","collector_model": "claude-sonnet-4-6", # Model for collector modediff --git a/tests/test_auto_engineer.py b/tests/test_auto_engineer.pyindex 16bf4fd..69a5d93 100644--- a/tests/test_auto_engineer.py+++ b/tests/test_auto_engineer.py@@ -28,6 +28,38 @@ class TestClaudeAutoEngineerInit:assert eng.har_path == tmp_path / "har" / "recording.har"+class TestClaudeAutoEngineerInitChromeMcp:+ """Test ClaudeAutoEngineer initialization with chrome-mcp provider."""++ def test_init_chrome_mcp(self, tmp_path):+ """Initializes with agent_provider='chrome-mcp'."""+ with patch("reverse_api.auto_engineer.get_har_dir", return_value=tmp_path / "har"):+ with patch("reverse_api.base_engineer.get_scripts_dir", return_value=tmp_path / "scripts"):+ with patch("reverse_api.base_engineer.MessageStore"):+ eng = ClaudeAutoEngineer(+ run_id="test123",+ prompt="browse and capture",+ model="claude-sonnet-4-6",+ output_dir=str(tmp_path),+ agent_provider="chrome-mcp",+ )+ assert eng.agent_provider == "chrome-mcp"+ assert eng.mcp_run_id == "test123"++ def test_init_default_provider(self, tmp_path):+ """Default agent_provider is 'auto'."""+ with patch("reverse_api.auto_engineer.get_har_dir", return_value=tmp_path / "har"):+ with patch("reverse_api.base_engineer.get_scripts_dir", return_value=tmp_path / "scripts"):+ with patch("reverse_api.base_engineer.MessageStore"):+ eng = ClaudeAutoEngineer(+ run_id="test123",+ prompt="browse and capture",+ model="claude-sonnet-4-6",+ output_dir=str(tmp_path),+ )+ assert eng.agent_provider == "auto"++class TestClaudeAutoEngineerPrompt:"""Test auto prompt building."""@@ -92,6 +124,164 @@ class TestClaudeAutoEngineerPrompt:assert "1MB" in prompt+class TestChromeMcpPrompt:+ """Test Chrome DevTools MCP prompt building."""++ def _make_engineer(self, tmp_path, **kwargs):+ defaults = {+ "run_id": "test123",+ "prompt": "browse and capture",+ "model": "claude-sonnet-4-6",+ "output_dir": str(tmp_path),+ "agent_provider": "chrome-mcp",+ }+ defaults.update(kwargs)+ with patch("reverse_api.auto_engineer.get_har_dir", return_value=tmp_path / "har"):+ with patch("reverse_api.base_engineer.get_scripts_dir", return_value=tmp_path / "scripts"):+ with patch("reverse_api.base_engineer.MessageStore"):+ return ClaudeAutoEngineer(**defaults)++ def test_chrome_mcp_prompt_uses_chrome_tools(self, tmp_path):+ """Chrome MCP prompt uses Chrome DevTools tool names."""+ eng = self._make_engineer(tmp_path)+ prompt = eng._build_chrome_mcp_prompt()+ assert "navigate_page" in prompt+ assert "click" in prompt+ assert "fill" in prompt+ assert "take_snapshot" in prompt+ assert "list_network_requests" in prompt+ assert "get_network_request" in prompt++ def test_chrome_mcp_prompt_no_har_file(self, tmp_path):+ """Chrome MCP prompt does not reference HAR file saving."""+ eng = self._make_engineer(tmp_path)+ prompt = eng._build_chrome_mcp_prompt()+ assert "There is no HAR file" in prompt+ assert "browser_close" not in prompt++ def test_chrome_mcp_prompt_mentions_real_browser(self, tmp_path):+ """Chrome MCP prompt mentions real Chrome browser."""+ eng = self._make_engineer(tmp_path)+ prompt = eng._build_chrome_mcp_prompt()+ assert "REAL Chrome browser" in prompt+ assert "existing sessions" in prompt++ def test_chrome_mcp_prompt_python(self, tmp_path):+ """Chrome MCP Python prompt includes correct language."""+ eng = self._make_engineer(tmp_path)+ prompt = eng._build_chrome_mcp_prompt()+ assert "Python" in prompt+ assert "requests" in prompt++ def test_chrome_mcp_prompt_javascript(self, tmp_path):+ """Chrome MCP JavaScript prompt includes JS instructions."""+ eng = self._make_engineer(tmp_path, output_language="javascript")+ prompt = eng._build_chrome_mcp_prompt()+ assert "JavaScript" in prompt+ assert "fetch" in prompt++ def test_chrome_mcp_prompt_typescript(self, tmp_path):+ """Chrome MCP TypeScript prompt includes TS instructions."""+ eng = self._make_engineer(tmp_path, output_language="typescript")+ prompt = eng._build_chrome_mcp_prompt()+ assert "TypeScript" in prompt+ assert "interfaces" in prompt++ def test_get_active_prompt_chrome_mcp(self, tmp_path):+ """_get_active_prompt returns chrome prompt for chrome-mcp provider."""+ eng = self._make_engineer(tmp_path)+ prompt = eng._get_active_prompt()+ assert "Chrome DevTools MCP" in prompt+ assert "navigate_page" in prompt++ def test_get_active_prompt_auto(self, tmp_path):+ """_get_active_prompt returns auto prompt for auto provider."""+ eng = self._make_engineer(tmp_path, agent_provider="auto")+ prompt = eng._get_active_prompt()+ assert "browser_navigate" in prompt+++class TestChromeMcpConfig:+ """Test MCP configuration selection."""++ def _make_engineer(self, tmp_path, **kwargs):+ defaults = {+ "run_id": "test123",+ "prompt": "browse and capture",+ "model": "claude-sonnet-4-6",+ "output_dir": str(tmp_path),+ }+ defaults.update(kwargs)+ with patch("reverse_api.auto_engineer.get_har_dir", return_value=tmp_path / "har"):+ with patch("reverse_api.base_engineer.get_scripts_dir", return_value=tmp_path / "scripts"):+ with patch("reverse_api.base_engineer.MessageStore"):+ return ClaudeAutoEngineer(**defaults)++ def test_chrome_mcp_config(self, tmp_path):+ """Chrome MCP returns chrome-devtools server config."""+ eng = self._make_engineer(tmp_path, agent_provider="chrome-mcp")+ name, config = eng._get_mcp_config()+ assert name == "chrome-devtools"+ assert "chrome-devtools-mcp@latest" in config["args"]+ assert "--autoConnect" in config["args"]++ def test_auto_mcp_config(self, tmp_path):+ """Auto provider returns playwright server config."""+ eng = self._make_engineer(tmp_path, agent_provider="auto")+ name, config = eng._get_mcp_config()+ assert name == "playwright"+ assert "rae-playwright-mcp@latest" in config["args"]+ assert "--run-id" in config["args"]+++class TestOpenCodeChromeMcpConfig:+ """Test OpenCodeAutoEngineer Chrome MCP config."""++ def _make_engineer(self, tmp_path, **kwargs):+ defaults = {+ "run_id": "test123",+ "prompt": "browse and capture",+ "output_dir": str(tmp_path),+ "opencode_provider": "anthropic",+ "opencode_model": "claude-opus-4-6",+ }+ defaults.update(kwargs)+ with patch("reverse_api.auto_engineer.get_har_dir", return_value=tmp_path / "har"):+ with patch("reverse_api.base_engineer.get_scripts_dir", return_value=tmp_path / "scripts"):+ with patch("reverse_api.base_engineer.MessageStore"):+ with patch("reverse_api.opencode_engineer.OpenCodeUI"):+ eng = OpenCodeAutoEngineer(**defaults)+ eng._session_id = "sess_test"+ return eng++ def test_opencode_chrome_mcp_config(self, tmp_path):+ """OpenCode chrome-mcp config uses chrome-devtools-mcp."""+ eng = self._make_engineer(tmp_path, agent_provider="chrome-mcp")+ config = eng._get_opencode_mcp_config()+ assert "chrome-devtools" in eng.mcp_name+ assert "chrome-devtools-mcp@latest" in config["config"]["command"]++ def test_opencode_auto_mcp_config(self, tmp_path):+ """OpenCode auto config uses rae-playwright-mcp."""+ eng = self._make_engineer(tmp_path, agent_provider="auto")+ config = eng._get_opencode_mcp_config()+ assert "playwright" in eng.mcp_name+ assert "rae-playwright-mcp@latest" in config["config"]["command"]++ def test_opencode_chrome_mcp_prompt(self, tmp_path):+ """OpenCode chrome-mcp uses Chrome DevTools prompt."""+ eng = self._make_engineer(tmp_path, agent_provider="chrome-mcp")+ prompt = eng._get_active_prompt()+ assert "Chrome DevTools MCP" in prompt+ assert "navigate_page" in prompt++ def test_opencode_auto_prompt(self, tmp_path):+ """OpenCode auto uses Playwright prompt."""+ eng = self._make_engineer(tmp_path, agent_provider="auto")+ prompt = eng._get_active_prompt()+ assert "browser_navigate" in prompt++class TestClaudeAutoEngineerAnalyze:"""Test ClaudeAutoEngineer analyze_and_generate."""diff --git a/uv.lock b/uv.lockindex 777463c..7e5f382 100644--- a/uv.lock+++ b/uv.lock@@ -2082,7 +2082,7 @@ wheels = [[[package]]name = "reverse-api-engineer"-version = "0.4.5"+version = "0.5.0"source = { editable = "." }dependencies = [{ name = "claude-agent-sdk" },