ask-chat-mcp
An MCP server that queries ChatGPT via the Codex CLI with real file context, read-only, and no length limits, enabling second opinions grounded in actual files.
README
ask-chat-mcp
An MCP server that lets Claude confer with ChatGPT directly — one specialist to another, grounded in the actual files, read-only, with no size limit in either direction.
Built for delegation, not review. When a problem is genuinely technical — the mathematics behind a model, whether a derivation holds, a design whose tradeoffs have to be argued out — the useful move is to put two capable models on it together and have them report what they concluded. Not to route every exchange through a person who must then adjudicate a subject neither of them is pitching at them.
So both sides talk at full technical depth. Nothing is explained down for a bystander, because there isn't one in the loop: the person delegated the question precisely so they would not have to sit in the middle of it.
flowchart TD
You([You]) -->|"'Ask Chat'"| Claude[Claude]
Claude -->|"the problem + file PATHS"| MCP["ask-chat MCP server"]
MCP -->|"codex exec --sandbox read-only"| Codex[Codex CLI]
Codex -->|"opens the files itself"| Repo[("your repo, read-only")]
Codex <-->|"one thread, kept open"| GPT["ChatGPT (your subscription)"]
GPT -->|"answer + what context it still needs"| Codex
Codex -->|"full answer, nothing truncated"| MCP
MCP -->|"arrives as if YOU wrote it"| Claude
Claude -->|"what Claude makes of it"| You
Three things that diagram is meant to make obvious:
- Paths cross the boundary, never file contents. ChatGPT opens the files itself, so there is no payload to budget and nothing to truncate.
- Every reply says what context it still needed. Supplying that and asking again is the normal path, not an error case — a confident answer resting on a silent assumption is the failure this prevents.
- The reply returns as your turn, not as a report. Claude answers it the way it would answer you.
Table of Contents
- Why not automate the ChatGPT desktop app
- Requirements
- Install
- Tools
- Configuration
- Design notes
- Limitations
Why not automate the ChatGPT desktop app
The obvious approach — drive the desktop app's window, paste a prompt, scrape the reply — is what the well-known MCP servers in this space do. It is a dead end for this use case, and it is worth being explicit about why, because the reasons are not obvious until you have built it:
- The prompt has a practical ceiling. It arrives by clipboard paste into the composer, and large pastes are silently truncated. Roughly 12k characters is the safe budget. That is not enough for a real question plus the documents it depends on.
- The reply is truncated too, and worse, invisibly. It has to be read back out of the app's accessibility tree, and a virtualized scroll container does not keep offscreen content there. A long answer comes back partial with no indication that it did.
- It takes over your screen. The window must be focused and keystrokes sent to it. You cannot type while it runs, and one call at a time is the hard limit.
- It breaks on UI changes, because the rendered accessibility tree is not an interface anyone promised to keep stable.
Driving the Codex CLI instead removes all four. It runs headless, reads files directly off disk, and returns its answer on stdout. Crucially it authenticates with a ChatGPT subscription, so this is not the OpenAI API with per-token billing — it is the plan you already pay for.
Requirements
- Node.js 18+
- Codex CLI, signed in with your ChatGPT account:
npm install -g @openai/codex
codex login # choose "Sign in with ChatGPT"
Install
git clone https://github.com/spe-investigator/ask-chat-mcp.git c:\src\ask-chat-mcp
cd c:\src\ask-chat-mcp
.\install.ps1 -DefaultCwd c:\src\YourProject
install.ps1 verifies prerequisites, builds, reports whether Codex is installed and signed in, and registers the server with Claude Code. Idempotent — re-run after a pull.
Restart Claude Code and confirm with /mcp.
Tools
ask_chatgpt
| Parameter | Required | Meaning |
|---|---|---|
question |
yes | The problem, framed to stand alone for someone who has not seen this codebase. Write at full technical depth — the reader is another specialist |
files |
no | Paths relative to cwd to point ChatGPT at. Reference whole files freely — they are read, not pasted |
cwd |
no | Directory it reads from. File access is confined to this tree |
session |
no | Thread control — see below. Omit for the normal case |
model |
no | e.g. gpt-5.5. Omit for the Codex default |
timeout_seconds |
no | Defaults to 300 |
Pass paths, not contents. That is the whole point: there is no payload budget to spend, so send the actual files.
files is a pointer, not a whitelist. It says start here; ChatGPT can and does open anything else it needs within cwd, and will tell you when it did. So an incomplete list degrades gracefully rather than producing a wrong answer — cwd is the real boundary.
Threads
By default the first call in a session starts a Codex thread and every later call continues it, so ChatGPT keeps the context of what you already discussed rather than meeting each question cold.
The session boundary is the server process. An MCP client spawns a stdio server per session, so the thread is held in memory and needs no registry keyed by repo or client: a new session starts clean, and two concurrent sessions get independent threads instead of trampling a shared one.
session |
Effect |
|---|---|
| omitted | Continue this session's thread, starting one if there is none |
new |
Deliberately start a clean thread |
last |
Pick up the most recent thread in this directory from an earlier session |
| a thread id | Resume that specific thread |
last is directory-scoped because Codex filters recorded sessions by working directory unless told otherwise.
chatgpt_status
Reports whether Codex is installed and signed in, and which thread this session is on. Check it before relying on ask_chatgpt, and to explain a failure without guessing.
Configuration
| Variable | Default | Purpose |
|---|---|---|
ASK_CHAT_DEFAULT_CWD |
server's cwd | Directory used when a call does not name one |
ASK_CHAT_TIMEOUT_SECONDS |
300 |
Default timeout |
ASK_CHAT_MODEL |
Codex default | Default model |
ASK_CHAT_CODEX_BIN |
codex |
Path to the Codex binary |
CODEX_HOME |
~/.codex |
Where Codex keeps credentials |
Design notes
Read-only. Codex is a coding agent that can edit files. A consulting specialist that can rewrite your working tree is a liability, not a feature. codex exec already defaults to a read-only sandbox, and on a fresh thread an explicit --sandbox read-only is passed as well, so the guarantee does not rest on a default staying put. On a resumed thread the flag is unavailable — see below.
Every reply reports its own sufficiency. The prompt asks ChatGPT to state explicitly whether the context it received was enough, to name precisely what it still wanted — a file, a definition, a measurement, a constraint — and to flag which parts of its answer rest on an assumption it had to make. This matters more than it sounds: the failure mode of a well-briefed model is not refusing to answer, it is answering confidently around a gap nobody knew was there. Naming the gap makes the next call trivial, since supplying a file costs a path.
No flag is passed on faith. The installed build is probed once, and optional flags are used only if it advertises them. Codex is moving quickly; guessing at its interface would make this brittle for no benefit.
exec and exec resume are probed separately, because they do not accept the same options — resume rejects --sandbox and --cd outright. Assuming one flag set for both produces a call that dies in argument parsing instead of doing anything, which is how this was found. On a resumed thread the read-only guarantee therefore rests on codex exec's default plus the policy the thread was created under, rather than on a second explicit flag; the working directory comes from the spawned process either way.
Neither direction has a length limit. The prompt goes in on stdin using codex exec -, so it never touches a command line and cannot hit the ~32k argument ceiling. The answer comes back through --output-last-message, read from a file rather than parsed out of a stream that also carries progress output. Progress goes to stderr and is kept for diagnostics.
Windows shim handling. npm installs codex as a .cmd shim, which Node refuses to spawn directly since the 2024 argument-injection fix. A failed direct spawn is retried through the shell. Because the prompt travels on stdin rather than argv, that retry is not a quoting hazard for the one input that is arbitrary text.
Limitations
- Codex must be signed in.
codex loginis an interactive browser flow; it cannot be automated, andchatgpt_statuswill tell you when it has lapsed. - File access is confined to
cwd. Deliberate. Point it at the repo root you want reviewed. - It is not fast. A substantive answer over real files takes tens of seconds. The default timeout is five minutes.
- A thread lives and dies with the session. Restarting the client starts a fresh thread.
session: "last"picks the previous one back up, but there is no listing of prior threads to choose from. - Threads are not visible in ChatGPT. Codex records them under
~/.codex/sessions/as JSONL; they do not appear in the ChatGPT sidebar or Projects. Nothing about this design can change that (openai/codex#21079).
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。