codex-mcp-opencode
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@codex-mcp-opencoderefactor the user model to use async/await"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
codex-mcp-opencode
A project-local MCP bridge: Codex plans; OpenCode executes in the project.
项目内 MCP 桥接器:Codex 负责规划,OpenCode 在项目内执行。
Codex Desktop -> codex-mcp-opencode -> OpenCode Server/SDK -> Current project
planning thin control plane sessions/models code and tools中文说明
它解决什么问题
codex-mcp-opencode 让 Codex Desktop 作为项目的规划者和调度者,而 OpenCode 作为实际执行者。Codex 只需向 OpenCode 下达简短、具体的工作指令;OpenCode 从启动它的当前项目目录中自行读取代码、配置和已有上下文。
它不是第二个项目记忆系统,也不是 API Key 管理器,更不会向模型重复发送源码或项目摘要。模型、供应商和凭据始终由 OpenCode 自己管理。
核心特性
能力 | 说明 |
项目天然隔离 | MCP 从当前项目目录启动,不接受 |
短期会话复用 | 默认复用 24 小时内、同模型且空闲的主会话,减少重复加载上下文。 |
生命周期管理 | 可列出、取消、删除、清理过期会话;不会自动删除活动会话或子会话。 |
原生后台子代理 | 只使用 OpenCode 的后台 subagent 能力,不实现 worktree 或外部并行替代。 |
MCP 长任务 | 宿主支持 MCP Tasks 时,可用可轮询、可恢复的 |
原生压缩 | 不自行计数 token 或总结;只依赖 OpenCode 的自动压缩和裁剪。 |
保守权限 | OpenCode 以 |
前置条件
Node.js 20 或更高版本。
opencode已安装、可在PATH中调用,并已在 OpenCode 内配置模型和凭据。OpenCode 中的目标模型必须设置
limit.context为550000。OpenCode 中必须开启原生压缩和裁剪:
compaction.auto: true、compaction.prune: true。
桥接器会在执行前检查模型上报的 limit.context,不是 550000 就拒绝运行。这样 DeepSeek 不会被推到约 600k 后才压缩。这个值需要在 OpenCode 配置中设置,MCP 不会改写供应商、模型或 API Key。
通用的 OpenCode 配置形状如下,请将占位符替换为自己的供应商和模型:
{
"provider": {
"<provider-id>": {
"models": {
"<model-id>": {
"limit": { "context": 550000, "output": 32000 }
}
}
}
},
"compaction": { "auto": true, "prune": true }
}给其他用户的安装与接入
本仓库当前可直接从 GitHub 安装,尚未发布到 npm。使用者不需要修改源码、填写 API Key,也不需要在工具调用中提供项目路径。
方式一:直接在 Codex MCP 配置中使用 GitHub(推荐)
将以下命令配置为 Codex 的 stdio MCP 服务:
command: npx
args: --yes github:Ichikawashadow/codex-mcp-opencodeCodex 必须从当前打开的目标项目目录启动该命令。npx 从 GitHub 获取包时会运行 prepare 自动构建;之后 OpenCode 仍由 MCP 在当前项目内拉起。
方式二:克隆后本地安装
git clone https://github.com/Ichikawashadow/codex-mcp-opencode.git
cd codex-mcp-opencode
npm ci
npm run build然后将下面的程序配置为 Codex 的 stdio MCP 服务:
command: node
args: <安装目录>/dist/index.js这里的 <安装目录> 是 MCP 自身的本机安装位置,不是目标项目路径。它只应存在于用户自己的 Codex 配置中,不能写进本仓库、代码或工具参数。
无论选哪种方式,都要确认:
opencode --version能正常运行,并且 OpenCode 已在其自己的配置中完成模型/API 配置。
首次使用时:
调用
opencode.configure,不传参数。从返回的模型列表中选择一个已按 550k 配置的
<provider-id>/<model-id>。再次调用
opencode.configure,将它作为defaultModel。使用
opencode.run向 OpenCode 发送简短工作指令。
日常使用时,Codex 可先调用 opencode.sessions 查看近期会话,再用 opencode.run 复用会话或启动新工作。需要并行时,传入 backgroundSubagents: true;它只会启用 OpenCode 原生后台子代理。
工具参考
工具 | 何时使用 |
| 首次配置、查看 OpenCode 可用模型、设置默认模型和复用/清理周期。 |
| 正常执行任务;可指定会话、模型、是否复用,以及是否允许原生后台子代理。 |
| 支持 MCP Tasks 的宿主上运行长任务;结果从 OpenCode 会话恢复,不在 MCP 中保存输出副本。 |
|
|
会话和权限
本地注册表按工作目录隔离,只保存会话 ID、父会话 ID、模型 ID、时间戳及活动任务 ID。它不保存提示词、代码、Diff、日志、模型输出、路径、密钥或项目摘要。OpenCode 才是会话历史与输出的唯一来源。
标准 MCP 无法把 Codex Desktop 的实时逐命令审批状态传给服务器,因此无法承诺完全相同的动态权限。桥接器采取更严格的下限:edit、bash、webfetch、external_directory 和 doom_loop 均为 ask。当 OpenCode 请求操作许可时,用 opencode.sessions 查看并显式响应。
开发
npm test
npm run build
npm pack --dry-runRelated MCP server: opencode-chatgpt-bridge
English
What it is for
codex-mcp-opencode makes Codex Desktop the planner and dispatcher for a project, while OpenCode is the execution agent. Codex sends short, specific work instructions; OpenCode reads code, configuration, and existing context directly from the project directory in which it was launched.
This is not a second project-memory system or an API-key manager. It never sends source trees or broad project summaries back through the bridge. Providers, models, and credentials remain entirely in OpenCode.
Key capabilities
Capability | Behavior |
Project-local by default | The MCP starts in the current project directory and has no |
Short-lived session reuse | By default, an idle primary session using the same model is reused for 24 hours. |
Session lifecycle | List, cancel, delete, and clean expired sessions without automatically deleting active or child sessions. |
Native background subagents | Uses only OpenCode background subagents; there is no worktree or external-parallel fallback. |
MCP Tasks |
|
Native compaction | The bridge never counts tokens or creates summaries; OpenCode handles compaction and pruning. |
Conservative permissions | OpenCode starts with |
Prerequisites
Node.js 20 or later.
opencodeinstalled onPATH, with models and credentials configured in OpenCode.The target OpenCode model configured with
limit.contextset to550000.Native OpenCode compaction enabled:
compaction.auto: trueandcompaction.prune: true.
Before execution, the bridge checks the model's reported limit.context and refuses anything other than 550000. This keeps DeepSeek below the chosen compaction boundary rather than allowing it to reach roughly 600k first. The setting belongs in OpenCode configuration; the MCP never rewrites providers, models, or API keys.
Use this portable OpenCode configuration shape, replacing the placeholders with your provider and model IDs:
{
"provider": {
"<provider-id>": {
"models": {
"<model-id>": {
"limit": { "context": 550000, "output": 32000 }
}
}
}
},
"compaction": { "auto": true, "prune": true }
}Installation and connection for other users
This repository can currently be installed directly from GitHub; it has not been published to npm. Users do not need to edit source code, enter API keys, or provide project paths in tool calls.
Option 1: use GitHub directly in Codex MCP configuration (recommended)
Configure this command as a Codex stdio MCP server:
command: npx
args: --yes github:Ichikawashadow/codex-mcp-opencodeCodex must start the command from the currently opened target project directory. When npx obtains the package from GitHub it runs prepare to build it; the MCP still starts OpenCode inside the current project.
Option 2: clone and install locally
git clone https://github.com/Ichikawashadow/codex-mcp-opencode.git
cd codex-mcp-opencode
npm ci
npm run buildThen configure this program as a Codex stdio MCP server:
command: node
args: <installation-directory>/dist/index.js<installation-directory> is the user's local MCP installation, not the target project path. It belongs only in the user's Codex configuration, never in this repository, source code, or tool arguments.
With either option, confirm that:
opencode --versionworks and that OpenCode has its own model/API configuration.
First use:
Call
opencode.configurewith no arguments.Select an OpenCode model already capped at 550k from the returned list.
Call
opencode.configureagain with that<provider-id>/<model-id>asdefaultModel.Use
opencode.runto send short work instructions to OpenCode.
For daily work, Codex can call opencode.sessions to inspect recent sessions and then call opencode.run to reuse a session or start fresh work. For parallel work, pass backgroundSubagents: true; this only enables OpenCode native background subagents.
Tool reference
Tool | When to use it |
| First-time setup, model discovery, and default model/reuse/cleanup settings. |
| Normal task execution; optionally select a session/model, control reuse, or allow native background subagents. |
| Long-running work for hosts that support MCP Tasks; output remains in the OpenCode session rather than being copied to MCP storage. |
| Use |
Sessions and permissions
The small local registry is isolated by launch directory. It stores only session IDs, parent session IDs, model IDs, timestamps, and active task IDs. It never stores prompts, code, diffs, logs, model output, paths, keys, or project summaries. OpenCode is the single source of truth for session history and output.
Standard MCP does not expose Codex Desktop's live per-command approval state to servers, so exact dynamic permission mirroring is impossible. The bridge takes the stricter floor: edit, bash, webfetch, external_directory, and doom_loop all start as ask. Use opencode.sessions to inspect and explicitly answer OpenCode permission requests.
Development
npm test
npm run build
npm pack --dry-runThis server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ichikawashadow/codex-mcp-opencode'
If you have feedback or need assistance with the MCP directory API, please join our Discord server