Claude Code
Use the official Anthropic Claude CLI with Cocobox as the model provider and your databases as MCP tools.
Claude Code is Anthropic’s official terminal CLI. It speaks the Anthropic Messages format natively and supports HTTP MCP servers — both of which Cocobox provides.
Prerequisites
- Cocobox account + active subscription / trial.
- An
sk-coco-*API key withtoolsEnabled: true. See API keys. - Claude Code installed (
npm i -g @anthropic-ai/claude-codeor follow Anthropic’s instructions).
Configure Claude Code
Set the base URL and key:
export ANTHROPIC_BASE_URL=https://api.cocobox.io
export ANTHROPIC_API_KEY=sk-coco-…
claude --model sonnet
Note that the base URL ends in / (no /v1) — Claude Code appends /v1/messages itself.
Attach the Cocobox MCP server
Edit ~/.claude/settings.json (or .claude/settings.json in your project for per-project config):
{
"mcpServers": {
"cocobox": {
"type": "http",
"url": "https://api.cocobox.io/v1/mcp",
"headers": {
"Authorization": "Bearer sk-coco-…"
}
}
}
}
Start Claude Code. Inside the prompt, run /mcp to see the cocobox server connected and the tool list.
Claude Code terminal session showing /mcp output: cocobox connected, sql_run/sql_describe/sql_list_tables/sql_explain tools available.
Workflow ideas
- “Open the prod-readonly connection. What’s the schema of the orders table? Suggest 3 missing indexes based on the most common WHERE clauses in the last 100 queries.”
- “Generate a CTE that ranks customers by lifetime spend, then run it and show me the top 25.”
- “My dashboard query is slow. EXPLAIN it and propose a rewrite.”
The model will chain sql_list_connections → sql_describe → sql_history → sql_run calls automatically. Every call is audited.
Tips
- Use Sonnet or Opus for multi-step. Claude Code’s strength shines on long tool chains;
sonnet(1 credit) is the sweet spot for cost/quality. - Project-level settings beat global settings. Commit
.claude/settings.json(with theAuthorizationvalue loaded from an env var) so teammates pick up the same MCP wiring. - Headers can interpolate env vars:
"Authorization": "Bearer ${COCOBOX_API_KEY}".
Troubleshooting
Invalid API key— Claude Code may strip thesk-coco-prefix in some versions. Verify withclaude --debug.- MCP server times out on initialize — Cocobox sessions live in Redis with a 1h TTL. Long idle sessions are reaped; Claude Code re-initializes automatically.
anthropic-versionheader complaints — Claude Code sets this for you; if you call the API directly, sendanthropic-version: 2023-06-01.