# Connect Google Sheets to Codex via MCP

Codex can query a Google Sheet as a native tool through MCP. Add the hosted PasteSheet URL once, then use the same connection from the Codex CLI, IDE extension, or ChatGPT desktop app.

*Last updated: 2026-09-09 · Source: <https://pastesheet.com/guides/google-sheets-mcp-codex>*

## Key facts

- The **Codex CLI and IDE extension** support Streamable HTTP MCP servers and share their MCP configuration with the ChatGPT desktop app on the same Codex host. ([source](https://learn.chatgpt.com/docs/extend/mcp))
- Codex stores MCP servers in `~/.codex/config.toml`, or in `.codex/config.toml` for a trusted project. Remote servers support bearer tokens through `bearer_token_env_var`. ([source](https://learn.chatgpt.com/docs/extend/mcp))
- MCP is an **open protocol** built on JSON-RPC 2.0. A server exposes Resources, Prompts and Tools to any MCP client — Claude, Cursor, ChatGPT, VS Code and Windsurf all speak it. ([source](https://modelcontextprotocol.io/specification/2025-06-18))
- PasteSheet's MCP server exposes three tools — `list_tabs`, `get_schema` and `query_rows` — and is **read-only by design**: an agent can query your sheet but can never modify it.
- It needs **no Google Cloud project, no OAuth consent screen and no service-account JSON**. You paste a share URL, and MCP is included on the Free plan.

## Can Codex read a Google Sheet?

Yes. Codex supports remote MCP servers over Streamable HTTP, and PasteSheet turns a Google Sheet into one of those hosted endpoints. Add the endpoint URL to Codex and the agent can list tabs, inspect columns, and query rows while it works.

Start with a link-shared sheet, or connect Google and choose a restricted file in Picker. PasteSheet handles the spreadsheet connection and serves the MCP tools, so you do not create a Google Cloud project, install a local server, or paste rows into every prompt. For the protocol and product overview, see the [Google Sheets MCP server guide](https://pastesheet.com/guides/google-sheets-mcp).

## Connect in four steps

1. Create a PasteSheet endpoint from a public Google Sheet URL, or connect Google and select the exact restricted sheet in Picker.
2. Open the endpoint's **Connect via MCP** panel and copy its `/mcp/sheets/…` URL.
3. Run `codex mcp add pastesheet --url <MCP URL>`, or add the same URL to a project-scoped `.codex/config.toml`.
4. Confirm the server with `codex mcp list`. Then open Codex, run `/mcp`, and ask a question about your sheet.

## Add the server from the Codex CLI

Codex can register a hosted MCP server with one command. Replace the example endpoint id with the URL from PasteSheet:

```bash
codex mcp add pastesheet --url \
  https://pastesheet.com/mcp/sheets/your-endpoint-id
```

## Scope the connection to one project

Codex normally stores MCP settings in `~/.codex/config.toml`. For a trusted project that alone should use this sheet, put the server in `.codex/config.toml` instead:

```bash
[mcp_servers.pastesheet]
url = "https://pastesheet.com/mcp/sheets/your-endpoint-id"
```

## Authenticate a private endpoint

Keep the key out of the config file. Put it in an environment variable, then tell Codex which variable supplies the bearer token:

```bash
[mcp_servers.pastesheet]
url = "https://pastesheet.com/mcp/sheets/your-endpoint-id"
bearer_token_env_var = "PASTESHEET_API_KEY"
```

## Check that Codex can see the sheet

Run `codex mcp list` in your terminal to confirm that `pastesheet` is registered. Inside the Codex terminal UI, use `/mcp` to see the active server and its tools. The ChatGPT desktop app, Codex CLI, and Codex IDE extension share MCP configuration on the same Codex host.

Then ask something concrete, such as *“List the tabs and show me the newest ten active customers.”* Codex should inspect the schema before querying the rows. If it cannot connect, confirm that you copied the MCP URL rather than the REST API URL and that the bearer environment variable is available to the Codex process.

## The tools Codex gets

PasteSheet exposes three read-only tools, and Codex chooses the right one for each question:

- `list_tabs` discovers every tab and identifies the default one.
- `get_schema` returns clean column aliases and inferred types before a query runs.
- `query_rows` filters, searches, sorts, and paginates rows. Pro endpoints can also aggregate with `count`, `sum`, `avg`, and `group_by`.

## Why use a hosted, read-only connection?

A direct Sheets API integration makes every developer solve credentials, range parsing, rate limits, and hosting before the agent can read one row. PasteSheet packages that work behind one remote URL and caches the source, so repeated tool calls do not become repeated requests to Google.

The tool boundary is intentionally narrow. Codex can query and analyse the spreadsheet, but PasteSheet exposes no write or delete tool. A coding agent can use live reference data without gaining a path to modify the source sheet.

## Requirements

**MCP is included on the Free plan.** Connect any **public** endpoint over MCP with no Google Cloud project and no credit card. Private endpoints and the account-wide workspace server need a paid plan (from **Starter ($9/mo)**) for the keys and OAuth they authenticate with.

Pro adds full-text search and aggregation (`count`, `sum`, `avg`, `group_by`) that your AI agent can call through `query_rows`.

**Starter — $9/month.** For indie makers shipping a real app.

- Endpoints: 10
- Requests: 50,000 / month
- Rows per endpoint: 5,000
- Tabs per endpoint: 5
- Rate limit: 300 / minute

## Frequently asked questions

### How do I connect Google Sheets to Codex?

Create a PasteSheet endpoint, copy its MCP URL, and run codex mcp add pastesheet --url . Codex can then discover and call the sheet's read tools.

### Where does Codex store MCP configuration?

Codex uses ~/.codex/config.toml by default. A trusted project can use .codex/config.toml to keep the server scoped to that project.

### How do I use a private PasteSheet endpoint?

Set your PasteSheet key in an environment variable and configure bearer_token_env_var for the server. Codex sends it as an Authorization bearer token without storing the key in config.toml.

### How do I verify the MCP server is connected?

Run codex mcp list in the terminal, or /mcp inside the Codex terminal UI. Both show the configured server and its available tools.

### Can Codex edit my Google Sheet?

No. PasteSheet exposes list_tabs, get_schema, and query_rows only. There is no write or delete tool, so the source remains read-only.

### Do I need Google Cloud or a service account?

No. Use a link-shared sheet, or connect Google and select a restricted sheet in Picker. PasteSheet hosts the MCP server and handles reads for you.

## Sources

- [Model Context Protocol in Codex](https://learn.chatgpt.com/docs/extend/mcp) — OpenAI
- [Model Context Protocol specification](https://modelcontextprotocol.io/specification/2025-06-18) — Model Context Protocol

## Related guides

- [Google Sheets MCP Server for Claude & ChatGPT](https://pastesheet.com/guides/google-sheets-mcp) — Turn any public or private Google Sheet into an MCP server so Claude, Cursor, and ChatGPT can read and query it in plain English. No code, no backend.
- [Google Sheets MCP for Claude Code](https://pastesheet.com/guides/google-sheets-mcp-claude-code) — Add a Google Sheet to Claude Code as an MCP server with one command. Query spreadsheet data from your terminal-based agent — no backend and no code to write.
- [Google Sheets MCP Server for Cursor](https://pastesheet.com/guides/google-sheets-mcp-cursor) — Add a Google Sheet to Cursor as an MCP server so the editor's AI can query your spreadsheet while you code. No backend — copy one URL and you are connected.
- [Connect Google Sheets to ChatGPT via MCP](https://pastesheet.com/guides/google-sheets-mcp-chatgpt) — Connect a Google Sheet to ChatGPT using PasteSheet's workspace MCP server and OAuth. Let ChatGPT query your spreadsheet data in plain English, no code required.

---

[PasteSheet](https://pastesheet.com) turns any Google Sheet into a live REST API and MCP server for AI agents — no backend, no code. Canonical HTML version of this page: <https://pastesheet.com/guides/google-sheets-mcp-codex>
