codex-advisor
Adds a second-opinion advisor to OpenAI Codex CLI, enabling consultation with ChatGPT subscription, OpenAI API, Claude, Gemini, or OpenAI-compatible models during coding sessions.
README
codex-advisor
OpenAI Codex CLI に Claude Code の advisor 相当の「セカンドオピニオン」を追加する 個人用 MCP サーバー。既定では、ChatGPT でログイン済みの Codex CLI を介して GPT をサブスクリプション利用する。OpenAI API・Claude・Gemini、および OpenAI 互換エンドポイントの任意モデルにも切り替えられる。
公開範囲と利用条件
このリポジトリは公開準備中の実験的な個人用ツールです。公開しても、現時点で マルチユーザー対応、互換性の保証、運用サポート SLA は提供しません。
ライセンス: この個人開発ではライセンスを付与していません。リポジトリには
LICENSE ファイルを含めていません。
セットアップ
前提: Python 3.12以上、uv、Codex CLI 0.144.1以上。codex/ providerには
ChatGPTログインが必要。
bash install.sh # advisor.toml / advisor.env 作成 + MCP 登録 + AGENTS.md 誘導
codex login status # codex/ 利用時は Logged in using ChatGPT を確認
vi ~/.codex/advisor.env # API provider も使う場合だけ API キーを記入
install.sh は既存の advisor.toml を上書きしない。旧版から移行する場合は、
下記の model を手動で変更する。
使い方
- Codex が計画前・エラー反復時・完了宣言前に自動で
consult_advisorを呼ぶ - 手動相談: 「advisor に相談して」
- サブスクリプションGPT:
model = "codex/gpt-5.6-sol" - OpenAI API:
model = "openai/<Chat Completions 対応モデル ID>" - モデル切替: 「advisor を codex/gpt-5.6-sol にして」(または
~/.codex/advisor.tomlのmodel =を編集) - 無効化: 「advisor を off にして」または
advisor.tomlでenabled = false
codex/ と openai/ は同居できる。前者はChatGPTサブスクリプション、後者は
OPENAI_API_KEY のAPI従量課金である。1回の相談では model が示す一方だけを使い、
codex/ 失敗時に openai/ へ自動フォールバックしない。
設定 (~/.codex/advisor.toml)
enabled = true
model = "codex/gpt-5.6-sol" # "<provider>/<model>"。モデル名は無検証
max_context_chars = 400000 # advisor に渡す会話の上限(古い方から切り詰め)
max_consults_per_session = 20 # セッションあたり相談回数上限
reasoning = "medium" # 任意: low/medium/high/xhigh。デフォルトは medium。reasoning = "" でプロバイダ既定に戻せる
# OpenAI 互換エンドポイントの追加例(OpenRouter / ollama など)
[providers.openrouter]
kind = "openai"
base_url = "https://openrouter.ai/api/v1"
api_key_env = "OPENROUTER_API_KEY"
advisor.toml は相談ごとに読み直すため、モデル切替にMCP再起動は不要。
advisor.env はMCP起動時にだけ読むため、APIキーの追加・変更後はCodexセッションを
再起動する。
xhigh は codex/ と openai/ providerで利用できる。選択モデルが非対応の場合は
下流のCodex CLIまたはAPIがエラーを返し、値を自動変更しない。Anthropic/Geminiでは
意味の異なる値へ推測変換せず、相談実行前に明示的な非対応エラーを返す。
セキュリティ
API キーは ~/.codex/advisor.env のみに置く。codex/ の子プロセスには、
組み込み・カスタムproviderを含むadvisor用credentialを渡さない。子Codexは
一時directory、read-only sandbox、ephemeral sessionで実行し、shell・Web・MCP・
app・subagent等を無効化する。APIエラーに含まれる選択providerのキー値は伏せ字化する。
データ送信: consult_advisor は、現在のセッションから復元した user/assistant メッセージ、
tool call、tool result を、設定された advisor provider に送信します。codex/ では
ログイン中のChatGPT workspace、API providerでは各APIアカウントのデータ処理条件が
適用されます。transcript の秘密情報は自動除去されません。
開発
uv run pytest -q # テスト
uv run ruff check src tests && uv run pyright # lint+型
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.