herdr-mcp
MCP server that exposes the Herdr terminal API as callable tools, enabling AI agents to manage terminal workspaces, tabs, panes, and agents. It dynamically generates tools from the Herdr API schema and communicates via Unix socket.
README
herdr-mcp
A Model Context Protocol (MCP) server that exposes 20 hand-crafted tools from the Herdr terminal API for AI agents — focused exclusively on multi-agent orchestration with git worktrees.
Each tool lives in its own file in tools/, with explicit input schemas, descriptions, and a direct JSON-RPC call to the Herdr Unix socket. No schema auto-generation, no magic.
Features
- 20 curated tools — only what's needed for worktree orchestration:
worktree.*,agent.*,pane.*,workspace.*,tab.*,ping,session.snapshot. No noise from graphics, plugins, layout management, or reporting APIs. - One file per tool — each tool in
tools/<method>.jsexports{ name, description, inputSchema, handler }. Easy to read, test, and modify. - WARNING prefix on destructive tools (
worktree.remove) to make the risk visible in the agent's tool list. - Auto-timeouts — calls are capped by a client-side timeout (30s by default), and blocking tools that accept
timeout_msare given enough headroom to complete instead of being cut short. - Dynamic socket discovery — the Herdr socket path is resolved automatically via
herdr status server --json. - Zero-config — no environment variables or configuration required.
How it works
- Startup: the server loads the 20 tool definitions from
tools/index.js. - Call: when a tool is invoked, the server sends the corresponding JSON-RPC request over the Herdr Unix socket and returns the result.
Tool naming follows herdr_<method> (dots become underscores), e.g. herdr_pane_split, herdr_agent_prompt, herdr_worktree_create.
Requirements
- Node.js 18+
- Herdr installed and running (the MCP talks to the Herdr server socket and discovers the socket path via
herdr status server --json). Theherdrbinary must be onPATH. - opencode (to register the MCP server)
Installation in opencode
The included installer registers the MCP server in opencode's config and copies
all commands from commands/ (/orchestrate, /plan-worktrees)
into opencode's command directory — without breaking any existing config
(comments, formatting and unrelated MCP servers are preserved).
-
Clone or copy the project to the target machine:
git clone git@github.com:Twinber/herdr-mcp.git cd herdr-mcp npm install -
Run the installer:
./install.sh # install globally (~/.config/opencode) ./install.sh --project # install into the current project's .opencode/Options:
--dry-run— show what would change without writing anything;--no-test— skip the automaticnpm install+ smoke test;--all— expose all 89 herdr API tools (default: restricted to 20 orchestration tools).
The installer is idempotent: re-running it leaves an already-registered
mcp.herdruntouched, and it refuses to touch an unparseable config (aborting with nothing changed). -
Restart opencode. The
herdr_*tools will be available to agents (shown asherdr_herdr_*), and the/orchestrateand/plan-worktreescommands will be available globally.
Tool modes
By default the server exposes only the 20 tools needed for worktree
orchestration (worktree.*, agent.*, pane.* (split/send_input/
wait_for_output/list/get), workspace.*, tab.*, ping, session.snapshot).
Destructive or noisy tools (workspace.close, tab.close, pane.close,
server.stop, graphics, plugins, layout, reporting, ...) are excluded.
To expose all 89 tools (e.g. for full herdr API access), pass --all to the
installer or to server.js directly:
./install.sh --all
# or in opencode.jsonc:
# "command": ["node", "/path/to/server.js", "--all"]
Development
npm test # run the smoke test (initializes the MCP, lists tools, calls herdr_pane_list)
npm start # run the server directly (stdio transport)
The smoke test spawns the server over stdio, performs the MCP handshake, verifies tools/list, and makes a real tools/call against your running Herdr instance.
Multi-agent orchestration with /orchestrate
/orchestrate is an opencode command that turns an opencode agent into a
reactive orchestrator. It drives the herdr MCP tools to launch one opencode
subagent per git worktree, monitor/unblock them, cross-review, merge, push and
open PRs — reacting to what it observes instead of predicting states.
Usage (from any opencode session with the herdr MCP connected):
/orchestrate /path/to/tasks/config.json
/orchestrate <inline JSON>
The config format and pipeline are documented in
commands/orchestrate.md. Example configs live in tasks/
(config.example.json, test-1.json, test-blocked.json).
Planning with /plan-worktrees
/plan-worktrees is the companion planning command. It interviews you about a
feature or fix you want, decomposes it into parallelizable tasks (non
overlapping files, no inter-task dependencies), and writes the factory JSON that
/orchestrate consumes directly.
/plan-worktrees # then answer the interviewer's questions
/plan-worktrees Add a station search box and a country filter to the map page
It asks questions via the question tool until the repo details and the task
decomposition are unambiguous, writes the config to
<repo>/tasks/<date>-<slug>.json, summarizes the plan, and hands off with
/orchestrate <file>.
Project layout
herdr-mcp/
├── server.js # MCP entry (stdio transport, tools/list + tools/call)
├── install.sh # installer entrypoint
├── scripts/
│ └── install.mjs # merges mcp.herdr into opencode config, copies commands
├── tools/
│ ├── index.js # collects all 20 tool definitions
│ ├── ping.js
│ ├── session.snapshot.js
│ ├── workspace.list.js / workspace.get.js
│ ├── tab.list.js / tab.get.js
│ ├── pane.list.js / pane.get.js / pane.split.js / pane.send_input.js / pane.wait_for_output.js
│ ├── agent.start.js / agent.prompt.js / agent.get.js / agent.wait.js / agent.read.js / agent.send_keys.js
│ └── worktree.create.js / worktree.remove.js / worktree.list.js
├── src/
│ └── client.js # JSON-RPC client for the Herdr Unix socket
├── commands/ # /orchestrate + /plan-worktrees commands
├── tasks/ # task configs for /orchestrate
├── test/
│ └── smoke.js # end-to-end smoke test
└── package.json
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。