# ๐Ÿ–ฅ๏ธ MCP-RealBrowser > **A persistent browser profile for your AI โ€” log in once, sessions stay forever.** > > No more blank browser windows. No more "please copy-paste this page." > Give your AI a dedicated browser identity, and it remembers everything. [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue)](https://www.typescriptlang.org/) [![MCP](https://img.shields.io/badge/MCP-1.0-purple)](https://modelcontextprotocol.io/) [![CI](https://github.com/obbbba/mcp-realbrowser/actions/workflows/ci.yml/badge.svg)](https://github.com/obbbba/mcp-realbrowser/actions/workflows/ci.yml) --- ## Why this exists Every existing MCP browser tool launches a **fresh, blank browser** that forgets everything when closed: | Tool | Problem | |------|---------| | `@playwright/mcp` | New incognito window, temporary profile โ€” lost on restart | | `browser-use` | Python-only, doesn't speak MCP | | `stagehand` | Data extraction focus, not general browsing | **MCP-RealBrowser** gives your AI a **persistent browser profile** โ€” same directory, same cookies, same sessions across restarts. Log into GitHub, Gmail, Bilibili once, and it stays logged in forever. --- ## What it does ``` You: "Check my unread emails and summarize them" AI: navigate(gmail.com) โ†’ snapshot() โ†’ extract() โ†’ reads & summarizes You: "Find flights to Tokyo next Friday under ยฅ3000" AI: navigate(ctrip.com) โ†’ fill("ๅ‡บๅ‘", "ไธŠๆตท") โ†’ fill("ๅˆฐ่พพ", "ไธœไบฌ") โ†’ click("ๆœ็ดข") โ†’ extract() โ†’ sorted results You: "Open my GitHub and tell me how many stars I have" AI: navigate(github.com/obbbba) โ†’ snapshot() โ†’ "You have 1 star" ``` --- ## Quick start ### 1. Install ```bash git clone https://github.com/obbbba/mcp-realbrowser.git cd mcp-realbrowser npm install npm run build ``` ### 2. Run diagnostics ```bash node dist/index.js --doctor ``` Checks: Node.js, dependencies, Chrome installed, Chrome running, CDP port open, debug flag enabled. ### 3. Launch your browser with debug port > The browser uses a **separate persistent profile** โ€” your daily browser isn't affected. **Windows (Edge โ€” pre-installed on Win11):** ```bat scripts\launch-edge.bat ``` **Windows (Chrome):** ```bat scripts\launch-chrome.bat ``` **Mac/Linux:** ```bash chmod +x scripts/launch-chrome.sh ./scripts/launch-chrome.sh ``` ### 4. Choose your mode #### Mode A: MCP Server (recommended โ€” Claude Code auto-control) Add to `.claude/settings.json` in your project: ```json { "mcpServers": { "realbrowser": { "command": "npx", "args": ["tsx", "/path/to/mcp-realbrowser/src/index.ts"], "env": { "CDP_PORT": "9222" } } } } ``` Restart Claude Code. Now you can just talk: ``` > Go to baidu.com and search for "MCP tutorial" > Open GitHub trending page and find the top TypeScript repo > Navigate to my Gmail and summarize unread emails ``` #### Mode B: Direct API (for scripts / custom tools) ```ts import { CDPConnection } from "mcp-realbrowser"; const browser = new CDPConnection(); await browser.connect("http://localhost:9222"); await browser.navigate("github.com"); const snapshot = await browser.snapshot(); // AI sees the page await browser.click("Sign in"); await browser.type("hello"); const screenshot = await browser.screenshot(); await browser.disconnect(); // Chrome stays open ``` ### 5. Verify it works ```bash npx tsx src/smoke-test.ts # Expected: test runs pass ``` --- ## Tools (20) | Tool | What it does | |------|-------------| | `navigate(url)` | Open any URL in the current tab | | `snapshot(query?)` | Get interactive elements โ€” filter with `query` to save tokens | | `click(target)` | Click by CSS selector, text, role, placeholder, or label (6 strategies) | | `type(text)` | Type into the focused input with human-like delay | | `press_key(key)` | Press Enter, Tab, Escape, arrows, etc. | | `screenshot(format?, quality?)` | Take a viewport screenshot (PNG/JPEG, quality 10-100 for JPEG) | | `extract(maxChars?)` | Get visible text (default 3K chars, max 30K) | | `scroll(direction, amount?)` | Scroll up/down, returns scroll position | | `fill(field, value)` | Fill an input by placeholder or label | | `select_option(target, value)` | Select an option in a `