Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ src/
main.rs 入口(clap CLI,--mode --profile --pipe --upload-base --max-text-bytes --max-image-bytes)
lib.rs 模块声明
mcp/
mod.rs Server 结构体, run_stdio, JSON-RPC 分发
types.rs ToolHandler, Tool, Content, arg extractors, 响应构建
mod.rs Server 结构体, run_stdio, JSON-RPC 分发(双纪元 era 检测入口)
lifecycle.rs MCP 版本协商 + 双纪元生命周期(legacy initialize / 2026-07-28 stateless、server/discover、resultType/缓存提示、-32022)
types.rs ToolHandler, Tool, ToolHints(annotations), Content, arg extractors, 响应构建
schema.rs registered_tools(), 工具注册
handlers.rs handle_tool_call + 52 个 handle_* 方法
profiles.rs ToolProfile (basic/network/full)
Expand Down
29 changes: 28 additions & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ reconnect and protocol logic can be tested with `tokio::io::duplex()` mocks.
| `protocol.rs` | Length-prefixed frame encode/decode, `Request`/`Response`, session-param merge |
| `discovery.rs` | Enumerate `codex-browser-use-*` pipes (PowerShell) |
| `browser.rs` | The 52 tool implementations over `Client` (navigate, dom, screenshot, network_monitor, …) |
| `mcp/` | MCP server: JSON-RPC dispatch, 52 tool handlers, schema, profiles, resources/prompts |
| `mcp/` | MCP server: JSON-RPC dispatch, 52 tool handlers, schema, profiles, resources/prompts, dual-era lifecycle |
| `security.rs` | URL scheme + file-path validation (path-traversal defense) |
| `config.rs` | Optional TOML config (profile, upload_base) |
| `doctor.rs` | Pipe connectivity diagnostics (`--mode doctor`) |
Expand Down Expand Up @@ -92,6 +92,33 @@ bridge does not fall back to a working-directory config.
Subscribe / list-changes is intentionally omitted: these are on-demand
snapshots, not a live feed.

### Dual-era MCP lifecycle (`mcp/lifecycle.rs`)
The 2026-07-28 revision removed the `initialize` handshake and protocol
sessions; every request is stateless and carries its protocol version in
`_meta`. The bridge serves **both eras from one binary**:

- **Era detection is per request**: the presence of
`_meta["io.modelcontextprotocol/protocolVersion"]` selects modern handling;
anything else follows the legacy lifecycle. Legacy `_meta` (e.g.
`progressToken`) without the version key stays legacy.
- **Legacy byte-compatibility is a hard requirement**: legacy envelopes pass
through untouched; modern framing (`resultType`, `_meta` serverInfo,
`ttlMs`/`cacheScope`) is applied only to requests that opted in. Tests pin
this (`legacy_tools_list_stays_byte_compatible`).
- **Version negotiation**: `initialize` echoes a supported legacy revision or
offers the newest one; a modern request asking for an unsupported revision
gets `UnsupportedProtocolVersionError` (-32022) with the supported list.
A modern version requested through `initialize` negotiates down to legacy
semantics.
- **`server/discover`** is always answered, even without version metadata —
that is the stdio compatibility probe.
- **`ping` is legacy-only**: the 2026-07-28 revision removed it, so modern
requests get `-32601`.
- **Lenient `clientCapabilities`**: the schema requires the field on modern
requests, but the bridge needs no client capabilities (no sampling /
elicitation / roots), so a missing value is treated as empty instead of
returning `MissingRequiredClientCapabilityError` (-32021).

## Data flow — a tool call

1. MCP client sends `tools/call` (e.g. `codex_navigate`) over stdio
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [1.11.0] - 2026-08-19

### Added

