An MCP server that lets AI coding agents consult other AI coding agents. Give Claude (or any MCP-compatible client) access to OpenAI Codex CLI, Opencode, and Claude Code as second-opinion tools.
Exposes a single MCP tool — get_second_opinion — that:
- Sends a prompt to Codex, Opencode, or Claude
- Waits for the agent to respond (with a configurable timeout)
- Writes the response to a
.mdfile - Returns the file path so the caller can read it
Note: No response body is returned inline. The caller must read the returned file path.
This server shells out to external CLI tools. Each call spawns a subprocess that may read and write files within the specified working_directory.
Flags used per agent:
| Agent | Flags |
|---|---|
codex |
--full-auto --ephemeral --skip-git-repo-check |
opencode |
--dangerously-skip-permissions |
claude |
-p --output-format text --dangerously-skip-permissions |
These flags allow the agents to operate autonomously without interactive prompts. Only point them at directories you're comfortable with them accessing.
Bun:
curl -fsSL https://bun.sh/install | bashCodex CLI (requires Node 22+):
npm install -g @openai/codexOpencode CLI:
curl -fsSL https://opencode.ai/install | bashClaude Code CLI:
npm install -g @anthropic-ai/claude-codeCodex uses your OPENAI_API_KEY environment variable:
export OPENAI_API_KEY=sk-...Opencode has its own auth flow — run it once interactively to configure:
opencodeClaude Code uses your Anthropic API key or OAuth:
export ANTHROPIC_API_KEY=sk-ant-...Or run claude auth to authenticate interactively.
bun install
bun run buildThis produces dist/second-opinion — a compiled binary. It still requires codex, opencode, and/or claude to be available on $PATH at runtime.
Add to your MCP client config (e.g. Claude Code ~/.claude/settings.json):
{
"mcpServers": {
"second-opinion": {
"command": "/path/to/dist/second-opinion"
}
}
}Or run directly without building:
{
"mcpServers": {
"second-opinion": {
"command": "bun",
"args": ["run", "/path/to/src/index.ts"]
}
}
}| Parameter | Type | Default | Description |
|---|---|---|---|
prompt |
string |
— | Question, code snippet, or task to send |
agent |
"codex" | "opencode" | "claude" |
"codex" |
Which agent to consult |
working_directory |
string |
server's cwd | Directory the agent runs in. Agents may read/write files here. Must exist on disk. |
timeout_seconds |
number |
120 |
Max seconds to wait (1–3600) |
output_directory |
string |
system temp | Where to write the response file. Created automatically if omitted. If provided, must already exist. |
Returns: The path to a .md file containing the agent's response.
On error: Returns isError: true. The response may still include a file path — check it, as partial output may have been written (e.g. on timeout).
<!-- agent: codex | duration: 12.3s | exit: 0 | generated: 2026-01-01T00:00:00.000Z -->
[agent response here]
On timeout the status line will show TIMED OUT instead of an exit code. The body may contain partial output.
Request:
{
"prompt": "What's the most likely cause of an off-by-one error in a binary search?",
"agent": "codex",
"working_directory": "/my/project",
"timeout_seconds": 60
}Success response:
/tmp/second-opinion-codex-1234567890-ab12cd34.md
Read that file to see the agent's answer.
| Symptom | Fix |
|---|---|
Error spawning codex: ... |
codex not on $PATH. Install it and verify with which codex. |
Error spawning opencode: ... |
opencode not on $PATH. Install it and verify with which opencode. |
Error spawning claude: ... |
claude not on $PATH. Install it and verify with which claude. |
| Agent exits with no output | CLI not authenticated. Run codex, opencode, or claude auth interactively once to check. |
TIMED OUT in response file |
Increase timeout_seconds or simplify the prompt. |
Directory does not exist error |
Supplied working_directory or output_directory doesn't exist on disk. |
bun run start # Run without building
bunx biome check # Lint + format check
bunx biome check --write # Auto-fixPre-commit hook runs Biome automatically via Husky + lint-staged.
MIT