Skip to main content

A MITM proxy tool to intercept, analyze and log AI coding assistant communications with LLM APIs

Project description

Claude-Code-Inspector (CCI)

๐Ÿ” MITM Proxy for LLM API Traffic Analysis

A cross-platform command-line tool that intercepts, analyzes, and logs communications between AI coding assistants (Claude Code, Cursor, Codex, Gemini-CLI, etc.) and their backend LLM APIs.


โœจ Features

  • Watch Mode - Interactive continuous capture with session management
  • Transparent Inspection - See exactly what prompts are sent and what responses are received
  • Streaming Support - Captures both streaming (SSE) and non-streaming API responses
  • Multi-Provider - Works with Anthropic, OpenAI, Google, Groq, Together, Mistral, and more
  • Automatic Masking - Protects API keys and sensitive data in logs
  • Auto Processing - Automatically merges and splits session data
  • Cross-Platform - Works on Windows, macOS, and Linux

๐Ÿ“ฆ Installation

Using pip

pip install claude-code-inspector

Using uv (recommended)

uv add claude-code-inspector

From source

git clone https://github.com/chouzz/claude-code-inspector.git
cd claude-code-inspector
uv sync

๐Ÿš€ Quick Start

1. Install Certificate (First Time Only)

# Generate certificate
cci watch &
sleep 2
kill %1

Then install the certificate:

macOS:

open ~/.mitmproxy/mitmproxy-ca-cert.pem
# Double-click to add to Keychain
# In Keychain Access, find "mitmproxy" โ†’ Double-click โ†’ Trust โ†’ "Always Trust"

Linux (Ubuntu/Debian):

sudo cp ~/.mitmproxy/mitmproxy-ca-cert.pem /usr/local/share/ca-certificates/mitmproxy.crt
sudo update-ca-certificates

Windows: Navigate to %USERPROFILE%\.mitmproxy\, double-click mitmproxy-ca-cert.pem โ†’ Install Certificate โ†’ Local Machine โ†’ Trusted Root Certification Authorities

2. Start Watch Mode

cci watch

3. Configure Your Application (New Terminal)

export HTTP_PROXY=http://127.0.0.1:9090
export HTTPS_PROXY=http://127.0.0.1:9090
export NODE_EXTRA_CA_CERTS=~/.mitmproxy/mitmproxy-ca-cert.pem

# Run your AI tool
claude -p "hello"

4. Record Sessions

  • Press Enter in watch mode to start recording
  • Press Enter again to stop and process the session
  • Ctrl+C to exit watch mode

๐ŸŽฌ How Watch Mode Works

Watch mode uses a state machine with three states:

State Description
IDLE Monitoring traffic, waiting for you to start a session
RECORDING Capturing traffic with session ID injection
PROCESSING Auto-extracting, merging, and splitting session data

Example Session

$ cci watch

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚   CCI Watch Mode        โ”‚
โ”‚ Continuous Capture      โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

  Proxy Port:    9090
  Output Dir:    ./traces
  Global Log:    traces/all_captured_20251203_220000.jsonl

Configure your application:
  export HTTP_PROXY=http://127.0.0.1:9090
  export HTTPS_PROXY=http://127.0.0.1:9090
  export NODE_EXTRA_CA_CERTS=~/.mitmproxy/mitmproxy-ca-cert.pem

โ— [IDLE] Monitoring on :9090... Logging to all_captured_20251203_220000.jsonl
  Press [Enter] to START Session 1
<Enter>

โ—‰ [REC] Session 01_session_20251203_223010 is recording...
  Press [Enter] to STOP & PROCESS
<Enter>

โณ [BUSY] Processing Session 01_session_20251203_223010...
  โœ” Saved to traces/01_session_20251203_223010/

โ— [IDLE] Monitoring on :9090... Logging to all_captured_20251203_220000.jsonl
  Press [Enter] to START Session 2

Output Structure

./traces/                                    # Root output directory
โ”œโ”€โ”€ all_captured_20251203_220000.jsonl       # Global log (all traffic)
โ”‚
โ”œโ”€โ”€ 01_session_20251203_223010/              # Session 01 folder
โ”‚   โ”œโ”€โ”€ raw.jsonl                            # Clean session data
โ”‚   โ”œโ”€โ”€ merged.jsonl                         # Merged conversations
โ”‚   โ””โ”€โ”€ split_output/                        # Individual files
โ”‚       โ”œโ”€โ”€ 001_request_2025-12-03_22-30-10.json
โ”‚       โ””โ”€โ”€ 001_response_2025-12-03_22-30-10.json
โ”‚
โ”œโ”€โ”€ 02_session_20251203_224500/              # Session 02 folder
โ””โ”€โ”€ ...

