---
title: "Coding agents and editors"
description: "Connect Claude Code, Codex, Cursor, VS Code, OpenCode, and Windsurf to the TwexAPI MCP server with sign-in or an API key."
---

Every client below connects to the same server, `https://api.twexapi.io/mcp`, over Streamable HTTP. Most of them can sign in with your TwexAPI account: add only the URL, and the client opens a browser for you to approve access. Use an API key for clients without MCP sign-in, or when you prefer a key.

| Client | Sign in with TwexAPI | API key | Tested by TwexAPI |
| --- | --- | --- | --- |
| [Claude Code](#claude-code) | Yes | Yes | No |
| [Cursor](#cursor) | Yes | Yes | Yes |
| [Codex](#codex) | Yes | Yes | No |
| [VS Code](#vs-code) | Yes | Yes | No |
| [OpenCode](#opencode) | Yes | Yes | No |
| [Windsurf](#windsurf) | Not confirmed | Yes | No |

"Tested" means we ran the full sign-in and a tool call with that client. The other sign-in paths follow each vendor's documented MCP authorization support; use an API key if sign-in fails. For Claude.ai, Claude Desktop, and ChatGPT, see the [MCP Server overview](/mcp/overview#claude-ai-and-claude-desktop) and [ChatGPT](/mcp/chatgpt).

:::tip
  Keep API keys in environment variables, not in configuration files you commit. Create a key in the [TwexAPI dashboard](https://twexapi.io/dashboard).
:::

<a id="claude-code"></a>

## Claude Code

Add the server:

```bash
claude mcp add --transport http twexapi https://api.twexapi.io/mcp
```

Then run `/mcp` inside a Claude Code session, select `twexapi`, and choose **Authenticate**. Approve access in the browser. Add `--scope project` to share the server through `.mcp.json`; teammates each sign in with their own account.

To use an API key instead, put the header in `.mcp.json`. Claude Code expands `${TWEXAPI_API_KEY}` from your environment:

```json
{
  "mcpServers": {
    "twexapi": {
      "type": "http",
      "url": "https://api.twexapi.io/mcp",
      "headers": {
        "x-api-key": "${TWEXAPI_API_KEY}"
      }
    }
  }
}
```

<a id="cursor"></a>

## Cursor

Add to `~/.cursor/mcp.json` (all projects) or `.cursor/mcp.json` (one project):

```json
{
  "mcpServers": {
    "twexapi": {
      "url": "https://api.twexapi.io/mcp"
    }
  }
}
```

Open **Settings → MCP**. The server shows **Needs authentication**; select **Authenticate**, approve access in the browser, and allow the browser to open Cursor. The server then shows three tools enabled.

To use an API key instead:

```json
{
  "mcpServers": {
    "twexapi": {
      "url": "https://api.twexapi.io/mcp",
      "headers": {
        "x-api-key": "${env:TWEXAPI_API_KEY}"
      }
    }
  }
}
```

<a id="codex"></a>

## Codex

Add the server and sign in:

```bash
codex mcp add twexapi --url https://api.twexapi.io/mcp
codex mcp login twexapi
codex mcp list
```

The Codex CLI, app, and IDE extension share the same configuration in `~/.codex/config.toml`:

```toml
[mcp_servers.twexapi]
url = "https://api.twexapi.io/mcp"
```

To use an API key instead, name an environment variable that holds it. Codex sends it as `Authorization: Bearer`:

```toml
[mcp_servers.twexapi]
url = "https://api.twexapi.io/mcp"
bearer_token_env_var = "TWEXAPI_API_KEY"
```

<a id="vs-code"></a>

## VS Code

Run **MCP: Add Server** from the Command Palette and choose **HTTP**, or add to `.vscode/mcp.json`:

```json
{
  "servers": {
    "twexapi": {
      "type": "http",
      "url": "https://api.twexapi.io/mcp"
    }
  }
}
```

Start the server and approve the sign-in prompt in the browser.

To use an API key instead, let VS Code prompt for it once and store it securely:

```json
{
  "inputs": [
    {
      "type": "promptString",
      "id": "twexapi-key",
      "description": "TwexAPI API key",
      "password": true
    }
  ],
  "servers": {
    "twexapi": {
      "type": "http",
      "url": "https://api.twexapi.io/mcp",
      "headers": {
        "x-api-key": "${input:twexapi-key}"
      }
    }
  }
}
```

<a id="opencode"></a>

## OpenCode

Add to `opencode.json`:

```json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "twexapi": {
      "type": "remote",
      "url": "https://api.twexapi.io/mcp"
    }
  }
}
```

OpenCode detects that the server needs sign-in and opens the browser. If it does not, run `opencode mcp auth twexapi`. Check the status with `opencode mcp list`, and use `opencode mcp debug twexapi` when the connection fails.

To use an API key instead, turn off automatic sign-in:

```json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "twexapi": {
      "type": "remote",
      "url": "https://api.twexapi.io/mcp",
      "oauth": false,
      "headers": {
        "Authorization": "Bearer {env:TWEXAPI_API_KEY}"
      }
    }
  }
}
```

<a id="windsurf"></a>

## Windsurf

We have not confirmed sign-in with Windsurf, so use an API key. Add to `~/.codeium/windsurf/mcp_config.json` (open it from the MCP menu in Cascade to find your version's location):

```json
{
  "mcpServers": {
    "twexapi": {
      "serverUrl": "https://api.twexapi.io/mcp",
      "headers": {
        "x-api-key": "YOUR_API_KEY"
      }
    }
  }
}
```

## Other clients

Any client that implements MCP authorization (OAuth 2.1 with PKCE and dynamic client registration) can sign in by adding only the server URL. Otherwise, send your API key in the `x-api-key` header or as `Authorization: Bearer YOUR_API_KEY`. Building your own client? See [OAuth for MCP clients](/mcp/oauth).

## Check the connection

- The server lists `explore`, `twexapi_request`, and `twexapi_write`. Without write access, `twexapi_write` is not listed.
- Ask the agent to "use TwexAPI explore to find trending endpoints". `explore` uses no credits, so it works even before you top up.
- The new connection appears under **Authorized apps** in the [dashboard](https://twexapi.io/dashboard).

| Problem | Fix |
| --- | --- |
| `401` or "Needs authentication" | Run the client's sign-in again (`/mcp` in Claude Code, **Authenticate** in Cursor, `codex mcp login`, `opencode mcp auth`). |
| The consent page says you have no API key | Create a key in the dashboard, then select **Approve** again within 10 minutes. |
| The consent page says you have no credits | Top up, then select **Approve** again within 10 minutes. |
| Tool calls return "No credits left on this TwexAPI account" | Top up in the dashboard. The connection itself is fine. |
| `twexapi_write` is missing | You connected read-only. Revoke the app in the dashboard, connect again, and keep the write checkbox selected. |

When you report a problem, include the client name and version, the UTC time, and the `X-Request-Id` response header if you can see it.
