Skip to main content

Capture the x-api-key header that Claude Code sends, via mitmproxy.

Project description

clodtok

Capture the x-api-key header that Claude Code sends to Anthropic, by funneling its traffic through a temporary mitmproxy instance.

Requirements

External CLIs that must already be on PATH:

  • uvx (from uv)
  • claude (Claude Code CLI), configured with x-api-key auth

Usage

uvx clodtok

Flags:

  • --prompt TEXT — prompt sent to claude -p to trigger an API call (default: "hi")
  • --host HOST — proxy listen host (default: 127.0.0.1)
  • --port PORT — proxy listen port (default: 8888)
  • --timeout SECONDS — how long to wait for the key (default: 60)
  • --debug — show mitmdump and claude output

The captured API key is printed to stdout. Errors go to stderr.

How it works

  1. Launches mitmdump (via uvx --from mitmproxy) on the configured port with a small Python addon.
  2. Launches claude -p <prompt> with HTTPS_PROXY, HTTP_PROXY, and NODE_TLS_REJECT_UNAUTHORIZED=0 set so its TLS traffic is intercepted.
  3. The addon scans each request for an x-api-key header and writes it to a sentinel file the parent process is watching.
  4. As soon as the key appears, both subprocesses are torn down and the key is printed.

Caveats

  • Only works when Claude Code authenticates with x-api-key. OAuth, Bedrock, and Vertex flows use different headers and will not produce a key here.
  • The configured port (default 8888) must be free.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clodtok-0.1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clodtok-0.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file clodtok-0.1.0.tar.gz.

File metadata

  • Download URL: clodtok-0.1.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for clodtok-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e867ef5778a37946e0e4421416ac4e8b75262f78f7c741f7ced11fc402a34135
MD5 4641fb9525ae7293a24ebab4bbe8cc39
BLAKE2b-256 6bb2c2b875aba5c0ea74a6ecfb9cecee77f6f8ad6bd77d3a3ba06a1c1314c11b

See more details on using hashes here.

File details

Details for the file clodtok-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: clodtok-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for clodtok-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68220778aeef01690b85d6d93f3110ab6d5a992bc785fa11e4cc9fe0ec9a6e2a
MD5 87e39d00fa03217b7d1a435d0db4d91d
BLAKE2b-256 b4549ee02ec4807c2bf8394a7ea3f23886189534b881f9fb5611072404cc4ad4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page