- **MCP protocol revision `2026-07-28` support (dual-era server).** The bridge now serves both protocol eras from one binary:
- Legacy era (`2024-11-05` … `2025-11-25`): the classic stdio lifecycle. `initialize` now negotiates the protocol version — supported revisions are echoed back, unknown requests get the newest legacy revision offered. The legacy wire format is byte-identical to v1.10.x, so existing clients see no change.
- Modern era (`2026-07-28`, SEP-2567/SEP-2575): stateless requests. Requests carrying `params._meta["io.modelcontextprotocol/protocolVersion"]` are answered without an `initialize` handshake. Results carry the required `resultType` field, server identity in `_meta["io.modelcontextprotocol/serverInfo"]`, and `ttlMs`/`cacheScope` cache hints on cacheable endpoints (`tools/list`, `resources/list`, `resources/read`, `prompts/list`, SEP-2549). Unsupported versions return `UnsupportedProtocolVersionError` (-32022) with the supported list.
- `server/discover` (required for servers under the new revision) advertises supported versions, capabilities, and instructions; it is also answered without version metadata so modern clients can probe compatibility on stdio.
- `ping` is answered for legacy clients only; the 2026-07-28 revision removed it.
- **MCP tool annotations** (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`) on all 52 tools, introduced by revision `2025-03-26`. Clients use the hints for approval UX and retry decisions; `openWorldHint` is always true because every tool reaches a live browser.
- `initialize` results now include natural-language `instructions` describing effective bridge usage.

### Changed

- New `src/mcp/lifecycle.rs` module owns version negotiation, era detection, modern result framing, and spec error envelopes.
- Verified against the official `2026-07-28` schema (`DiscoverResult`, `CacheableResult`, `ResultType`, error-code allocation `-32020`…`-32099`).
- Verified against Codex v0.148.x: extension capabilities (`viewport`, `pageAssets`, `browserTabMentions` protocol v1) remain fully covered by the existing tool surface.

## [1.10.1] - 2026-07-14

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "codex-browser-bridge"
version = "1.10.1"
version = "1.11.0"
edition = "2021"
license = "MIT"
description = "MCP server that exposes Codex Desktop's Chrome browser bridge."
Expand Down
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<p align="center">
<h1 align="center">codex-browser-bridge</h1>
<p align="center">
Let Claude Code and other MCP agents control your existing Chrome browser through Codex Desktop's browser bridge.
Let Claude Code and other MCP agents control your existing Chrome or Edge browser through the ChatGPT desktop app's browser bridge (formerly Codex Desktop).
<br>52 MCP tools. Pure Rust. Single binary. Zero config.
</p>
</p>
Expand All @@ -30,9 +30,11 @@

## What It Does

`codex-browser-bridge` turns your **local Codex Desktop + Chrome** into an MCP server that any agent can control.
`codex-browser-bridge` turns your **local ChatGPT desktop app + Chrome/Edge** into an MCP server that any agent can control.

No browser profile copying. No WebDriver. No remote setup. It connects to the Codex browser named pipe that already exists on your machine, speaks the same JSON-RPC protocol, and exposes 52 MCP tools for browser automation.
No browser profile copying. No WebDriver. No remote setup. It connects to the `codex-browser-use` named pipe that already exists on your machine, speaks the same JSON-RPC protocol, and exposes 52 MCP tools for browser automation.

> **Naming note:** In 2026 OpenAI folded the Codex app into the new **ChatGPT desktop app**, and the browser extension was renamed from "Codex Chrome Extension" to the **ChatGPT extension** (Chrome, and Edge since app build 26.730). The underlying named pipe (`\\.\pipe\codex-browser-use-*`) and its JSON-RPC protocol kept their names — so this project, and its `codex_*` tool surface, work unchanged with both browsers.

**Your agent can:**

Expand All @@ -58,7 +60,7 @@ npm i -g @delicious233/codex-browser-bridge

Or download from [GitHub Releases](https://github.com/DeliciousBuding/codex-browser-bridge/releases).

**Requires:** Windows · Chrome · Codex Desktop · Codex Chrome Extension
**Requires:** Windows · Chrome or Edge · ChatGPT desktop app (formerly Codex Desktop) · ChatGPT browser extension

## 30-Second Setup (Claude Code)

Expand Down Expand Up @@ -300,9 +302,20 @@ codex-browser-bridge (Rust binary)
Windows Named Pipe \\.\pipe\codex-browser-use-*
│
▼
Codex Desktop → Chrome Extension → Chrome tabs
ChatGPT desktop app → ChatGPT extension → Chrome / Edge tabs
```

## MCP Protocol Support

The bridge is a **dual-era MCP server**:

| Era | Revisions | Behavior |
|-----|-----------|----------|
| Legacy | `2024-11-05` … `2025-11-25` | Classic stdio lifecycle with `initialize` version negotiation (byte-compatible with older clients) |
| Modern | `2026-07-28` | Stateless requests: version carried per-request in `_meta`, `server/discover` probe, `resultType` + cache hints (`ttlMs`/`cacheScope`) on results, `UnsupportedProtocolVersionError` (-32022) |

All 52 tools carry behavior annotations (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`) for client approval UX. See [CHANGELOG.md](CHANGELOG.md) for details.

## Security

This tool gives an agent access to your active browser session.
Expand Down Expand Up @@ -332,7 +345,7 @@ Source layout:

```
src/
mcp/ MCP server (mod, types, schema, handlers, profiles)
mcp/ MCP server (mod, lifecycle, types, schema, handlers, profiles)
browser.rs CDP + browser operations
client.rs Named pipe transport + sticky attach
security.rs URL + file path validation
Expand Down Expand Up @@ -362,7 +375,7 @@ See [ROADMAP.md](ROADMAP.md). Highlights:

## License

MIT. Maintained independently from Codex / Anthropic / Google.
MIT. Maintained independently from OpenAI, Anthropic, and Google.

## Acknowledgments

Expand Down
27 changes: 20 additions & 7 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<p align="center">
<h1 align="center">codex-browser-bridge</h1>
<p align="center">
让 Claude Code 和其他 MCP Agent 通过 Codex Desktop 控制你现有的 Chrome 浏览器。
让 Claude Code 和其他 MCP Agent 通过 ChatGPT 桌面应用(原 Codex Desktop)控制你现有的 Chrome 或 Edge 浏览器。
<br>52 个 MCP 工具。纯 Rust。单文件二进制。零配置。
</p>
</p>
Expand All @@ -30,9 +30,11 @@

## 它能做什么

`codex-browser-bridge` 把你本机的 **Codex Desktop + Chrome** 变成一个任何 agent 都能控制的 MCP 服务器。
`codex-browser-bridge` 把你本机的 **ChatGPT 桌面应用 + Chrome/Edge** 变成一个任何 agent 都能控制的 MCP 服务器。

无需复制浏览器配置。无需 WebDriver。无需远程配置。它直接连接本机已存在的 Codex 浏览器 named pipe,使用相同的 JSON-RPC 协议,暴露 52 个 MCP 工具用于浏览器自动化。
无需复制浏览器配置。无需 WebDriver。无需远程配置。它直接连接本机已存在的 `codex-browser-use` named pipe,使用相同的 JSON-RPC 协议,暴露 52 个 MCP 工具用于浏览器自动化。

> **命名说明:** 2026 年 OpenAI 将 Codex 应用并入新的 **ChatGPT 桌面应用**,浏览器扩展也从 "Codex Chrome Extension" 改名为 **ChatGPT 扩展**(支持 Chrome,应用 26.730 版本起支持 Edge)。底层 named pipe(`\\.\pipe\codex-browser-use-*`)和 JSON-RPC 协议名称保持不变——因此本项目及其 `codex_*` 工具面在两种浏览器下都无需任何改动即可工作。

**你的 Agent 可以:**

Expand All @@ -58,7 +60,7 @@ npm i -g @delicious233/codex-browser-bridge

或从 [GitHub Releases](https://github.com/DeliciousBuding/codex-browser-bridge/releases) 下载。

**需要:** Windows · Chrome · Codex Desktop · Codex Chrome Extension
**需要:** Windows · Chrome 或 Edge · ChatGPT 桌面应用(原 Codex Desktop)· ChatGPT 浏览器扩展

## 30 秒接入 Claude Code

Expand Down Expand Up @@ -261,9 +263,20 @@ codex-browser-bridge (Rust 二进制)
Windows Named Pipe \\.\pipe\codex-browser-use-*
│
▼
Codex Desktop → Chrome Extension → Chrome 标签页
ChatGPT 桌面应用 → ChatGPT 扩展 → Chrome / Edge 标签页
```

## MCP 协议支持

本 bridge 是一个 **双纪元(dual-era)MCP 服务器**:

| 纪元 | 版本 | 行为 |
|------|------|------|
| Legacy | `2024-11-05` … `2025-11-25` | 经典 stdio 生命周期,`initialize` 版本协商(对旧客户端字节级兼容) |
| Modern | `2026-07-28` | 无状态请求:版本通过每个请求的 `_meta` 携带、`server/discover` 探测、结果携带 `resultType` + 缓存提示(`ttlMs`/`cacheScope`)、不支持的版本返回 `UnsupportedProtocolVersionError` (-32022) |

全部 52 个工具都携带行为注解(`readOnlyHint`、`destructiveHint`、`idempotentHint`、`openWorldHint`),供客户端审批 UX 使用。详见 [CHANGELOG.md](CHANGELOG.md)。

## 安全

此工具让 agent 能访问你活跃的浏览器会话。
Expand Down Expand Up @@ -293,7 +306,7 @@ cargo build --locked --release

```
src/
mcp/ MCP 服务(mod, types, schema, handlers, profiles)
mcp/ MCP 服务(mod, lifecycle, types, schema, handlers, profiles)
browser.rs CDP + 浏览器操作
client.rs Named pipe 传输 + sticky attach
security.rs URL + 文件路径验证
Expand Down Expand Up @@ -324,7 +337,7 @@ src/

## 许可证

MIT。独立于 Codex / Anthropic / Google 维护。
MIT。独立于 OpenAI / Anthropic / Google 维护。

## 致谢

Expand Down
9 changes: 6 additions & 3 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# ROADMAP

## Status: v1.10.1 shipped (2026-07-14)
## Status: v1.11.0 shipped (2026-08-19)

52 MCP tools, CDP event architecture, structured network monitoring, `--mode doctor` CLI, JPEG/WebP screenshots. See [CHANGELOG.md](CHANGELOG.md) for the full release history.
52 MCP tools, dual-era MCP protocol support (`2024-11-05` … `2026-07-28`), tool behavior annotations, CDP event architecture, structured network monitoring, `--mode doctor` CLI, JPEG/WebP screenshots. See [CHANGELOG.md](CHANGELOG.md) for the full release history.

**Architecture health (SUPER):** S 5, U 5, P 5, E 3 (Windows-only), R 4 = **22/25**. Remaining gaps are operational maturity (winget/scoop, protocol depth), not architecture.
**Upstream branding:** OpenAI folded Codex Desktop into the ChatGPT desktop app and renamed the extension to the ChatGPT extension (Chrome + Edge since app build 26.730). The `codex-browser-use` pipe name and protocol are unchanged, so no bridge-side migration was needed; docs now reference both names.

**Architecture health (SUPER):** S 5, U 5, P 5, E 3 (Windows-only), R 4 = **22/25**. Remaining gaps are operational maturity (winget/scoop) and platform reach, not architecture.

### Completed releases

- **v1.11.0** (2026-08-19): MCP `2026-07-28` dual-era server (`server/discover`, stateless `_meta`-versioned requests, `resultType` + `ttlMs`/`cacheScope` cache hints, `-32022` version errors) with byte-compatible legacy era; MCP tool annotations on all 52 tools; `initialize` version negotiation + `instructions`.
- **v1.10.1** (2026-07-14): `codex_evaluate` awaits Promises and surfaces JS exceptions; docs for Promise/exception behavior.
- **v1.10.0** (2026-07-10): engineering hardening — reconnect, supply-chain CI, benchmarks, release contract, bounded MCP surfaces.
- **v1.9.1** (2026-06-21): 16 new tools → 52 total. CDP event subscription (`network_monitor`, `console_logs`). Background-tab fix (`bring_to_front` + sticky 20s timeout). JPEG/WebP screenshots, sessionStorage, `--mode doctor`, `performance_metrics`.
Expand Down
2 changes: 1 addition & 1 deletion npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@delicious233/codex-browser-bridge",
"version": "1.10.1",
"version": "1.11.0",
"private": false,
"description": "MCP server that exposes Codex Desktop's Chrome browser bridge for Claude Code and other agents.",
"bin": {
Expand Down
Loading