Codex CLI Setup Guide
March 12, 2026 ยท View on GitHub
Method 1: One-click Install
In the AI chat, type:
Help me auto install Gate Skills and MCPs: https://github.com/gateio/gate-skills

Method 2: Manual Configuration
Prerequisites
- OpenAI API key with Codex access
- Node.js >= 18
Step 1: Install Codex CLI
Install the OpenAI Codex CLI globally:
npm install -g @openai/codex
Or use npx (no installation required):
npx @openai/codex --version
Step 2: Configure OpenAI API Key
Set your OpenAI API key:
export OPENAI_API_KEY="your-api-key-here"
Or add it to your shell profile (~/.bashrc, ~/.zshrc, etc.):
echo 'export OPENAI_API_KEY="your-api-key-here"' >> ~/.zshrc
source ~/.zshrc
Step 3: Add Gate MCP
For full trading (OAuth on connect):
codex mcp add gate --url https://api.gatemcp.ai/mcp/exchange
For market data only (no auth):
codex mcp add gate --url https://api.gatemcp.ai/mcp
For Info (no auth):
codex mcp add gate-info --url https://api.gatemcp.ai/mcp/info
For News (no auth):
codex mcp add gate-news --url https://api.gatemcp.ai/mcp/news

Step 4: Verify Installation
List all configured MCP servers:
codex mcp list
You should see the Gate MCP server in the list.

Step 5: Start Using
Launch the Codex CLI:
codex
Try these example queries:
- "What is the current price of BTC/USDT?"
- "Show me arbitrage opportunities on Gate"
- "Analyze SOL for me"
- "Any new coins on Gate worth watching?"

Updating the MCP Server
To update the MCP server URL or configuration:
codex mcp remove gate
codex mcp add gate --url https://api.gatemcp.ai/mcp/exchange
Troubleshooting
"OPENAI_API_KEY not set" Error
Make sure you've set your OpenAI API key:
export OPENAI_API_KEY="your-api-key-here"
MCP Server Not Found
- Check if the MCP is properly added:
codex mcp list - Try removing and re-adding the MCP
- Check your internet connection
Connection Errors
- Verify the URL is correct:
https://api.gatemcp.ai/mcp/exchange(trading) orhttps://api.gatemcp.ai/mcp(market data) - Check if you need a proxy or VPN
- Try again later (the server might be temporarily down)
Next Steps
- Explore all available tools
- Learn about futures market tools
- Check the API documentation