Skip to main content
Glama
ChatGPT Web MCP
by nekh4ett
README.md
# ChatGPT Web MCP

Ask ChatGPT from your coding agent. The agent sends a prompt, with screenshots and files if needed, into a
conversation of **your own** chatgpt.com account and gets back the answer and the images ChatGPT made: no browser
window, no API key, no copy and paste.

**Claude Code · Codex · any MCP client with stdio · Node.js 22+ · zero dependencies**

[Install with your agent](#install-with-your-agent) · [Manual setup](#manual-setup) · [Tools](#tools) · [Sign-in](#sign-in) · [Good to know](#good-to-know) · [Troubleshooting](#troubleshooting)

```text
you    › ask ChatGPT for three layout options for the settings screen, then compare them with ours
agent  › chatgpt_send(text: "…brief…")
         → answer, https://chatgpt.com/c/…, conversation_id
agent  › chatgpt_send(conversation: "<conversation_id>", text: "make option 2 denser",
                       files: ["/abs/path/current-screen.png"], download_dir: "/abs/path/references")
         → answer + the generated mockup saved as /abs/path/references/Settings mockup-1a2b3c.png
```

The chat is a normal ChatGPT conversation: open the returned link in your browser and continue it there, or hand
the agent a `https://chatgpt.com/c/…` link of a chat you started and let it read or continue that one.

## Install with your agent

Paste this into Claude Code, Codex or another coding agent:

> Install ChatGPT Web MCP from https://github.com/nekh4ett/chatgpt-web-mcp — read its `AGENTS.md`, follow the
> steps for the client we are using, and show me what the readiness check printed.

The agent checks Node.js and your ChatGPT sign-in, registers the server and verifies it. The steps it follows are in
[`skills/chatgpt-web-mcp/SKILL.md`](skills/chatgpt-web-mcp/SKILL.md), which also works as an
[Agent Skill](https://agentskills.io) in clients that support skills.

## Manual setup

First check that your sign-in works. Nothing is installed and nothing is sent to a chat:

```sh
npx -y github:nekh4ett/chatgpt-web-mcp --check
```

`Ready · N models · …` means you can register the server. `Not ready · …` says what is missing: see [Sign-in](#sign-in).

<details open>
<summary><strong>Claude Code</strong></summary>

```sh
claude mcp add --scope user chatgpt-web -- npx -y github:nekh4ett/chatgpt-web-mcp
claude mcp get chatgpt-web
```

</details>

<details>
<summary><strong>Codex</strong></summary>

```sh
codex mcp add chatgpt-web -- npx -y github:nekh4ett/chatgpt-web-mcp
codex mcp get chatgpt-web
```

Codex stops an MCP tool call after 60 s by default. For answers that take longer, add a limit to the entry it
created in `~/.codex/config.toml`:

```toml
[mcp_servers.chatgpt-web]
tool_timeout_sec = 1800
```

</details>

<details>
<summary><strong>Other clients (Cursor, Windsurf, Zed, your own)</strong></summary>

Add a stdio server to the client's MCP configuration:

```json
{
  "mcpServers": {
    "chatgpt-web": {
      "command": "npx",
      "args": ["-y", "github:nekh4ett/chatgpt-web-mcp"]
    }
  }
}
```

</details>

<details>
<summary><strong>From a clone, without npx</strong></summary>

```sh
git clone https://github.com/nekh4ett/chatgpt-web-mcp.git
node chatgpt-web-mcp/src/chatgpt-mcp.cjs --check
claude mcp add --scope user chatgpt-web -- node "$PWD/chatgpt-web-mcp/src/chatgpt-mcp.cjs"
```

There is nothing to build and no `npm install`: the server is two files that use only Node.js built-ins.

</details>

Start a new session after registering: MCP servers load when a session starts.

## Tools

| Tool | Arguments | What you get |
| --- | --- | --- |
| `chatgpt_send` | `text`, `files?` (absolute paths), `conversation?` (URL or id), `model?`, `download_dir?`, `timeout_seconds?` | The full answer, the chat URL, `conversation_id`, the model that answered and timings, plus the images and files ChatGPT produced (saved to `download_dir` when given). Without `conversation` it starts a new chat. |
| `chatgpt_read` | `conversation`, `limit?` | The last messages of a chat with roles and ids, and the ids of attached or generated images and files. Works for chats you started in the browser too. |
| `chatgpt_download` | `conversation`, `file_id?`, `dir?` | Saves images and files of a chat to disk and returns the paths. Without `file_id`: everything ChatGPT produced in the latest turn. |
| `chatgpt_models` | — | The model slugs your account can use. |
| `chatgpt_check` | `conversation` | Confirms the chat is reachable and shows its last message. Sends nothing. |

## Sign-in

The server uses your own ChatGPT access token and looks for it in this order:

1. The environment variable `CHATGPT_ACCESS_TOKEN`.
2. The file `~/.codex/auth.json` (or `$CODEX_HOME/auth.json`), which [Codex CLI](https://github.com/openai/codex)
   writes when you sign in with a ChatGPT account:

   ```sh
   npm install -g @openai/codex
   codex login          # choose "Sign in with ChatGPT"
   ```

Codex keeps that token fresh while you use it. If the check says the token expired, run `codex login` again.
A Codex login with an API key has no ChatGPT token and does not work here.

The token stays on your machine. The server reads it for each request and sends it to `chatgpt.com` only. It writes
no files, collects no telemetry and has no dependencies you would have to trust.

## Good to know

- **It is your account.** Every send appears in your ChatGPT history, follows your account's data settings and
  counts against your plan's limits.
- **Images and files go both ways.** Attach local images (png, jpg, gif, webp: the model sees them) and documents
  (pdf, md, txt, csv, docx and others) with `files`. Images ChatGPT generates and files attached in a chat are
  saved to disk with `download_dir` or `chatgpt_download`. Not covered yet: files that ChatGPT writes in its code
  sandbox (`sandbox:/…` links) and tool calling.
- **Unofficial.** The server talks to the same backend as the ChatGPT web app and follows its handshake. When
  ChatGPT changes that handshake, sends fail with 403 until this repository is updated. There is no guarantee it
  keeps working, and automated use may be restricted by OpenAI's terms for your account: decide for yourself
  whether that is acceptable for your use.
- **Long answers.** `chatgpt_send` waits up to 300 s by default; pass `timeout_seconds` up to 1800 for slow models.
  After a timeout, read the chat before sending again: the message may have landed.

This is an independent project. It is not affiliated with or endorsed by OpenAI. ChatGPT is a product of OpenAI.

## Troubleshooting

| Symptom | What to do |
| --- | --- |
| `Not ready · No ChatGPT sign-in found` | Run `codex login` with a ChatGPT account, or set `CHATGPT_ACCESS_TOKEN`. |
| `Not ready · … holds no ChatGPT access token` | Codex is signed in with an API key. Run `codex login` and choose ChatGPT. |
| `… -> 401` | The token expired or was revoked. Run `codex login` again. |
| `… -> 403` on send, while read works | ChatGPT changed its handshake or blocked the request. Update to the latest version; if it still fails, open an issue. |
| The `chatgpt_*` tools are missing | Check the client's MCP list (`/mcp`), make sure `node --version` is 22 or newer, and start a new session. |
| `… failed: …` with a network error | Check that `https://chatgpt.com` opens from this machine. Behind an HTTP proxy, start the client with `NODE_USE_ENV_PROXY=1` and `HTTPS_PROXY` set (works on Node.js 22.22 and newer). |

Remove it with `claude mcp remove --scope user chatgpt-web` or `codex mcp remove chatgpt-web`.

## Contributing

Issues and pull requests are welcome. For a bug, include your operating system, Node.js version, MCP client and
the error text. Never post a token, an `auth.json` or a private conversation link.

Changes keep the server dependency-free. Before opening a pull request, run `node src/chatgpt-mcp.cjs --check` and
one real `chatgpt_send` into a fresh chat. Rules for agents working on this repository are in [`AGENTS.md`](AGENTS.md).

## License

[MIT](LICENSE)