opencode-delegator
MCP server that delegates code writing, editing, and execution to OpenCode, allowing AI assistants to focus on decision-making.
README
OpenCode Delegator
MCP Server — 让 Codex、Claude Code 等 AI 编码助手只做决策,将代码编写、编辑、执行全部委派给 OpenCode。
快速开始
安装
npm install -g opencode-delegator
或直接使用 npx:
npx opencode-delegator
前置要求
- Node.js >= 18
- OpenCode CLI 已安装并在 PATH 中
配置
Codex CLI — 编辑 ~/.codex/config.toml:
[mcp_servers.opencode]
command = "npx"
args = ["-y", "opencode-delegator"]
env = { OPENCODE_DEFAULT_PROJECT = "/path/to/project" }
Claude Code:
claude mcp add opencode -- npx -y opencode-delegator
Claude Desktop — 编辑配置文件:
{
"mcpServers": {
"opencode": {
"command": "npx",
"args": ["-y", "opencode-delegator"],
"env": { "OPENCODE_DEFAULT_PROJECT": "/path/to/project" }
}
}
}
环境变量
| 变量 | 默认值 | 说明 |
|---|---|---|
OPENCODE_MODE |
spawn |
spawn 或 persistent |
OPENCODE_DEFAULT_PROJECT |
- | 默认项目绝对路径 |
OPENCODE_PATH |
opencode |
OpenCode 可执行文件路径 |
OPENCODE_TIMEOUT |
120000 |
超时时间 (ms) |
OPENCODE_WHITELIST |
false |
启用命令白名单 |
OPENCODE_PROJECTS |
- | JSON 格式多项目配置 |
也支持配置文件 opencode-delegator.json,参见 config.example.json。
工具
| 工具 | 说明 |
|---|---|
write_code |
创建/覆写文件(支持 AI 生成) |
edit_code |
通过 OpenCode 编辑文件(自动 lint/typecheck) |
read_file |
读取文件内容 |
search_code |
ripgrep 搜索代码库 |
run_command |
执行 shell 命令(带安全过滤) |
run_tests |
运行测试套件(自动检测框架) |
git_status |
查看分支和文件状态 |
git_diff |
查看 diff |
git_commit |
暂存并提交 |
git_log |
查看提交历史 |
plan |
OpenCode 分析需求并输出方案 |
execute_plan |
执行已生成的方案 |
list_projects |
列出已注册项目 |
add_project |
动态注册新项目 |
list_sessions |
列出活跃会话(persistent) |
resume_session |
恢复历史会话(persistent) |
ask_opencode |
通用委派工具 |
MCP Resources
| 资源 | URI | 说明 |
|---|---|---|
| project-structure | project://{project}/structure |
项目文件树 |
| project-dependencies | project://{project}/dependencies |
依赖信息 |
| project-recent | project://{project}/recent |
最近 git 变更 |
安全
- 路径校验:所有文件操作限制在项目目录内,防止路径遍历
- 命令过滤:拦截危险 shell 命令(
rm -rf /、curl | sh等),支持白名单模式 - 审计日志:所有工具调用记录到
~/.opencode-delegator/audit.jsonl
架构
┌─────────────────┐ MCP (stdio) ┌──────────────────┐
│ Codex CLI │ ◄────────────────────► │ opencode- │
│ Claude Code │ │ delegator │
│ Cursor 等 │ │ (MCP Server) │
└─────────────────┘ └────────┬─────────┘
│
┌───────────────┼───────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Project A │ │ Project B │ │ Project C │
└──────────┘ └──────────┘ └──────────┘
文档
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.