# ChatGPT, OpenAI API & Codex

Use the Data MCP server from ChatGPT, from your own app through the OpenAI Responses API or Agents SDK, and from the Codex CLI.

## ChatGPT

ChatGPT connects to remote MCP servers through developer mode and apps. Developer mode is available to Business, Enterprise and Edu workspaces on the web and must be enabled by a workspace admin; check OpenAI's help center for the current menu path.

**ChatGPT cannot send an API key.** It supports OAuth or no authentication only, so the connection is always made with OAuth and is always **live**.

1. In ChatGPT, create a custom connector or app for the MCP server URL `https://data-services.autouncle.com/mcp` and choose **OAuth**.
2. ChatGPT registers itself through dynamic client registration (AutoUncle does not publish a client ID metadata document).
3. Sign in with your AutoUncle account, choose the organization and approve the scopes.

Each successful valuation uses one of the organization's credits. Approve `catalogue:read` and `account:read` without `valuations:write` if you only want ChatGPT to look up vehicles.

## Responses API

The Responses API can call a remote MCP server for you. Send the key in `headers`, keep it in your backend, and decide when tools may run without approval:

```python
import os

from openai import OpenAI

client = OpenAI()
response = client.responses.create(
    model="your-model",
    input="Value a 2020 Volkswagen Golf in Denmark with 60,000 km. Report the price basis, currency, 80% interval and precision grade.",
    tools=[
        {
            "type": "mcp",
            "server_label": "autouncle-data",
            "server_url": "https://data-services.autouncle.com/mcp",
            "headers": {"Authorization": f"Bearer {os.environ['AUTOUNCLE_API_KEY']}"},
            "allowed_tools": ["get_account", "search_vehicles", "valuate_car", "get_valuation"],
            "require_approval": {"never": {"tool_names": ["get_account", "search_vehicles", "get_valuation"]}},
        }
    ],
)
print(response.output_text)
```

- `headers` is sent to the MCP server on every call. Use a test key while you build.
- `require_approval` defaults to requiring approval for every tool call. The example lets the free, read-only tools run directly and keeps approval for `valuate_car`, which spends a credit with a live key.
- `allowed_tools` limits which tools the model sees.
- If your app runs the OAuth flow itself, pass the access token as `authorization` instead of an `Authorization` header.

Replace `your-model` with the model you use.

## Agents SDK

In the OpenAI Agents SDK for Python, connect to the server over Streamable HTTP from your own process:

```python
import os

from agents.mcp import MCPServerStreamableHttp

autouncle = MCPServerStreamableHttp(
    params={
        "url": "https://data-services.autouncle.com/mcp",
        "headers": {"Authorization": f"Bearer {os.environ['AUTOUNCLE_API_KEY']}"},
    }
)
```

Pass the server to your agent's `mcp_servers` and use it inside `async with autouncle:` as the SDK documentation shows. The SDK also offers `HostedMCPTool`, which runs the call through the Responses API with the same `tool_config` fields as the JSON above.

## Codex CLI

Codex reads MCP servers from `~/.codex/config.toml` (or `.codex/config.toml` in a trusted project). With an API key, name the environment variable that holds it; Codex sends it as a bearer token:

```toml
[mcp_servers.autouncle-data]
url = "https://data-services.autouncle.com/mcp"
bearer_token_env_var = "AUTOUNCLE_API_KEY"
```

For OAuth, add the server without a token and sign in:

```bash
codex mcp add autouncle-data --url https://data-services.autouncle.com/mcp
codex mcp login autouncle-data
```

## Verify the connection

Ask the model or agent:

> Call get_account on autouncle-data and tell me the key mode, scopes and remaining credits.

## Troubleshooting

| Symptom | Fix |
| --- | --- |
| `401 invalid_api_key` | The header or `AUTOUNCLE_API_KEY` is empty or wrong. Check the variable in the process that calls OpenAI or runs Codex. |
| ChatGPT asks for a key you cannot enter | ChatGPT supports OAuth only. Choose OAuth when you create the connector. |
| Every tool call waits for approval | That is the Responses API default. Relax `require_approval` for the read-only tools only. |
| Unexpected credit use | OAuth and live keys are billed. Use a test key in development and keep approval on `valuate_car`. |

## Next steps

- [Safety & spend control](/docs/mcp/safety)
- [Tool reference](/docs/mcp/tools)

Sources: [OpenAI MCP and connectors guide](https://developers.openai.com/api/docs/guides/tools-connectors-mcp), [Responses API reference](https://developers.openai.com/api/reference/resources/responses/methods/create), [Building an MCP server for ChatGPT](https://developers.openai.com/api/docs/guides/custom-mcp-server), [ChatGPT app authentication](https://developers.openai.com/plugins/build/auth), [ChatGPT developer mode](https://help.openai.com/en/articles/12584461), [Agents SDK MCP](https://openai.github.io/openai-agents-python/mcp/), [Codex MCP](https://learn.chatgpt.com/docs/extend/mcp?surface=cli).
