Coding agents and editors
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 | Yes | Yes | No |
| Cursor | Yes | Yes | Yes |
| Codex | Yes | Yes | No |
| VS Code | Yes | Yes | No |
| OpenCode | Yes | Yes | No |
| 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 and ChatGPT.
Claude Code
Add the server:
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:
{
"mcpServers": {
"twexapi": {
"type": "http",
"url": "https://api.twexapi.io/mcp",
"headers": {
"x-api-key": "${TWEXAPI_API_KEY}"
}
}
}
}
Cursor
Add to ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (one project):
{
"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:
{
"mcpServers": {
"twexapi": {
"url": "https://api.twexapi.io/mcp",
"headers": {
"x-api-key": "${env:TWEXAPI_API_KEY}"
}
}
}
}
Codex
Add the server and sign in:
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:
[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:
[mcp_servers.twexapi]
url = "https://api.twexapi.io/mcp"
bearer_token_env_var = "TWEXAPI_API_KEY"
VS Code
Run MCP: Add Server from the Command Palette and choose HTTP, or add to .vscode/mcp.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:
{
"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}"
}
}
}
}
OpenCode
Add to opencode.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:
{
"$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}"
}
}
}
}
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):
{
"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.
Check the connection
- The server lists
explore,twexapi_request, andtwexapi_write. Without write access,twexapi_writeis not listed. - Ask the agent to “use TwexAPI explore to find trending endpoints”.
exploreuses no credits, so it works even before you top up. - The new connection appears under Authorized apps in the 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.