The debug endpoints provide real-time visibility into bridge operations. Use these tools to monitor connections, troubleshoot issues, and understand message flow.
http://localhost:8081/debugFeatures:
- Connection list
- Active sessions
- Subprocess states
- Message counts
- Real-time updates
Active connections:
- Session ID
- Namespace
- Connection time
- Message count
Subprocess states:
stopped- Process not runningstarting- Process starting uprunning- Process activestopping- Process shutting downerror- Process error
Metrics:
- Total messages (in/out)
- Connection duration
- Last activity timestamp
Browser:
http://localhost:8081/debug/streamcurl:
curl -N http://localhost:8081/debug/streamWebSocket (if supported):
ws://localhost:8081/debug/stream
{
"event": "message" | "connection" | "ping",
"direction": "in" | "out", // For message events
"namespace": "git",
"session": "session-123",
"timestamp": "2025-03-08T12:00:00Z",
"message": {
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {...}
}
}Shows JSON-RPC messages flowing through the bridge.
Incoming (client → bridge → server):
event: message
data: {
"direction": "in",
"namespace": "git",
"session": "session-123",
"message": {"jsonrpc":"2.0","id":1,"method":"ping"}
}
Outgoing (server → bridge → client):
event: message
data: {
"direction": "out",
"namespace": "git",
"session": "session-123",
"message": {"jsonrpc":"2.0","id":1,"result":{...}}
}
Shows connection lifecycle events.
Connected:
event: connection
data: {
"event": "connected",
"namespace": "git",
"session": "session-123"
}
Disconnected:
event: connection
data: {
"event": "disconnected",
"namespace": "git",
"session": "session-123"
}
Heartbeat from debug stream.
event: ping
data: {"time":"2025-03-08T12:00:00Z"}
Subprocess is starting up.
Symptoms: No messages yet Action: Wait for process to start
Subprocess is active and handling requests.
Symptoms: Messages flowing Action: Normal operation
Client disconnected.
Symptoms: No more messages from client Action: Session cleanup
Subprocess error occurred.
Symptoms: Error messages, connection dropped Action: Check logs and subprocess stderr
Graceful shutdown in progress.
Symptoms: Closing connections Action: Wait for cleanup
Symptoms:
- Connection hangs
- No messages appear
/health/{namespace}shows "no subprocess"
Debug Steps:
- Watch
/debug/stream - See "connection" event?
- Check bridge logs for errors
Common Causes:
- Binary not found
- Wrong arguments
- Permission denied
- Port conflict
Fix:
# Check if binary exists
which npx
# Verify binary path
ls -la /path/to/binary
# Test manually
npx -y @modelcontextprotocol/server-git
# Check permissions
chmod +x /path/to/binarySymptoms:
- POST returns 202
- No response received
- SSE stream empty
Debug Steps:
- Watch
/debug/stream - See "in" message?
- See "out" message?
If "in" but no "out":
Problem: Subprocess not processing
Causes:
- Subprocess crashed
- Invalid JSON-RPC
- Subprocess not outputting to stdout
If no "in" message:
Problem: Request not reaching bridge
Causes:
- Network issue
- Wrong endpoint
- CORS blocked
Fix:
# Validate JSON-RPC
cat request.json | jq
# Check subprocess output
# Ensure each message ends with newline (\n)
# Check CORS
curl -v http://localhost:8080/mcp/git/messageSymptoms:
- Subprocess keeps restarting
/debug/streamshows crash events- Bridge logs show errors
Debug Steps:
- Check
/debug/stream- see crash events - Check subprocess stderr
- Look at bridge logs
Common Causes:
- Subprocess error
- Timeout
- Out of memory
- Config error
Fix:
# Check subprocess logs
sudo journalctl -u mcp-bridge -f
# Check resource usage
free -h
df -h
# Increase timeout if needed
# servers:
# git:
# timeout: 120s
# Check for memory issues
# servers:
# git:
# max_restarts: 10Symptoms:
- Browser console shows CORS error
- Request blocked
- No connection established
Debug Steps:
- Check browser console
- Verify
allowed_originsin config - Check origin matches exactly
Fix:
# Config
bridge:
allowed_origins:
- http://localhost:3000
- http://127.0.0.1:3000
# Ensure exact match (including protocol)
# http:// not https://
# localhost not 127.0.0.1 (unless both listed)Symptoms:
- Multiple sessions for same client
- Session ID conflicts
- Unexpected behavior
Debug Steps:
- Check
/debug/stream - See multiple "connected" events?
- Same session ID?
Fix:
# Ensure unique session IDs
# Client should generate unique IDs
# Session: session-{timestamp}# Real-time monitoring
curl -N http://localhost:8081/debug/stream
# Filter by namespace (if supported)
curl -N "http://localhost:8081/debug/stream?namespace=git"
# Save to file
curl -N http://localhost:8081/debug/stream > debug.log# Bridge health
curl http://localhost:8080/health
# Namespace health
curl http://localhost:8080/health/git
# Pretty print
curl http://localhost:8080/health/git | jq# HTML dashboard
curl http://localhost:8081/debug
# Open in browser
xdg-open http://localhost:8081/debug# Check subprocess status
ps aux | grep mcp
# Check ports in use
lsof -i :8080
lsof -i :8081
# Check for zombie processes
ps aux | grep defunctLocation:
# Systemd
sudo journalctl -u mcp-bridge -f
# Direct
tail -f /path/to/bridge.logCommon patterns:
{"level":"INFO","msg":"Connection established","namespace":"git"}
{"level":"ERROR","msg":"Subprocess crashed","namespace":"git"}
{"level":"WARN","msg":"High restart count","namespace":"git"}
Location:
# Depends on subprocess
# Check stderr outputCommon patterns:
Error: Cannot find module
Error: Port already in use
Error: Permission denied
Check active connections:
curl http://localhost:8081/debugMonitor over time:
# Script to monitor connections
while true; do
curl -s http://localhost:8081/debug | grep -c "session"
sleep 5
doneMessages per minute:
# Count messages in stream
curl -N http://localhost:8081/debug/stream | grep -c "event: message"Measure response time:
# Time request to completion
time curl -X POST http://localhost:8080/mcp/git/message \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"ping","params":{}}'Best practices:
- Only expose
debug_portinternally - Don't expose to public internet
- Monitor for suspicious activity
- Enable authentication (future feature)
Configuration:
bridge:
debug_port: 8081 # Internal onlyCurrent: No authentication Recommended: Use reverse proxy with auth Future: Built-in authentication
- Start with health check - Verify bridge is running
- Watch debug stream - See real-time activity
- Check subprocess logs - Find root cause
- Use curl with verbose - See HTTP details
- Monitor over time - Catch intermittent issues
Normal flow:
connection (connected)
→ message (in)
→ message (out)
→ message (in)
→ message (out)
connection (disconnected)
Error flow:
connection (connected)
→ message (in)
→ error (crashed)
connection (disconnected)
→ message (reconnecting)
- API.md - API specification
- CONFIG.md - Configuration reference
- EXAMPLES.md - Usage examples