Automated setup assistant for cc-trace - install mitmproxy, configure certificates, and verify the environment for intercepting Claude Code API traffic
Automated setup assistant for cc-trace - install mitmproxy, configure certificates, and verify the environment for intercepting Claude Code API traffic
/plugin marketplace add greyhaven-ai/claude-code-config/plugin install cc-trace@grey-haven-pluginsSet up cc-trace for intercepting and debugging Claude Code API requests using mitmproxy. This command will guide you through the complete setup process automatically.
Check Prerequisites
Install mitmproxy
Generate & Trust Certificate
Verify Setup
Provide Usage Instructions
When you use this command, Claude will:
# Check OS type
uname -s
# Check if Homebrew installed (macOS)
which brew
# Check if mitmproxy already installed
which mitmproxy
macOS:
brew install mitmproxy
Linux (Debian/Ubuntu):
sudo apt update && sudo apt install -y mitmproxy
Linux (RHEL/Fedora):
sudo dnf install -y mitmproxy
Universal (Python):
pip install mitmproxy
Verify installation:
mitmproxy --version
Run mitmproxy briefly to generate CA certificate:
# Start and immediately stop mitmproxy to generate cert
timeout 2 mitmproxy 2>/dev/null || true
# OR
mitmproxy &
sleep 2
pkill mitmproxy
Verify certificate exists:
ls -la ~/.mitmproxy/mitmproxy-ca-cert.pem
macOS:
# Add certificate to system keychain
sudo security add-trusted-cert -d -p ssl -p basic \
-k /Library/Keychains/System.keychain \
~/.mitmproxy/mitmproxy-ca-cert.pem
# Verify trust
security find-certificate -c mitmproxy -a
Linux (Debian/Ubuntu):
# Copy certificate to trusted CA directory
sudo cp ~/.mitmproxy/mitmproxy-ca-cert.pem \
/usr/local/share/ca-certificates/mitmproxy.crt
# Update CA certificates
sudo update-ca-certificates
Linux (RHEL/Fedora):
# Copy certificate
sudo cp ~/.mitmproxy/mitmproxy-ca-cert.pem \
/etc/pki/ca-trust/source/anchors/mitmproxy.pem
# Update trust
sudo update-ca-trust
Run the bundled verification script:
bash ~/.claude/plugins/marketplaces/grey-haven-plugins/grey-haven-plugins/cc-trace/scripts/verify-setup.sh
The script checks:
# Start mitmproxy in background
mitmproxy --listen-port 8080 &
MITM_PID=$!
# Test proxy with curl
export HTTPS_PROXY=http://127.0.0.1:8080
export NODE_TLS_REJECT_UNAUTHORIZED=0
curl -I https://api.anthropic.com 2>&1
# Stop mitmproxy
kill $MITM_PID
unset HTTPS_PROXY NODE_TLS_REJECT_UNAUTHORIZED
Setup is complete when:
~/.mitmproxy/mitmproxy-ca-cert.pemTerminal 1 - Start mitmweb:
mitmweb --web-port 8081 --set flow_filter='~d api.anthropic.com'
Terminal 2 - Run Claude with proxy:
bash ~/.claude/plugins/marketplaces/grey-haven-plugins/grey-haven-plugins/cc-trace/scripts/proxy-claude.sh
Browser - View traffic:
http://127.0.0.1:8081
Terminal 2:
export HTTP_PROXY=http://127.0.0.1:8080
export HTTPS_PROXY=http://127.0.0.1:8080
export NODE_EXTRA_CA_CERTS="$HOME/.mitmproxy/mitmproxy-ca-cert.pem"
export NODE_TLS_REJECT_UNAUTHORIZED=0
claude
If certificate verification fails:
# Remove existing certificate
sudo security delete-certificate -c mitmproxy \
/Library/Keychains/System.keychain 2>/dev/null || true
# Re-add with trust
sudo security add-trusted-cert -d -p ssl -p basic \
-k /Library/Keychains/System.keychain \
~/.mitmproxy/mitmproxy-ca-cert.pem
# Open Keychain Access to verify manually
open /System/Applications/Utilities/Keychain\ Access.app
# Check what's using port 8080
lsof -i :8080
# Kill conflicting process if needed
kill $(lsof -t -i:8080)
# Or use different port
mitmweb --listen-port 9090 --web-port 9091
If you get permission errors:
# Ensure you have sudo access
sudo -v
# On Linux, you may need to add your user to relevant groups
sudo usermod -a -G ssl-cert $USER
# Log out and back in for group changes to take effect
# Check Python version (requires 3.8+)
python3 --version
# Reinstall mitmproxy
pip uninstall mitmproxy
pip install mitmproxy
# Or via package manager
brew reinstall mitmproxy # macOS
sudo apt reinstall mitmproxy # Debian/Ubuntu
⚠️ Important Security Considerations:
NODE_TLS_REJECT_UNAUTHORIZED=0 disables certificate validationBest Practices:
The command will provide:
Installation Progress
🔧 Installing mitmproxy...
✓ mitmproxy 10.1.5 installed successfully
🔐 Generating certificate...
✓ Certificate created: ~/.mitmproxy/mitmproxy-ca-cert.pem
🔒 Adding certificate to system trust...
✓ Certificate trusted in system keychain
Verification Results
🔍 Verifying setup...
✓ mitmproxy installation
✓ Certificate generation
✓ Certificate trust
✓ Proxy connectivity
✅ All checks passed! Setup complete.
Usage Instructions
🚀 Ready to capture traffic!
Terminal 1:
mitmweb --web-port 8081 --set flow_filter='~d api.anthropic.com'
Terminal 2:
bash ~/.claude/plugins/.../scripts/proxy-claude.sh
Browser:
http://127.0.0.1:8081
/cc-trace - Interactive agent for debugging and analysis (coming soon)cc-trace agent for guided troubleshooting~/.claude/plugins/.../cc-trace/README.mdNote: This command performs automated setup. If you encounter issues, you can invoke the cc-trace agent for interactive troubleshooting assistance.