关于 Herald - The Self Hosted Mcp Bridge Between Claude Chat And Claude Code
Herald 是一个可自托管的 MCP 服务,用于连接 Claude Chat 与 Claude Code。用户可在手机或浏览器中下达任务,由工作站上的 Claude Code 在后台执行,适合希望远程推进编码工作的开发者。
主要功能
- 01基于 Anthropic 官方 Custom Connectors 协议
- 02异步任务执行与进度查询
- 03每个任务使用独立 Git 分支
- 04会话恢复与多轮对话
- 05支持 Claude Code 会话推送回 Herald
- 06按项目限制 Claude Code 可用工具
适用场景
- 01在手机上下发重构或测试任务到工作站
- 02离开电脑后查看任务状态并获取结果
- 03在另一台设备上继续 Claude Code 会话
MCP 相关
Herald 是 MCP 服务,向 Claude Chat 暴露 start_task、check_task、get_result、get_diff 等 10 个工具,并通过 MCP 通知推送任务更新。
配置
远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。
https://your-herald-instance.example.com/mcpclaude mcp add --transport http herald https://your-herald-instance.example.com/mcp{"mcpServers":{"herald":{"type":"http","url":"https://your-herald-instance.example.com/mcp"}}}在 Cursor 中打开{"servers":{"herald":{"type":"http","url":"https://your-herald-instance.example.com/mcp"}}}在 VS Code 中打开{"mcpServers":{"herald":{"type":"http","url":"https://your-herald-instance.example.com/mcp"}}}{"mcpServers":{"herald":{"serverUrl":"https://your-herald-instance.example.com/mcp"}}}命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。
工具
详细介绍
Herald
用手机写代码。真的。
连接 Claude Chat 与 Claude Code 的可自托管 MCP 桥接工具。
文档 ·
快速开始 ·
工作原理 ·
功能 ·
安全 ·
路线图
🇫🇷 法语版本
你正窝在沙发上,手里拿着手机。你打开 Claude Chat 并输入:
“将 my-api 中的身份验证中间件重构为使用 JWT,而不是会话 Cookie。运行测试。”
四分钟后,任务完成。已创建分支、重构代码、测试通过,并提交了更改。所有工作都由你的工作站完成。你甚至没打开笔记本电脑。
这就是 Herald。
问题
Claude Chat 和 Claude Code 是两款出色的工具,却各自运行在完全独立的世界里。
| Claude Chat | Claude Code | |
|---|---|---|
| 位置 | 浏览器、手机,随处可用 | 你的终端 |
| 功能 | 对话、分析、思考 | 读取、编写并交付实际代码 |
| 局限 | 无法访问你的代码库 | 无法离开你的办公桌 |
你一直在两者之间复制粘贴。或者更糟——你一直等到回到办公桌前才开始处理。这种情况到此为止。
解决方案
Herald 是一个可自托管的 MCP 服务,通过 Anthropic 官方的 Custom Connectors 协议将 Claude Chat 连接到 Claude Code。一个 Go 二进制文件,零 hack。
You (phone/tablet/browser)
│
│ "Add rate limiting to the API"
▼
Claude Chat ──── MCP over HTTPS ────► Herald (your workstation)
│
▼
Claude Code
├── reads your codebase
├── writes the code
├── runs the tests
└── commits to a branch
You (terminal)
│
│ Claude Code calls herald_push
▼
Claude Code ──── MCP ────► Herald ────► Claude Chat picks it up
└── session context, summary,
files modified, git branch
这个桥接工具是双向的。Claude Chat 可以向 Claude Code 分派任务,而 Claude Code 也可以将会话上下文推送回 Herald,以便远程监控,并从其他设备继续会话。
你的代码绝不会离开本机。Herald 只负责协调。
工作原理
You (Claude Chat) Herald Claude Code
───────────────── ────── ───────────
"Refactor auth..." ──► start_task
→ creates branch
→ spawns Claude Code ──► reads codebase
refactors code
runs tests
commits changes
◄── task_id: herald-a1b2c3d4
"How's it going?" ──► check_task
◄── ✅ Completed (4m 12s)
4 files changed (+127/-23)
"Show me the diff" ──► get_diff
◄── auth/middleware.go
+func ValidateJWT(...)
-func CheckSession(...)
三个工具,就是核心工作流程。启动、检查、获取结果——无论你身在何处,都能完成。
反向流程:Claude Code → Herald
在终端中工作时,如果想在手机上继续,可以让 Claude Code 将会话推送到 Herald:
You (terminal) Claude Code Herald
────────────── ─────────── ──────
"Push this to Herald" ──► herald_push
→ session_id, summary,
files, branch ──► linked task created
🔗 visible in list_tasks
You (phone, later) Claude Chat Herald
────────────────── ─────────── ──────
"What sessions are list_tasks
waiting for me?" ──► (status: linked) ──► 🔗 herald-a1b2c3d4
my-api / feat/auth
"Resume that session" ──► start_task
(session_id) ──► picks up where you left off
功能
核心功能
- 原生 MCP 桥接 — 使用 Anthropic 官方的 Custom Connectors 协议。不是 hack,不是封装器,也不是代理。
- 异步任务执行 — 启动任务、查看进度、获取结果。Claude Code 会在后台运行,你可以同时处理其他事情。
- Git 分支隔离 — 每个任务都在独立分支上运行,不会触碰主分支。
- 会话续接 — 支持多轮 Claude Code 对话。可以从上次中断处继续。
- 双向桥接 — Claude Code 可以通过
herald_push将会话上下文推送到 Herald,以便远程监控,并从其他设备继续会话。
多项目支持
- 多个项目 — 按需配置任意数量的项目,每个项目都有自己的设置。
- 按项目限制工具 — 精确控制 Claude Code 可使用的工具。每个项目都拥有完整的沙盒隔离。
运维
- MCP 推送通知 — Herald 通过 MCP 服务通知将任务更新直接推送到 Claude Chat。无需轮询。
- SQLite 持久化 — 即使服务重启,任务也会保留。完整历史记录,且支持全面搜索。
工程
- 单一二进制文件 — 一个 Go 可执行文件,约 15MB。无需 Docker、运行时或 node_modules。
- 零 CGO — 纯 Go。可交叉编译为 Linux、macOS、Windows 和 ARM 版本。
- 6 个依赖项 — chi、mcp-go、modernc/sqlite、uuid、yaml、testify。这就是全部依赖树。
快速开始
前置条件:Claude Code CLI 已安装,并通过 ngrok(内置)或带反向代理的域名提供 HTTPS。
1. 安装
curl -fsSL https://raw.githubusercontent.com/btouchard/herald/main/install.sh | sh
或从源代码构建(需要 Go 1.26+)
git clone https://github.com/btouchard/herald.git
cd herald && make build
# Binary is in ./bin/herald
2. 配置
mkdir -p ~/.config/herald
cp configs/herald.example.yaml ~/.config/herald/herald.yaml
# Edit with your domain and projects (see below)
3. 运行
herald serve
# Client secret is auto-generated on first start and displayed in the console
编辑 ~/.config/herald/herald.yaml,填写你的域名和项目:
server:
host: "127.0.0.1"
port: 8420
public_url: "https://herald.yourdomain.com"
auth:
client_id: "herald-claude-chat"
projects:
my-api:
path: "/home/you/projects/my-api"
description: "Main backend API"
default: true
allowed_tools:
- "Read"
- "Write"
- "Edit"
- "Bash(git *)"
- "Bash(go *)"
- "Bash(make *)"
git:
auto_branch: true
branch_prefix: "herald/"
然后从 Claude Chat 连接:
- Claude Chat → 设置 → 自定义连接器
- 添加连接器:
https://herald.yourdomain.com/mcp - 通过 OAuth 进行身份验证
- 完成 — Claude Chat 现在有 10 个新工具可用于控制你的工作站
使用 ngrok 快速开始(无需反向代理)
没有域名或反向代理?使用 ngrok,即可通过 HTTPS 立即公开 Herald:
1. 获取 ngrok 身份验证令牌
在 ngrok.com 注册(免费套餐即可),并从控制面板获取身份验证令牌。
2. 在配置中启用隧道
编辑 ~/.config/herald/herald.yaml:
tunnel:
enabled: true
provider: "ngrok"
authtoken: "2abc..." # or set HERALD_NGROK_AUTHTOKEN env var
# domain: "my-herald.ngrok-free.app" # optional: fixed domain (paid plans)
3. 运行 Herald
herald serve
# Tunnel URL appears in the banner:
# Tunnel: https://abc123.ngrok-free.app (ngrok)
使用横幅中显示的 ngrok URL 从 Claude Chat 连接即可。就是这么简单 — 无需配置 Traefik、Caddy 或 DNS。
注意:ngrok 隧道是可选的。如果你已有反向代理(Traefik/Caddy),请保留
tunnel.enabled: false,照常使用你的域名。
完整配置参考
server:
host: "127.0.0.1" # Always localhost — reverse proxy handles external
port: 8420
public_url: "https://herald.yourdomain.com"
log_level: "info" # debug, info, warn, error
log_file: "" # Optional file path for log output
auth:
client_id: "herald-claude-chat"
# client_secret is auto-generated — override with HERALD_CLIENT_SECRET env var if needed
access_token_ttl: 1h
refresh_token_ttl: 720h # 30 days
redirect_uris:
- "https://claude.ai/oauth/callback"
- "https://claude.ai/api/oauth/callback"
- "https://claude.ai/api/mcp/auth_callback"
database:
path: "~/.config/herald/herald.db"
retention_days: 90
execution:
claude_path: "claude"
model: "claude-sonnet-4-5-20250929" # Default model for tasks
default_timeout: 30m
max_timeout: 2h
work_dir: "~/.config/herald/work"
max_concurrent: 3
max_prompt_size: 102400 # 100KB
max_output_size: 1048576 # 1MB
env:
CLAUDE_CODE_ENTRYPOINT: "herald"
CLAUDE_CODE_DISABLE_AUTO_UPDATE: "1"
projects:
my-api:
path: "/home/you/projects/my-api"
description: "Main backend API"
default: true
allowed_tools:
- "Read"
- "Write"
- "Edit"
- "Bash(git *)"
- "Bash(go *)"
- "Bash(make *)"
max_concurrent_tasks: 1
git:
auto_branch: true
auto_stash: true
auto_commit: true
branch_prefix: "herald/"
tunnel:
enabled: false # Set to true to enable ngrok tunnel
provider: "ngrok"
authtoken: "" # or set HERALD_NGROK_AUTHTOKEN env var
# domain: "" # optional: fixed domain (paid ngrok plans)
rate_limit:
requests_per_minute: 200
burst: 100
MCP 工具
Herald 提供 10 个工具,Claude Chat 会通过 MCP 协议自动发现这些工具:
| 工具 | 功能 |
|---|---|
start_task | 启动 Claude Code 任务。立即返回 ID。支持优先级、超时、会话恢复和 Git 分支选项。 |
check_task | 检查状态和进度。可选择包含近期输出。 |
get_result | 获取已完成任务的完整结果(summary、full 或 json)。 |
list_tasks | 按状态、项目和时间范围等筛选条件列出任务。 |
cancel_task | 取消正在运行或排队中的任务。可选择还原 Git 更改。 |
get_diff | 获取任务分支或未提交更改的 Git diff。 |
list_projects | 列出已配置的项目及其 Git 状态。 |
read_file | 读取项目中的文件(路径安全 — 无法跳出项目根目录)。 |
herald_push | 将 Claude Code 会话推送到 Herald,以便从其他设备远程监控并继续会话。 |
get_logs | 查看日志和活动历史记录。 |
安全
Herald 会将 Claude Code 暴露到网络中。我们对此非常重视。
| 层 | 防护措施 |
|---|---|
| 网络 | 仅绑定到 127.0.0.1。通过内置 ngrok 隧道或反向代理(Traefik/Caddy)提供 HTTPS。 |
| 身份验证 | 使用 PKCE 的 OAuth 2.1。每个请求都需要有效的 Bearer 令牌。 |
| 令牌 | 访问令牌:1h。刷新令牌:30d,每次使用后轮换。 |
| 文件系统 | 所有文件操作均提供路径遍历防护。阻止通过符号链接逃逸。 |
| 执行 | 按项目限制工具。不会一概使用 --dangerously-skip-permissions。 |
| 速率限制 | 每个令牌每分钟 200 个请求(可配置)。 |
| 超时 | 每项任务都有截止时间(默认:30min)。不会出现失控进程。 |
| 提示词 | 原样传递给 Claude Code。不注入、不扩充、不改写。 |
| 审计 | 记录每项操作的时间戳和身份。 |
架构
Claude Chat (mobile/web)
→ HTTPS (MCP Streamable HTTP + OAuth 2.1)
→ Traefik / Caddy (TLS termination)
→ Herald (Go binary, port 8420)
├── MCP Handler (/mcp)
├── OAuth 2.1 Server (PKCE, token rotation)
├── Task Manager (goroutine pool, priority queue)
├── Executor Registry (pluggable backends, default: Claude Code)
├── SQLite (persistence)
└── MCP Notifications (server push via SSE)
设计原则:单二进制文件(所有内容都编译进一个 Go 可执行文件)、异步优先(每项任务都是一个 goroutine)、无状态 MCP 搭配有状态后端、故障安全(Herald 崩溃不会终止正在运行的 Claude Code 进程)。
技术栈
| 组件 | 选型 | 原因 |
|---|---|---|
| 语言 | Go 1.26 | 单二进制文件、交叉编译、goroutine |
| MCP | mcp-go | Streamable HTTP、官方协议支持 |
| 路由器 | chi | 轻量、兼容标准库 |
| 数据库 | modernc.org/sqlite | 纯 Go、无需 CGO |
| 日志记录 | log/slog | Go 标准库、结构化 |
| 配置 | gopkg.in/yaml.v3 | 标准 YAML |
6 个直接依赖。无 ORM。无日志框架。无构建工具链。
部署
Herald 以原生二进制文件运行效果最佳(可直接访问 Claude Code 和你的文件)。也可选择使用 Docker。
使用 Traefik 的 Docker Compose
services:
traefik:
image: traefik:v3
command:
- "--entrypoints.websecure.address=:443"
- "[email protected]"
- "--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json"
- "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web"
ports:
- "443:443"
volumes:
- "./letsencrypt:/letsencrypt"
herald:
build: .
network_mode: host
volumes:
- "~/.config/herald:/root/.config/herald"
- "~/projects:/root/projects:ro"
labels:
- "traefik.http.routers.herald.rule=Host(`herald.yourdomain.com`)"
- "traefik.http.routers.herald.tls.certresolver=le"
- "traefik.http.services.herald.loadbalancer.server.port=8420"
路线图
| 版本 | 状态 | 重点 |
|---|---|---|
| v0.1 | ✅ 已完成 | 核心 MCP 服务、异步任务、Git 集成、OAuth 2.1、SQLite |
| v0.2 | 🚧 进行中 | 共享记忆——Claude Chat 与 Claude Code 之间的双向上下文 |
| v0.3 | 🚀 未来 | 稳定 API、插件系统 |
有想法?提交问题。我们会开发用户需要的功能。
参与贡献
Herald 目前处于早期 Alpha 阶段——这是参与塑造项目的最佳时机。
# Get started
git clone https://github.com/btouchard/herald.git
cd herald
make build && make test
# Create your branch
git checkout -b feat/your-feature
# Code, test, lint
make lint && make test
# Open a PR
提交消息遵循 Conventional Commits(feat:、fix:、refactor:、docs:)。
无论是修复错误、添加新的通知后端,还是改进文档,我们都欢迎各种贡献。
为什么选择 Herald?
| Herald | 复制粘贴工作流 | 其他工具 | |
|---|---|---|---|
| 官方协议 | MCP Custom Connectors | 不适用 | 自定义 API,脆弱易失效 |
| 代码保留在本地 | 始终如此 | 是 | 视情况而定 |
| 可通过手机使用 | 原生支持 | 否 | 很少支持 |
| 可自托管 | 100% | 不适用 | 通常是 SaaS |
| 依赖项 | 6 | 不适用 | 50-200+ |
| 设置时间 | 约 5 分钟 | 不适用 | 30 分钟以上 |
| 需要 CGO | 否 | 不适用 | 通常需要 |
Herald 使用的协议与 Anthropic 为其自有集成构建的协议相同。无需逆向工程、无需非官方 API,也无需担心小把戏会在下次更新时失效。
AGPL-3.0 许可证 — 由 Benjamin Touchard 构建
如果 Herald 为你节省了时间,请点个星。这有助于其他人发现这个项目。
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。