Create an MCP (Model Context Protocol) server that exposes your DevTools traffic data to AI assistants. This enables Codex CLI, ChatGPT, and Claude Code to query your network traffic directly.
Looking for local-only? See the Ollama guide for a fully local setup without external dependencies.
What you'll build:
You: "What external APIs is my app calling?"
AI: [Calling get_hosts tool...]
"Your application is connecting to 16 external APIs:
- api.stripe.com (3 requests, all 200s) - /v1/customers, /v1/charges
- api.openai.com (2 requests, 401 errors) - /v1/chat/completions
- api.segment.io (2 requests, all 200s) - /v1/track
..."
You: "Are we leaking any sensitive data?"
AI: [Calling check_sensitive_data tool...]
"Found 5 requests with sensitive data:
- api.github.com: X-Api-Key header exposed
- httpbin.org: Password in request body
- www.googleapis.com: Database credentials in payload
..."
Available Tools
Tool
Use Case
Default Capture
get_traffic
Full HTTP details for debugging
60s, 500 requests
get_traffic_summary
Quick overview of traffic patterns
60s, 1000 requests
get_hosts
Map all external API dependencies
60s, 1000 requests
get_errors
Debug 4xx/5xx failures
60s, 1000 requests
check_sensitive_data
Security audit for leaked secrets
60s, 500 requests
get_processes
Which process/container made requests
60s, 1000 requests
get_payloads
Inspect request/response bodies
60s, 500 requests
search_traffic
Filter by host, method, status
60s, 1000 requests
get_connections
Network/TLS connection details
60s, 2000 events
All tools support up to 5 minutes of capture with seconds=300.
Prerequisites
Linux host with Qtap installed and DevTools enabled
Python 3.10+
Create the MCP Server
Step 1: Install Dependencies
Step 2: Create the Server
Save this as devtools_mcp.py:
Make it executable:
Connect to AI Assistants
Option 1: Codex CLI
Codex CLI is OpenAI's terminal-based coding assistant that supports MCP servers natively.
Add the MCP server to your config:
Or edit ~/.codex/config.toml directly:
Using a virtual environment? Replace python3 with your venv Python path:
Use it:
Codex will call get_hosts and analyze the results.
Option 2: ChatGPT Developer Mode
ChatGPT can connect to MCP servers via Developer Mode connectors. Since ChatGPT requires HTTPS, you'll need to expose your local server.
1. Start the MCP server with HTTP transport:
2. Expose your local server via HTTPS tunnel:
This creates a temporary *.trycloudflare.com URL you can use immediately.
Requires a free ngrok account.
3. In ChatGPT:
Go to Settings > Connectors > Advanced Settings
Enable Developer Mode
Add a new connector with your tunnel URL
Option 3: Claude Code
Claude Code supports MCP servers natively via the CLI.
Add the MCP server:
Using a virtual environment? Replace python3 with your venv Python path:
Verify it's connected:
Use it in Claude Code:
Claude Code will automatically use the appropriate tools to analyze your traffic.
Example Prompts
Once connected, try these prompts:
Quick Overview:
"What's happening with my network traffic?"
"Give me a summary of all HTTP requests"
"How many errors are there?"
API Discovery:
"What external APIs is my app calling?"
"Which services are we depending on?"
"Show me all the hosts we're connecting to"
Security Audit:
"Are we leaking any sensitive data?"
"Check for exposed API keys or passwords"
"What credentials are being transmitted?"
Error Debugging:
"What's failing? Show me all errors"
"Why are requests to stripe.com failing?"
"Debug the 401 errors"
Process Attribution:
"Which process is calling the OpenAI API?"
"What requests is the Python process making?"
"Show me traffic by container"
Payload Inspection:
"What data is being sent to external services?"
"Show me the request bodies"
"What's in the response from api.github.com?"
Filtered Search:
"Show me all POST requests"
"Find requests to anything with 'stripe' in the host"
"Show only 500 errors"
Example Output
get_hosts()
check_sensitive_data()
Troubleshooting
"Cannot connect to DevTools API"
Ensure Qtap is running with DevTools enabled:
Verify it's accessible:
"MCP server not found" in Codex
Check your config path:
Ensure the Python path is absolute and the script exists.
"No HTTP traffic captured"
Ensure traffic is being generated during the capture window
Try increasing the capture time: get_traffic(seconds=120)
Check that Qtap is capturing HTTP (not just connections)
ChatGPT can't reach the server
Verify cloudflared/ngrok is running and the URL is correct
Check that the MCP server is listening on the right port