The proxy module (Documentation Index
Fetch the complete documentation index at: https://docs.q-uestionable.ai/llms.txt
Use this file to discover all available pages before exploring further.
q_ai.proxy) intercepts MCP traffic between a client and server for inspection, modification, and replay. It operates as a man-in-the-middle, presenting itself as the server to the client while forwarding messages to the real server.
Module Structure
How It Works
qai proxy start launches the TUI. The proxy:
- Spawns the target MCP server (stdio) or connects to it (SSE/HTTP)
- Presents itself as the server to the client
- Records all messages with timestamps, direction, and sequence numbers
- In passthrough mode: forwards messages transparently
- In intercept mode: pauses on each message for inspection/modification
Session Model
A session is a sequence ofProxyMessage objects. Each message records:
- direction —
CLIENT_TO_SERVERorSERVER_TO_CLIENT - method — MCP method name (e.g.,
tools/call,initialize) - jsonrpc_id — For request/response correlation
- sequence — Ordering within the session
- raw — Full JSON-RPC message
- original_raw — Pre-modification content (if intercepted and changed)
- modified — Boolean flag
- correlated_id — Links requests to their responses
SessionStore.
Replay
qai proxy replay replays recorded client-to-server messages against a live server:
- Loads a saved session file
- Optionally sends a synthetic
initializehandshake - Sends each client→server message to the target
- Records responses and latency
- Reports success/failure per message
--target-command) or HTTP servers (--target-url).
TUI
The Textual-based TUI provides:- Chronological message list with direction indicators (
→client→server,←server→client) - Message expansion for full JSON payload inspection
- Intercept mode with pause/modify/forward controls
Adapter
ProxyAdapter wraps session recording for orchestrator workflows. It creates a child run, starts the proxy, and persists the session to the database on completion or failure.
Export
qai proxy export serializes a session to JSON. qai proxy inspect prints session contents to stdout with optional --verbose for full JSON payloads.