chatgpt-context-mcp
Imports private ChatGPT conversation context, fetching remote conversations via the ChatGPT web backend API and caching them locally for use in MCP clients.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@chatgpt-context-mcp import conversation https://chatgpt.com/c/abc123"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ChatGPT Context MCP
A local stdio MCP server for importing private ChatGPT conversation context into Codex, Claude Code, and other MCP clients.
Disclaimer
This is an unofficial project. It is not maintained, endorsed, or supported by OpenAI.
This tool uses private, non-public ChatGPT web backend APIs. The behavior was inferred from web traffic and may change, break, or return incomplete data at any time. This project is provided only for technical research, personal context migration, and local MCP experimentation.
No guarantees are made about correctness, reliability, stability, completeness, legality, compliance, or fitness for any purpose. You are responsible for your own use, including token handling, data privacy, local laws, organization policy, and relevant service terms. Bearer tokens are sensitive temporary credentials and should be handled like passwords. Use at your own risk.
Related MCP server: ChatCrystal
Features
Imports private ChatGPT conversation URLs into MCP clients.
Refreshes remote conversation content by default before returning context.
Caches JSON, Markdown, messages, and metadata locally.
Supports cache-only reads for previously imported conversations.
Provides MCP tools and cache-backed resources.
Documents setup for Codex and Claude Code.
Supported Scope
Supported:
https://chatgpt.com/c/{conversation_id}
https://chat.openai.com/c/{conversation_id}Not supported:
Shared links such as
https://chatgpt.com/share/{share_id}ChatGPT Projects
Bulk history export
Attachment, image, or Canvas downloads
Browser automation or cookie extraction
How It Works
import_chatgpt_url parses a private ChatGPT conversation URL, fetches the full remote conversation through ChatGPT's web backend API, compares a stable content hash with local metadata, updates the cache when content changed, and returns bounded Markdown/messages/JSON to the MCP client.
get_chatgpt_context reads local cache only. It does not check the remote conversation.
Install From Source
Requirements:
Node.js 20+
npm
git clone https://github.com/OWNER/chatgpt-context-mcp.git
cd chatgpt-context-mcp
npm install
npm run buildRun checks:
npm run checkToken Setup
Get a fresh ChatGPT web bearer token from your browser DevTools. Do not paste tokens into agent chat or commit them to config files.
You can provide credentials through the current process environment:
export CHATGPT_BEARER_TOKEN="<chatgpt-bearer-token>"
export CHATGPT_ACCOUNT_ID=""For desktop apps, use the wrapper script with a private fallback env file:
mkdir -p "$HOME/.config/chatgpt-context-mcp"
chmod 700 "$HOME/.config/chatgpt-context-mcp"
cat > "$HOME/.config/chatgpt-context-mcp/env" <<'EOF'
export CHATGPT_BEARER_TOKEN="<chatgpt-bearer-token>"
export CHATGPT_ACCOUNT_ID=""
EOF
chmod 600 "$HOME/.config/chatgpt-context-mcp/env"The wrapper uses this precedence:
Existing process environment variables.
Values from
$HOME/.config/chatgpt-context-mcp/env.
Set CHATGPT_CODEX_MCP_ENV_FILE to point at a different env file.
Codex Configuration
Built mode:
[mcp_servers.chatgpt_context]
command = "<repo-path>/scripts/start-mcp.sh"
args = []
env_vars = ["CHATGPT_BEARER_TOKEN", "CHATGPT_ACCOUNT_ID", "CHATGPT_CODEX_MCP_CACHE_DIR", "CHATGPT_CODEX_MCP_ENV_FILE"]
startup_timeout_sec = 10
tool_timeout_sec = 120
default_tools_approval_mode = "auto"Development mode:
[mcp_servers.chatgpt_context]
command = "npm"
args = ["run", "start:mcp", "--prefix", "<repo-path>"]
env_vars = ["CHATGPT_BEARER_TOKEN", "CHATGPT_ACCOUNT_ID", "CHATGPT_CODEX_MCP_CACHE_DIR"]
startup_timeout_sec = 10
tool_timeout_sec = 120
default_tools_approval_mode = "auto"Restart Codex or open a new session after changing MCP configuration.
Claude Code Configuration
Configure this as a stdio MCP server:
{
"mcpServers": {
"chatgpt_context": {
"command": "<repo-path>/scripts/start-mcp.sh",
"args": [],
"env": {
"CHATGPT_CODEX_MCP_ENV_FILE": "$HOME/.config/chatgpt-context-mcp/env"
}
}
}
}Client-specific UI and config locations may vary. The server itself is a standard stdio MCP server.
MCP Tools
import_chatgpt_url: Fetches a private ChatGPT conversation URL from the remote API by default, updates cache when content changed, and returns bounded context.get_chatgpt_context: Reads a cached conversation. Does not access the network.list_chatgpt_imports: Lists locally cached imports.verify_chatgpt_auth: Checks token presence, expiration, account id detection, and lightweight API access.
MCP Resources
Cache-backed resources:
chatgpt://conversation/{conversation_id}/metadata
chatgpt://conversation/{conversation_id}/markdown
chatgpt://conversation/{conversation_id}/messages
chatgpt://conversation/{conversation_id}/jsonResource reads are cache-only and do not refresh remote content.
Cache and Privacy
Imported conversations are cached as plaintext under:
$HOME/.cache/chatgpt-context-mcp/Override the cache location:
export CHATGPT_CODEX_MCP_CACHE_DIR="/path/to/cache"Cache files may contain private prompts, assistant replies, code, and other sensitive content. The server does not write bearer tokens to disk.
Troubleshooting
If verify_chatgpt_auth fails:
Confirm
CHATGPT_BEARER_TOKENis available to the MCP server.Refresh the bearer token if it expired.
For Team or Enterprise accounts, set
CHATGPT_ACCOUNT_IDif auto-detection fails.Restart the MCP client after changing config or environment variables.
If import_chatgpt_url returns UNSUPPORTED_URL, use a private /c/{conversation_id} URL rather than a /share/{share_id} URL.
If remote access fails but cache exists, the error includes cache_available: true. Use get_chatgpt_context only when stale cached context is acceptable.
Development
npm install
npm test
npm run typecheck
npm run build
npm run checkRun the server locally:
npm run start:mcpLicense
MIT
Available Tools
4 toolsget_chatgpt_contextGet Cached ChatGPT ContextA
Read an already imported ChatGPT conversation from local cache. This does not check the remote conversation.
Inputs: conversation_id (required), format, max_chars.
import_chatgpt_urlImport ChatGPT URLC
Refresh and import a private ChatGPT /c/{conversation_id} URL into local cache and return bounded context.
Inputs: url (required), format, max_chars, cache_policy.
list_chatgpt_importsList ChatGPT ImportsA
List locally cached ChatGPT conversation imports, optionally filtered by a simple text query.
Inputs: query, limit.
verify_chatgpt_authVerify ChatGPT AuthA
Check whether CHATGPT_BEARER_TOKEN is present, unexpired, and accepted by the ChatGPT backend.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool serves a distinct function: fetching cached context, importing/refreshing from URL, listing imports, and verifying authentication. No overlap in purpose.
All tools follow a consistent verb_noun pattern with snake_case and a 'chatgpt_' prefix, making the API predictable and easy to understand.
Four tools cover the core operations for managing ChatGPT context (auth, import, retrieve, list) without being excessive or insufficient for the domain.
The set covers the main workflows (auth, import, read cached, list), but lacks a delete or remote fetch tool, which could be minor gaps in advanced usage.
Maintenance
Related MCP Connectors
Share one project context across ChatGPT, Claude, Telegram and any MCP client.
Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
Connect ChatGPT and Claude to your Mac, Windows or Linux with secure MCP remote access.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceSyncs AI conversations from multiple platforms to local Markdown files for your second brain, and provides browser automation tools via MCP for agentic workflows.AGPL 3.0
- AlicenseAqualityBmaintenanceLocal-first AI PKM memory server for coding conversations. Imports Claude Code, Cursor, Codex CLI, Trae, and GitHub Copilot chats into notes, semantic search, tag graphs, Markdown exports, and MCP memory tools.7121 npm62Apache 2.0
- AlicenseNot gradedqualityDmaintenanceCapture, index, and search your Claude Code conversation history. Provides an MCP server for Claude Code to query its own past conversations.2 npm1MIT
- AlicenseNot gradedqualityDmaintenanceProvides MCP tools and a local HTTP API to incrementally synchronize Codex conversations into a structured thinking canvas with AI-automated picking and manual override.MIT