example-remote-server/dev-with-mitm.sh
Jerome Swannack 07300e8453
Add dev scripts for mitmproxy debugging and fix JSON-RPC error responses
- Add dev-with-mitm.sh for TUI-based traffic inspection
- Add dev-with-mitmweb.sh for web UI-based traffic inspection
- Fix missing 'id' field in JSON-RPC error responses (required by spec)
- Migrate from zod-to-json-schema to Zod v4's native z.toJSONSchema()

The mitmproxy scripts help developers debug MCP traffic by running
the server through a reverse proxy that intercepts all client requests.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 13:35:29 +00:00

31 lines
848 B
Shell
Executable file

#!/bin/bash
# Easy script to run MCP server with mitmproxy intercepting client traffic
echo "🚀 Starting MCP server with mitmproxy..."
echo ""
echo "This will:"
echo " 1. Start your MCP server on port 3232"
echo " 2. Start mitmproxy reverse proxy on port 8080"
echo " 3. Intercept all client → server traffic"
echo ""
echo "📡 Connect your MCP client to: http://localhost:8080/mcp"
echo "🔍 View traffic in mitmproxy TUI"
echo ""
echo "Press Ctrl+C to stop both processes"
echo ""
# Trap Ctrl+C to kill both processes
trap 'kill 0' EXIT
# Start the MCP server in background
npm run dev &
SERVER_PID=$!
# Give server time to start
sleep 3
# Start mitmproxy in reverse proxy mode (foreground so we see the TUI)
mitmproxy --mode reverse:http://localhost:3232 --listen-port 8080
# This line won't be reached until mitmproxy exits
wait