Skip to main content
Cordon integrates with Claude Code so your AI agent can make authenticated API calls without holding real credentials.
Cordon currently works with API key authentication only. If you use Claude Code with a Claude Pro/Team subscription (OAuth login), credential injection won’t apply — Claude Code authenticates directly via OAuth, bypassing the proxy. Support for OAuth-based subscriptions is coming soon.

Automated setup

The fastest way to get started:
cordon setup claude-code
This:
  1. Generates CA certificates (if not already present)
  2. Creates a scaffold cordon.toml
  3. Generates a combined CA bundle (system CAs + Cordon CA)
  4. Configures Claude Code’s settings.json with proxy env vars (HTTPS_PROXY, HTTP_PROXY, https_proxy, http_proxy, NODE_EXTRA_CA_CERTS, SSL_CERT_FILE, REQUESTS_CA_BUNDLE, CURL_CA_BUNDLE)
Your existing settings.json is backed up to settings.json.cordon.bak before any changes are made. To run cordon as a background service for this project, run cordon service install --name my-project --config ./cordon.toml after setup.

Remove the setup

cordon setup claude-code --remove

Adding routes

After setup, add a route for your API provider. Example for Anthropic:
cordon route add
If you chose keyring as the secret source, store the secret:
cordon secret set anthropic
You can also edit cordon.toml directly — see Routes for the full format.

API key setup

Claude Code needs an API key env var set so it selects the API key auth path. Add a placeholder to settings.json:
{
  "env": {
    "ANTHROPIC_API_KEY": "dummy-replaced-by-cordon"
  }
}
Cordon strips this dummy key and injects the real one from your secret store at the network layer.

Manual setup

If you prefer manual configuration, set these env vars in Claude Code’s environment:
export HTTPS_PROXY=http://127.0.0.1:6790
export HTTP_PROXY=http://127.0.0.1:6790
export https_proxy=http://127.0.0.1:6790
export http_proxy=http://127.0.0.1:6790
export NODE_EXTRA_CA_CERTS=./ca-cert.pem
export SSL_CERT_FILE=/path/to/combined-ca.pem
export REQUESTS_CA_BUNDLE=/path/to/combined-ca.pem
export CURL_CA_BUNDLE=/path/to/combined-ca.pem
You must create a combined CA bundle manually if not using cordon setup claude-code. Concatenate your system CA bundle with the Cordon CA cert — see Combined CA bundle below.
You can add these to Claude Code’s settings.json:
{
  "env": {
    "HTTPS_PROXY": "http://127.0.0.1:6790",
    "HTTP_PROXY": "http://127.0.0.1:6790",
    "https_proxy": "http://127.0.0.1:6790",
    "http_proxy": "http://127.0.0.1:6790",
    "NODE_EXTRA_CA_CERTS": "./ca-cert.pem",
    "SSL_CERT_FILE": "/path/to/combined-ca.pem",
    "REQUESTS_CA_BUNDLE": "/path/to/combined-ca.pem",
    "CURL_CA_BUNDLE": "/path/to/combined-ca.pem"
  }
}

Combined CA bundle

Claude Code can launch MCP servers and tools that use Python, curl, wget, or other non-Node runtimes. These tools use SSL_CERT_FILE, REQUESTS_CA_BUNDLE, or CURL_CA_BUNDLE to locate trusted certificates. Python’s SSL_CERT_FILE replaces the default certificate store rather than appending to it. Setting it to just the Cordon CA cert would break TLS for all non-proxied connections (the system CAs would be missing). To solve this, cordon setup claude-code generates a combined CA bundle that concatenates:
  1. Your system CA certificates (e.g., from /etc/ssl/cert.pem)
  2. The Cordon proxy CA certificate
This combined bundle is written next to the Cordon CA cert (e.g., combined-ca.pem) and SSL_CERT_FILE, REQUESTS_CA_BUNDLE, and CURL_CA_BUNDLE all point to it.
  • SSL_CERT_FILE — used by Python’s ssl module and OpenSSL-based tools
  • REQUESTS_CA_BUNDLE — used by Python’s requests library (does not read SSL_CERT_FILE)
  • CURL_CA_BUNDLE — used by curl and libcurl-based tools
  • NODE_EXTRA_CA_CERTS — used by Node.js (appends to built-in CAs, so it points to just the Cordon CA cert, not the combined bundle)

Trust the CA

If tools used by Claude Code fail with certificate errors:
tls: failed to verify certificate: x509: certificate signed by unknown authority
Add the CA to the system trust store:
cordon trust
Node.js ignores the system trust store, so you still need NODE_EXTRA_CA_CERTS for Node-based tools (this is handled automatically by cordon setup claude-code).

Workflow

Once configured, the workflow is:
  1. Start cordon: cordon start (or use the background service)
  2. Start Claude Code as usual
  3. When Claude Code makes API calls to configured hosts, cordon transparently injects credentials
  4. Claude Code never sees or logs real API keys
Use cordon doctor to diagnose any setup issues. It checks config validity, cert paths, trust store status, and port availability.

Troubleshooting

Certificate errors

If tools used by Claude Code fail with certificate errors:
tls: failed to verify certificate: x509: certificate signed by unknown authority
  1. Verify NODE_EXTRA_CA_CERTS is set in settings.json and points to an existing file
  2. For Python MCP servers, verify SSL_CERT_FILE and REQUESTS_CA_BUNDLE are set and point to the combined CA bundle (not just the Cordon CA cert)
  3. For curl/wget-based tools, verify CURL_CA_BUNDLE is set
  4. For other non-Node tools, add the CA to the system trust store: cordon trust
Node.js ignores the system trust store — it only reads NODE_EXTRA_CA_CERTS. Python’s SSL_CERT_FILE replaces the system store, so it must point to the combined bundle. Both are handled automatically by cordon setup claude-code.

Proxy not being picked up

Verify the env vars are in Claude Code’s settings.json:
cat ~/.claude/settings.json
If the vars are set but Claude Code isn’t routing through the proxy, ensure cordon is running:
cordon status
curl http://127.0.0.1:6790/health

MCP servers not using the proxy

Node.js MCP servers need the bootstrap loader to enable proxy support. Add to your MCP server config:
{
  "mcpServers": {
    "my-server": {
      "command": "npx",
      "args": ["-y", "@some/mcp-server"],
      "env": {
        "NODE_OPTIONS": "--import @c6o/cordon/register"
      }
    }
  }
}
Python MCP servers using requests or httpx will respect HTTPS_PROXY automatically if it’s set in the environment.

New routes not taking effect

Cordon loads routes at startup. If you add or change routes in cordon.toml, restart the proxy (secrets are fetched per-request and don’t require a restart):
# If running manually
# Ctrl+C, then:
cordon start

# If running as a service
cordon service stop claude-code && cordon service start claude-code

401 Unauthorized errors

  1. Verify the secret is stored: cordon secret set <route-name>
  2. Check the auth type: Anthropic uses type: api_key with header_name: x-api-key, not type: bearer
  3. Check the secret source: Secrets are fetched per-request — if you changed a secret, the next request picks it up automatically