> For the complete documentation index, see [llms.txt](https://docs.zigpoll.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zigpoll.com/integrations/mcp/mcp-codex.md).

# Connect to Codex

Connect your Zigpoll surveys to the **OpenAI Codex CLI** as an MCP server using the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/). Once connected, Codex can read your survey responses, run analytics, and create surveys — straight from your terminal.

For other AI clients, see the [MCP overview](/integrations/mcp.md).

{% hint style="info" %}
Connecting to a remote MCP server over HTTP requires a recent version of the Codex CLI (with streamable HTTP support). Update Codex if the steps below don't match your version.
{% endhint %}

## Prerequisite: get your Zigpoll API key

1. Log into your [Zigpoll dashboard](https://app.zigpoll.com).
2. Go to **Settings → Manage Integrations**.
3. Scroll to **API Key**, click **Add Key** under **Private Keys**, label it "Codex", and copy it.

## Step 1: Add Zigpoll to your Codex config

Open `~/.codex/config.toml` and add a server entry:

```toml
[mcp_servers.zigpoll]
url = "https://mcp.zigpoll.com/mcp"
```

## Step 2: Authenticate

Run the OAuth login from your terminal:

```bash
codex mcp login zigpoll
```

A browser window opens. Paste the API key from the prerequisite step on the Zigpoll authorization page and click **Authorize**. Codex stores a secure token, so you only do this once.

{% hint style="info" %}
`mcp.zigpoll.com` authenticates through a browser-based OAuth flow. A static `bearer_token` / `Authorization` header will not work — use `codex mcp login` as shown above.
{% endhint %}

## Step 3: Verify your connection

Start Codex and ask:

> "List my Zigpoll accounts"

Codex will use the Zigpoll tools automatically to fetch your data.

## Example prompts

* "Summarize the responses for my NPS survey from the last 30 days"
* "What are the daily response trends for my customer satisfaction survey?"
* "Correlate my NPS scores with purchase type"
* "Create a new NPS survey for my account"

For the full list of tools and more examples, see the [MCP overview](/integrations/mcp.md). For ideas on what to build, see [Ideas for Using Zigpoll MCP](/tutorials/zigpoll-mcp-use-cases.md).

## Troubleshooting

* **Server not connecting** — confirm your Codex version supports remote (streamable HTTP) MCP servers, and that the `url` in `config.toml` is exactly `https://mcp.zigpoll.com/mcp`.
* **Authentication errors** — re-run `codex mcp login zigpoll` with a valid API key that hasn't been revoked. Regenerate one from **Settings → Manage Integrations → API Key** if needed.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.zigpoll.com/integrations/mcp/mcp-codex.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
