Skip to main content
Glama
opencode-delegator
by S0ra-ai

OpenCode Delegator

MCP Server — 让 Codex、Claude Code 等 AI 编码助手只做决策,将代码编写、编辑、执行全部委派给 OpenCode。

快速开始

安装

npm install -g opencode-delegator

或直接使用 npx:

npx opencode-delegator

前置要求

Related MCP server: openclaw-mcp

配置

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

Available Tools

17 tools
add_projectC

Register a new project directory.

Inputs: name (required), path (required), mode, port.

ask_opencodeA

Send an arbitrary prompt to OpenCode in a project context. General-purpose delegation tool.

Inputs: prompt (required), model, project.

edit_codeA

Edit an existing file using OpenCode. Delegates all edits to OpenCode for lint/typecheck safety.

Inputs: file (required), instruction (required), project.

execute_planB

Execute a previously generated plan. OpenCode will implement the plan step by step.

Inputs: plan (required), dryRun, project.

git_commitC

Stage all changes and create a git commit.

Inputs: message (required), files, project.

git_diffB

View git diff (unstaged, staged, or specific commit).

Inputs: ref, file, project.

git_logB

View recent git commits.

Inputs: count, project.

git_statusA

Get git status (branch, staged/unstaged changes).

Inputs: project.

list_projectsB

List all registered projects.

Inputs: no named parameters.

list_sessionsB

List active OpenCode sessions (persistent mode only).

Inputs: project.

planA

Use OpenCode in plan mode to analyze, design, and plan without executing. Safe for exploration.

Inputs: task (required), context, project.

read_fileC

Read the contents of a file.

Inputs: file (required), project.

resume_sessionB

Resume a previous OpenCode session (persistent mode only).

Inputs: sessionId (required), project.

run_commandB

Execute a shell command in the project directory. Use for builds, installs, scripts, etc.

Inputs: command (required), force, project, timeout.

run_testsC

Run the project test suite with configurable options.

Inputs: pattern, project, timeout, coverage, +1 more.

search_codeB

Search for patterns in the codebase using ripgrep.

Inputs: pattern (required), glob, path, project.

write_codeA

Create or overwrite a file with code. Use this to write new files or completely replace file contents.

Inputs: file (required), prompt, content, project.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 17 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose. Potential confusion between edit_code and write_code is resolved by descriptions (edit vs create/overwrite). All other tools target different operations or resources.

    Naming Consistency4/5

    Most tools follow a verb_noun pattern (add_project, edit_code, run_command). 'plan' is a lone verb without a noun, and git_* tools use a non-verb prefix, but the overall pattern is consistent and readable.

    Tool Count5/5

    17 tools is appropriate for a coding assistant delegate. Each tool addresses a distinct need (project management, file ops, git, sessions, delegation) without redundancy.

    Completeness4/5

    Core workflow (plan, edit, test, commit) is covered. Minor gaps exist: no tool to delete a project or end a session, but these are not essential for typical usage.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      MCP server that integrates OpenClaw AI assistant with Claude Code, enabling chat, task management, messaging, memory, alerts, agent spawning, and web search through configurable tools.
      12
      406 npm
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      An MCP server that empowers AI coding agents to work effectively with Minecraft mod development, providing static analysis of decompiled source code and runtime interaction with a running Minecraft instance.
      31
      92 npm
      18
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      An MCP server that lets an AI coding agent delegate implementation work to the OpenCode CLI, choosing an explicit provider + model on every call.
      3
      MIT