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 withx-api-keyauth
Usage
uvx clodtok
Flags:
--prompt TEXT— prompt sent toclaude -pto 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
- Launches
mitmdump(viauvx --from mitmproxy) on the configured port with a small Python addon. - Launches
claude -p <prompt>withHTTPS_PROXY,HTTP_PROXY, andNODE_TLS_REJECT_UNAUTHORIZED=0set so its TLS traffic is intercepted. - The addon scans each request for an
x-api-keyheader and writes it to a sentinel file the parent process is watching. - 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.4.tar.gz
(5.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clodtok-0.1.4.tar.gz.
File metadata
- Download URL: clodtok-0.1.4.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a953b1ffc667a0b1b162ed9e76051a1f680bf185dc9bf386646c8d36608c3986
|
|
| MD5 |
23a445babb8c30c0d73070c9505f83e2
|
|
| BLAKE2b-256 |
4daf2218fe06d8c2386a8f12838850549b8f9694078193902cfe4d6c8783dab3
|
File details
Details for the file clodtok-0.1.4-py3-none-any.whl.
File metadata
- Download URL: clodtok-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54a99ed992944daf587b448fa22281e67d92b75363a4ac7f01e5affde72707c7
|
|
| MD5 |
478f3d7ea2858996b9da8bb0b501a84b
|
|
| BLAKE2b-256 |
aa1f7ddd7a7cab6e9789ddd2bf8fb832b0b8a878b6f8de3f1c554fe872134b93
|