Venice Browser MCP Bridge
Enables browser automation through Playwright with persistent sessions and cookie state management. Supports web navigation, page interaction, and browser control via JSON-RPC protocol over stdin/stdout.
README
Venice Browser MCP Bridge
<img width="1536" height="1024" alt="image" src="https://github.com/user-attachments/assets/81bae856-9692-4b48-98a9-c8bd213935a7" />
What this is:
A tiny, production-minded browser bridge that speaks a JSON-RPC-ish protocol over stdin/stdout.
It supports two transport framers out of the box:
line— one JSON message per line (default). Simple, friendly, great for prototyping.content-length— HTTP-likeContent-Length: Nframed messages. Good for strict MCP hosts.
It uses Playwright for real browser automation with a single persistent context (optional cookie/session state).
This repo is hardened against the classic asyncio.StreamWriter(sys.stdout, ...) footgun by using a writer implementation that never logs to stdout, avoids protocol mismatches, and cleanly flushes per message.
Quick Start
1) Create an isolated env (recommended)
python3 -m venv .venv && source .venv/bin/activate
2) Install deps
pip install -r requirements.txt
playwright install chromium
3) Run the bridge (line framing by default)
make run-line
In another terminal, run the example host:
make test-line
Expect output like:
Navigate...
{"id":"nav-1","result":{"ok":true,"final_url":"https://example.com/","title":"Example Domain"}}
To exercise Content-Length framing
make run-cl # terminal A
make test-cl # terminal B
Repo Layout
venice-browser-mcp/
├─ src/
│ ├─ venice_browser_mcp.py # entrypoint
│ ├─ venice_browser_mcp_core.py # env plumbing
│ └─ venice_browser_mcp_v23_impl.py # framing + browser logic (patched)
├─ examples/
│ ├─ line_host.py # spawns bridge (line) and sends a request
│ └─ hard_mcp_host.py # spawns bridge (content-length) and sends a request
├─ docs/
│ ├─ ARCHITECTURE.md
│ └─ TROUBLESHOOTING.md
├─ Makefile
├─ requirements.txt
├─ .gitignore
├─ LICENSE
└─ README.md
Configuration
The bridge is configured via environment variables. Reasonable defaults chosen for newbies.
| Variable | Meaning | Default |
|---|---|---|
MCP_FRAMING |
line or content-length |
line |
HEADLESS |
true or false for Playwright |
true |
MCP_STORAGE_STATE |
Path to storage_state JSON for persistent sessions |
state.json |
NAV_TIMEOUT |
Navigation timeout ms | 30000 |
BROWSER |
Browser name chromium | firefox | webkit |
chromium |
Note: All logs go to stderr. Never print non-protocol text to stdout, or you will corrupt the transport.
RPC Methods
-
browser.navigate—{ "url": "https://example.com" }
Opens/uses a single page, navigates, returns{ ok, status, final_url, title }. -
ping—{ "echo": "value" }
Returns{ "echo": "value" }for quick checks. -
mcp.shutdown— No params.
Gracefully closes browser & exits main loop.
You can add more handlers in venice_browser_mcp_v23_impl.py under dispatch().
Makefile Targets
make install— install Python deps and Playwright browsermake run-line— run bridge in line mode (foreground)make run-cl— run bridge in content-length mode (foreground)make test-line— run example host for line modemake test-cl— run example host for content-length modemake fmt— basic Python formatting (viapython -m json.toolchecks and whitespace cleanup)make clean— remove caches/artifacts
“Stuck here?” Troubleshooting Lanes
1) Crash: AssertionError or 'Protocol' object has no attribute '_drain_helper'
Cause: Incorrect asyncio.StreamWriter construction (classic pitfall).
Fix: This repo does not use that pattern; it uses a safe writer. Ensure you are running these sources and not an unpatched file. Reinstall with git clean -xfd or re-extract the zip.
2) json.decoder.JSONDecodeError: Extra data
Cause: You leaked a non-JSON line to stdout (e.g., prints, warnings from other tools).
Fix: Ensure all diagnostics go to stderr. In Python: print(\"dbg\", file=sys.stderr, flush=True).
3) Expecting value: line 1 column 1 (char 0)
Cause: Host expected a JSON line but got empty/garbage, usually because the child process printed banners to stdout before the JSON.
Fix: Same as above; keep stdout pure protocol. Also verify your framing modes match (host vs bridge).
4) playwright._impl._errors.Error: BrowserType.launch: Executable doesn't exist
Cause: You forgot to install browsers.
Fix: playwright install chromium (or firefox / webkit if you changed BROWSER).
5) Headless works, but you need cookie persistence / “logged-in” state
- Set
MCP_STORAGE_STATE=state.json(default already). - Log in once with
HEADLESS=false, then close. Subsequent sessions reuse that state.
6) Corporate proxy, weird TTY, or PTY quirks
If the host uses a PTY or non-pipe stdout, line-buffering can glitch. Prefer the included example hosts which spawn the bridge with a pipe and communicate cleanly.
Security Notes
- This project is a tooling bridge. It does not bypass web/app authentication, nor does it ship exploit logic.
- If you extend it, keep logs on stderr, and sanitize inputs when invoking shell or navigating to user-provided URLs.
- For red-team experiments: keep it abstracted and non-operational; do not automate harmful behaviors.
Sanity Checks
- Both framers verified with the included hosts.
- No stdout logging, atomic flush per message.
- Single Playwright context reused across calls, optional persistence enabled.
- Explicit timeouts on navigation.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。