I could not point Claude Code at localhost, so I MITM Bedrock on loopback
说明与用途
claude‑sniff 工具通过本地 MITM 代理拦截、检查并可选编辑 Claude Code 对 Bedrock 的请求,实现成本跟踪和安全处理 AWS 凭证。
问题
Claude Code on Amazon Bedrock does not expose its invoke requests to a local proxy, making it hard to inspect, edit, or cost‑track requests.
结果
The claude-sniff tool enables local inspection, editing, and cost tracking of Claude Code requests without exposing AWS credentials, improving transparency and control for developers.
工作流
- 1. Install dependencies with
uv syncand runuv run python main.py --aws-profile your-profileto start mitmproxy on 127.0.0.1:9090. - 2. In the same shell, set
HTTP_PROXYandHTTPS_PROXYto the mitmproxy address and launch Claude Code withclaude. - 3. Keep Proxy and Intercept disabled by default; enable Intercept only when you want to decrypt and edit requests.
- 4. Export the mitmproxy CA certificate and restart Claude Code to trust the proxy.
- 5. Intercept Bedrock
invoke/invoke-with-response-streamcalls, edit the JSON payload as needed, then forward the request. - 6. The tool re‑signs edited requests and resumes untouched JSON as-is; no calls are dropped unless explicitly configured.
证据
I built claude-sniff: one Python process, mitmproxy on 127.0.0.1:9090, UI on 8765.
Intercept holds Bedrock invoke / invoke-with-response-stream that carry x-claude-code-session-id.
- 记录日期: 2026-09-07T19:59:57.141Z