๐Ÿ“‹ CLI Reference

cci watch

Start watch mode for continuous session capture (recommended).

cci watch [OPTIONS]

Options:
  -p, --port INTEGER       Proxy server port (default: 9090)
  -o, --output-dir PATH    Root output directory (default: ./traces)
  -i, --include TEXT       Additional URL patterns to include (glob pattern)
  --debug                  Enable debug mode with verbose logging

Examples:

# Basic watch mode
cci watch

# Custom port and output directory
cci watch --port 8888 --output-dir ./my_traces

# Include custom API endpoint (glob pattern)
cci watch --include "*my-custom-api.com*"

# Match all subdomains of a domain
cci watch --include "*api.example.com*"

Glob Pattern Syntax:

Pattern Description
* Matches any characters
? Matches a single character
[seq] Matches any character in seq
[!seq] Matches any character not in seq

cci config

Display configuration and setup help.

cci config --cert-help    # Certificate installation instructions
cci config --proxy-help   # Proxy configuration instructions
cci config --show         # Show current configuration

cci stats

Display statistics for a captured trace file.

cci stats traces/01_session_xxx/raw.jsonl

๐Ÿ”ง Supported LLM Providers

CCI is pre-configured to capture traffic from:

Provider API Domain
Anthropic api.anthropic.com
OpenAI api.openai.com
Google generativelanguage.googleapis.com
Together api.together.xyz
Groq api.groq.com
Mistral api.mistral.ai
Cohere api.cohere.ai
DeepSeek api.deepseek.com

Add custom providers with --include (using glob patterns):

cci watch --include "*my-custom-api.com*"

๐Ÿ› Troubleshooting

SSL Certificate Error

Problem: SSL: CERTIFICATE_VERIFY_FAILED

Solution: Install the mitmproxy CA certificate. Run cci config --cert-help for instructions.

Node.js Apps Not Working

Problem: Requests hang or timeout when using Claude Code, Cursor, etc.

Solution: Set the NODE_EXTRA_CA_CERTS environment variable:

export NODE_EXTRA_CA_CERTS=~/.mitmproxy/mitmproxy-ca-cert.pem

No Traffic Captured

Problem: Watch mode is running but no requests are logged

Solution:

  1. Verify proxy environment variables are set correctly
  2. Make sure the URL matches the default patterns (or add --include)
  3. Check cci config --show to see current filter patterns

๐Ÿ“œ License

MIT License

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“ž Support

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

claude_code_inspector-1.3.0.tar.gz (101.0 kB view details)

Uploaded Source

Built Distribution

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

claude_code_inspector-1.3.0-py3-none-any.whl (39.1 kB view details)

Uploaded Python 3

File details

Details for the file claude_code_inspector-1.3.0.tar.gz.

File metadata

  • Download URL: claude_code_inspector-1.3.0.tar.gz
  • Upload date:
  • Size: 101.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for claude_code_inspector-1.3.0.tar.gz
Algorithm Hash digest
SHA256 e204efdffe038dc6248ff53bfa58c935b80f8d7dbe279a774bfca06676272625
MD5 2211f08f3969e684c84f9e2ff1da4a50
BLAKE2b-256 c3941f2defa2013420e3e2bec3b0d5a97907fc0e0bdfd64e4e3ee3c5c5b4a2cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_code_inspector-1.3.0.tar.gz:

Publisher: publish.yml on chouzz/claude-code-inspector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file claude_code_inspector-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for claude_code_inspector-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b5a49ea23dde7cb7d667a2da2676fd1037722682714d5205d0b2242e96bcefd
MD5 f9e7f762db3ec7c5487c199c78e88858
BLAKE2b-256 3203a4f06f42b224b00b2c5406d4dc84b06e28906eb7ccbb68748f4e2a70d7e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_code_inspector-1.3.0-py3-none-any.whl:

Publisher: publish.yml on chouzz/claude-code-inspector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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