PasteSheet icon PasteSheet logo mark — a spreadsheet grid with a curly brace on a green rounded square PasteSheet

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

Looking for the general setup? Start with the Google Sheets MCP server guide.

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
  • 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
  • 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
  • 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.

Connect in four steps

  1. 1 Create a PasteSheet endpoint from a public Google Sheet URL, or connect Google and select the exact restricted sheet in Picker.
  2. 2 Open the endpoint's Connect via MCP panel and copy its /mcp/sheets/… URL.
  3. 3 Run codex mcp add pastesheet --url <MCP URL>, or add the same URL to a project-scoped .codex/config.toml.
  4. 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:

terminal
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:

.codex/config.toml
[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:

.codex/config.toml
[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

For indie makers shipping a real app.

$9 /mo
Endpoints
10
Requests / mo
50,000
Row cap
5,000
  • MCP for AI agents

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 <MCP 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

Related guides

Turn your sheet into an API in minutes

Paste a Google Sheet URL and get a live REST API and MCP server — no backend, no code, free to start.