ChatGPT Code
A secure, local-first MCP coding and computer-use harness for ChatGPT and Codex, enabling guarded file operations, durable terminals, Git review, local skills, and macOS computer control.
README
<p align="center"> <img src="docs/chatgpt-code-banner.png" alt="ChatGPT Code service dashboard" width="100%" /> </p>
<div align="center">
ChatGPT Code
A secure, local-first MCP coding and computer-use harness for ChatGPT and Codex.
Guarded files · durable terminals · Git review · local skills · MCP gateway · subagents · evaluators · macOS computer control
</div>
ChatGPT Code runs as a private MCP service on your own machine. Start one command, pair through OAuth, and give an AI client carefully scoped access to coding tools, long-running workflows, and visual computer control—without surrendering the workspace boundary.
chatgpt-code
The command starts:
- a Streamable HTTP MCP endpoint at
http://127.0.0.1:3939/mcp; - an authenticated legacy SSE compatibility endpoint at
http://127.0.0.1:3939/sse; - an OAuth 2.1 authorization server with PKCE and one-time terminal pairing;
- a private visual dashboard;
- a Cloudflare Quick Tunnel by default, printing a public HTTPS
/mcpURL.
Install
From this repository:
npm install
npm run build
npm link
chatgpt-code
Release-ready installation paths are included:
# npm, after publication
npm install --global chatgpt-code
# pip shim, after publication (Node.js 20+ is still required)
pip install chatgpt-code
# Homebrew tap, after publication
brew install HardikCoder45/tap/chatgpt-code
# curl installer
curl -fsSL https://raw.githubusercontent.com/HardikCoder45/chatgpt-code/main/install.sh | bash
This workspace contains the npm package, Python shim, Homebrew formula, curl installer, and GitHub release workflow. Publishing them requires your own npm/PyPI/GitHub/Homebrew credentials and repository URL; no external package was published automatically.
First run and ChatGPT connection
-
Start the service:
chatgpt-code -
Copy the printed public URL ending in
/mcp. -
In ChatGPT developer/plugin settings, add that MCP endpoint.
-
When the OAuth page opens, enter the pairing code printed in the terminal.
-
Rotate the pairing code whenever needed:
chatgpt-code auth rotate
The default Quick Tunnel URL changes on restart and is intended for personal development. Use a managed Cloudflare tunnel for a stable URL. Temporary tunnels should not be used for public plugin submission.
Prefer /mcp for ChatGPT and modern MCP clients. If a legacy client explicitly requires SSE, give it the same public origin ending in /sse; the SSE handshake advertises the authenticated /messages endpoint automatically.
Security model
ChatGPT Code is deliberately single-user and local-first:
- OAuth 2.1 authorization-code flow with S256 PKCE;
- dynamic client registration plus ChatGPT Client ID Metadata support;
- one-time pairing knowledge available only in the local terminal;
- Ed25519-signed 15-minute access tokens;
- resource/audience, issuer, expiry, revocation, and per-tool scope checks;
- OAuth Protected Resource Metadata and
WWW-Authenticatediscovery; - private dashboard token in an HttpOnly, SameSite cookie;
- workspace-root path allowlists with symlink escape checks;
- atomic file writes and patch path validation;
- state and signing keys stored under
~/.chatgpt-codewith user-only permissions; - tokens and pairing codes are never written to activity logs.
For a multi-user or publicly submitted service, replace the built-in single-user pairing authorization server with an established identity provider. OpenAI’s current guidance recommends OAuth 2.1 for authenticated MCP servers and advises using a mature identity provider for production deployments.
Tool surface
| Area | Tools |
|---|---|
| Files | workspace_roots, read_file, list_directory, search_files, write_file, edit_file |
| Terminal | run_command, start_command, terminal_status, terminal_input, terminal_stop |
| Git | git_status, git_diff, apply_patch |
| Skills | read_chatgpt_code_guide, list_skills, refresh_skills, read_skill, evaluate_skill, make_skill |
| MCP gateway | connect_mcp, list_connected_mcps, inspect_connected_mcp_tools, call_connected_mcp_tool, disconnect_mcp, plus dynamically proxied tools |
| Long-horizon harness | start_agent, agent_status, list_agents, cancel_agent, evaluate_workspace |
| Computer use | computer_screenshot, computer_click, computer_type, computer_key, computer_scroll |
| Visuals | Universal per-tool result UI, recent_activity, show_activity_dashboard |
Every tool carries safety annotations and an OAuth scope. File and command tools can only act inside configured workspace roots.
Every native tool and every dynamically connected MCP tool advertises the same versioned
ui://chatgpt-code/tool-result-v2.html MCP App resource. ChatGPT therefore renders tool
calls inline with a specialized view for code reads, directory listings, searches,
terminal sessions, unified diffs and patches, Git status, skills, agents, MCP connections,
computer screenshots, and activity timelines. Unknown result shapes use a structured,
collapsible JSON inspector instead of disappearing into plain text. A Raw tab remains
available for exact-output review.
The comprehensive single-file operating skill is packaged at skills/chatgpt-code/SKILL.md. It is also exposed through read_chatgpt_code_guide and the chatgpt-code://guide/SKILL.md MCP resource so an AI client can load the same workflow directly.
Local skills
At startup the service inventories SKILL.md files under:
~/.codex/skills~/.claude/skills~/.agents/skills~/.config/skills
The inventory exposes name, description, source, files, validity warnings, content, and a structural score. make_skill creates a new skill in a configured root; it never writes to an arbitrary directory.
Connect another MCP
ChatGPT can call connect_mcp, or you can seed entries in ~/.chatgpt-code/config.json.
Stdio:
{
"id": "github-local",
"name": "GitHub Local",
"transport": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"]
}
Streamable HTTP:
{
"id": "internal",
"name": "Internal Tools",
"transport": "http",
"url": "https://tools.example.com/mcp",
"headers": { "Authorization": "Bearer ..." }
}
Legacy SSE is supported with "transport": "sse". On connection, upstream tools are registered immediately as mcp_<connection>__<tool> and a tool-list-changed notification is emitted. Because ChatGPT developer-mode connections cache tool metadata, direct names may require Settings → Plugins → Refresh and a new conversation. In the current conversation, call inspect_connected_mcp_tools and then call_connected_mcp_tool; this stable bridge can invoke every newly imported tool without waiting for a catalog refresh. Disconnection removes the direct and bridged access.
Durable subagents and evaluators
start_agent runs the locally authenticated Codex CLI in workspace-write sandbox mode. Tasks are queued with a configurable parallelism limit and persisted under ~/.chatgpt-code/tasks.
An agent can be started with evaluator commands:
{
"prompt": "Implement the requested parser and its tests.",
"workspace": "/path/to/project",
"evaluationCommands": ["npm test", "npm run typecheck"]
}
The task is only marked complete when Codex exits successfully and every evaluator passes. Service restarts preserve completed task history and mark interrupted jobs clearly.
Cloudflare
Quick Tunnel
No key is required:
chatgpt-code --tunnel quick
Existing managed tunnel token
export CLOUDFLARE_TUNNEL_TOKEN="..."
export CHATGPT_CODE_PUBLIC_URL="https://code.example.com"
chatgpt-code --tunnel managed
Fully managed through the Cloudflare API
export CLOUDFLARE_API_TOKEN="..."
export CLOUDFLARE_ACCOUNT_ID="..."
export CHATGPT_CODE_HOSTNAME="code.example.com"
export CLOUDFLARE_ZONE_ID="..." # optional; enables automatic DNS
chatgpt-code --tunnel managed
The service creates or reuses a tunnel, writes its ingress configuration, optionally creates the proxied CNAME, retrieves the tunnel token, starts cloudflared, and updates the OAuth resource URL.
When managed mode is installed as a macOS service, ChatGPT Code stores only the fixed hostname and tunnel runtime token in ~/.chatgpt-code/cloudflare-managed.json with user-only 0600 permissions. If the Cloudflare API is used for first-time provisioning, the broader API token is removed from that runtime file after the tunnel token is obtained. The LaunchAgent can therefore reconnect to the same hostname after every login without depending on shell environment variables.
Background service
On macOS:
chatgpt-code service install --tunnel managed
chatgpt-code service status
chatgpt-code service uninstall
This installs a per-user LaunchAgent at ~/Library/LaunchAgents/com.openai.chatgpt-code.plist. Logs are written under ~/.chatgpt-code.
Command reference
chatgpt-code [serve] [options]
chatgpt-code doctor
chatgpt-code auth rotate
chatgpt-code config show
chatgpt-code service install|status|uninstall
Important options:
--workspace <path> allowed root; repeatable
--tunnel off|quick|managed
--public-url <https-url>
--stdio local stdio MCP mode
--home <path> private state directory
--no-open do not open the dashboard
Computer-use permissions
The built-in computer tools target macOS. The first click/type operation may prompt for Accessibility permission for your terminal or Node.js host. Screenshots require Screen Recording permission. These permissions remain under macOS control.
Development
npm install
npm run typecheck
npm test
npm run build
npm run dev -- --tunnel off
Run the MCP Inspector against http://127.0.0.1:3939/mcp. Because the endpoint is authenticated, use the Inspector’s OAuth flow.
Architecture
ChatGPT / Codex
│ OAuth 2.1 + PKCE
▼
Cloudflare HTTPS tunnel
│
▼
ChatGPT Code MCP ───── Universal per-tool UI / event stream
│
├── Guarded files, shell, Git, macOS computer control
├── Skill inventory from Codex / Claude / agent roots
├── Dynamic MCP clients (stdio / HTTP / SSE)
└── Durable Codex subagents + evaluator gates
License
MIT
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。