We've successfully set up a man-in-the-middle proxy to intercept the Model Context Protocol (MCP) communication between Claude Code and VS Code.
- MCP Server: VS Code extension runs an MCP server on
localhost:40145using WebSocket protocol - Lock Files: Located in
~/.claude/ide/, named by PID (e.g.,367937.lock) - Communication: JSON-RPC messages over WebSocket connection
- Original VS Code MCP Server: Port 40145 (PID: 367937)
- MITM WebSocket Proxy: Port 40146 (forwards to 40145)
- Modified Lock File:
~/.claude/ide/367937.lockpoints to our proxy port 40146
-
Verify proxy is running:
netstat -tlnp | grep 40146 -
Start Claude in debug mode:
claude --debug
-
Type the /ide command:
> /ide -
Check captured messages:
ls -la mitm-claude/logs/mcp_websocket/
mitm-websocket.py- Basic WebSocket MITM proxymitm-websocket-v2.py- Enhanced proxy with better loggingintercept-mcp-stdio.py- Stdio interceptor (for future use)- Various test scripts for setup and monitoring
The MCP uses JSON-RPC over WebSocket with messages for:
- Tool discovery and execution
- Resource access (files, git state)
- Completion suggestions
- IDE state synchronization
With the proxy in place, you can now:
- Capture all MCP messages between Claude and VS Code
- Analyze the protocol implementation
- Understand how /ide integrates with the IDE
- Potentially create custom MCP servers or clients