Codex to OpenCode MCP Server
CodexからOpenCodeへのMCPサーバー
Codexがコーディング作業をOpenCodeに委任できるようにする、ローカルで動作する小さなMCP(Model Context Protocol)サーバーです。公式のMCP Python SDK、stdioトランスポート、非同期のOpenCodeサブプロセスを利用します。
ツール
opencode_execute
opencode_execute(
task: str,
working_directory: str,
model: str | None = None,
reasoning_effort: str | None = None,
timeout: int = 1800,
)このコマンドをシェルなしで実行します:
opencode run --format json --dir <working_directory> --auto [--model <model>] [--variant <reasoning_effort>] <task>reasoning_effortは、OpenCodeのプロバイダー固有の--variantオプションに対応します。一般的な値にはminimal、low、medium、high、maxなどがありますが、利用可能なバリアントは選択したプロバイダーとモデルによって定義されます。MCPサーバーは、プロバイダー固有のenumを強制せず、意図的に空でない任意の値を受け入れます。
例:
opencode_execute(
task="Implement uncertainty propagation and run the unit tests.",
working_directory="C:\\path\\to\\NuSR",
model="pinche_10/gpt-5.6-sol",
reasoning_effort="high",
timeout=1800,
)次の内容を含む構造化された出力を返します:
成功、タイムアウト、終了コード、経過時間
OpenCodeのセッションIDと最終的なアシスタントの要約
完了したOpenCodeのツール呼び出しとエラー
上限付きのstdout/stderrキャプチャ
最終的な
git status --short、git diff --stat、および上限付きのunified diff
Gitフィールドは実行後のスナップショットです。この呼び出しの前にすでに存在していた変更が含まれることもあります。未追跡ファイルのテキスト内容は新規ファイルのパッチとして表現され、バイナリの未追跡ファイルはパスとサイズで報告されます。
opencode_check
設定されたOpenCode実行可能ファイルを特定し、環境を変更せずにopencode --versionを実行します。
Related MCP server: Claude Code Manager WAN
インストール
要件:Python 3.11以上、Git(diffレポート用にオプション)、OpenCode。
git clone https://github.com/TAO-MINGYU/codex_to_opencode.git
cd codex_to_opencode
uv venv --python 3.11 .venv
uv pip install --python .venv\Scripts\python.exe -e ".[dev]"OpenCodeは個別にインストールされ、認証されている必要があります。まず確認してください:
opencode --version
opencode auth listOpenCodeデスクトップアプリケーションとOpenCode CLIは、Windows上では別々のエントリポイントです。GUIを開いて何も出力しないOpenCode.exe --versionの実行は、CLIとして利用できません。必要になった場合は、公式CLIをインストールしてください:
npm install -g opencode-aiopencodeがPATHにない場合は、OPENCODE_MCP_COMMANDに実行ファイルの絶対パスを設定してください。Windowsのnpmインストールでは、node_modules\opencode-ai\bin\opencode.exeにあるネイティブバイナリを推奨します。サーバーはopencode.cmdラッパーも自動的に検出してバイパスします。
Codexを接続する
設定を手編集しなくて済むように、Codex CLIでサーバーを追加します:
codex mcp add opencode --env OPENCODE_MCP_COMMAND=C:\path\to\opencode.exe -- C:\path\to\opencode-mcp\.venv\Scripts\python.exe -m opencode_mcp.serverOpenCodeがすでにPATHにある場合は、--envオプションを省略します:
codex mcp add opencode -- C:\path\to\opencode-mcp\.venv\Scripts\python.exe -m opencode_mcp.serverその後、登録を確認します:
codex mcp listMCP設定を変更した後は、Codexを再起動してください。このサーバーは、stdio MCPサーバーに要求されるように、プロトコルメッセージをstdoutにのみ書き込み、ログをstderrに送信します。
設定
環境変数 | デフォルト | プロセッサ |
|
| 実行可能ファイル名または絶対パス |
|
| 実行可能ファイルの後に挿入されるJSON配列(ラッパーやテストに便利) |
|
| OpenCodeの |
|
| stdout/stderrのそれぞれに保持される末尾バイト数 |
|
| stderrに書き込まれるサーバーログレベル |
自動承認をfalseに設定すると、OpenCodeは対話的に確認できない権限を拒否します:
$env:OPENCODE_MCP_AUTO_APPROVE = "false"デバッグ
自動テストを実行します:
.venv\Scripts\python.exe -m pytest --cov=opencode_mcp --cov-fail-under=80
.venv\Scripts\python.exe -m ruff check .
.venv\Scripts\python.exe -m ruff format --check .MCP Inspectorでサーバーを実行します:
uv run --python 3.11 --with-editable ".[dev]" mcp dev src\opencode_mcp\server.pyMCPツールのタイムアウトは、opencode_executeに渡すtimeoutよりわずかに長く設定してください。そうしないと、サーバーがOpenCodeを終了して診断情報を返す前に、CodexがMCPリクエストをキャンセルしてしまう可能性があります。
セキュリティモデル
opencode_executeは、意図的に書き込みが可能で、破壊的な可能性があるツールです。このMCPサーバーと同じファイルシステムとプロセスの権限をOpenCodeに付与します。実装では以下のことを行います:
OpenCodeのタスクのためにシェルを起動しない
作業ディレクトリとして、存在する絶対パスを要求する
キャプチャする出力を制限してCodexのコンテキストを保護する
タイムアウトまたはMCPのキャンセル時にOpenCodeのプロセスツリーを終了させる
委任された実行中はOpenCodeの自動更新を無効にする
MCPツールを非冪等かつ潜在的に破壊的なものとしてマークする
信頼できないタスクやリポジトリを委任する場合は、制限されたOSアカウントまたはサンドボックスを使用してください。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables Claude Code to delegate tasks to OpenAI's Codex CLI (GPT-5.4) with structured execution traces, parallel execution, session persistence, and adversarial code review.15MIT
- FlicenseNot gradedqualityCmaintenanceEnables ISLI agents and MCP clients to dispatch natural-language coding and terminal tasks to a locally-installed Claude Code CLI, supporting both one-shot execution and persistent sessions with workspace and security controls.
- AlicenseAqualityAmaintenanceEnables MCP clients like Claude Code and Codex to delegate coding tasks to Cursor's CLI agent, which implements changes in the workspace and returns clean, structured results for review.36994MIT
- AlicenseAqualityCmaintenanceEnables Codex/ChatGPT to coordinate OpenCode agents, managing tasks, sessions, parallel execution, and project context through 25 local tools.2510MIT
Related MCP Connectors
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
A paid remote MCP for OpenAI Codex agent coordination MCP, built to return verdicts, receipts, usage
A paid remote MCP for OpenAI Codex context compressor, built to return verdicts, receipts, usage log
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/TAO-MINGYU/codex_to_opencode'
If you have feedback or need assistance with the MCP directory API, please join our Discord server