JSON-RPC Debugger
A terminal-based JSON-RPC debugger with interception capabilities, built with Rust and ratatui. Inspect, modify, and debug JSON-RPC requests and responses in real-time.
Demo video of pointing metamask JSON-RPC at the debugger:
https://github.com/user-attachments/assets/20a23f55-e3b8-44b1-9536-fcc1fd6e09dc
Features
- π Real-time monitoring of JSON-RPC requests and responses with timing information
- βΈοΈ Request interception - pause, inspect, and modify requests before forwarding
- π¨ Syntax highlighting for JSON content with proper indentation
- π HTTP headers display for debugging transport details
- β¨οΈ Vim-style navigation with comprehensive keyboard shortcuts
- π― Dynamic configuration - change target URL and port on the fly
- π External editor support for request/response modification
- π Table view with status, transport, method, ID, and duration columns
- π Custom response creation for intercepted requests
Installation
Prerequisites
- Rust 1.70+ (install from rustup.rs)
Install from crates.io
Install from GitHub
Build from source
Install locally
Usage
Basic Usage
Start the debugger with default settings (port 8080, no default target):
# or during development:
Command Line Options
# Custom port
# Custom target URL
# Both custom port and target
# Show help
Making Requests
Once the debugger is running, send JSON-RPC requests to the proxy:
Interface Overview
The TUI is divided into three main sections:
ββ Status ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β JSON-RPC Debugger | Status: RUNNING | Port: 8080 | Target: https://api.example.com β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββ JSON-RPC βββββββββββββββββββββββββββββ ββ Details βββββββββββββββββββββββββββββββββββ
β Status βTransportβMethod βIDβDurβ β Transport: Http β
β β Success β HTTP β eth_call β1 β45mβ β Method: eth_call β
β β Error β HTTP β eth_send β2 β12mβ β ID: 1 β
ββ³ Pending β HTTP β eth_blockβ3 β11mβ β β
β β β REQUEST: β
β β β HTTP Headers: β
β β β content-type: application/json β
β β β β
β β β JSON-RPC Request: β
β β β { β
β β β "jsonrpc": "2.0", β
β β β "method": "eth_call", β
β β β "params": [...], β
β β β "id": 1 β
β β β } β
βββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββ
ββ Controls ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β q quit | ββ/^n/^p navigate | j/k/d/u/G/g scroll | s start/stop | t target | p pause β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Status Indicators
- β Success - Request completed successfully
- β Error - Request returned an error
- β³ Pending - Request sent, waiting for response
Keyboard Shortcuts
Navigation
β/β
orCtrl+p/Ctrl+n
- Navigate between requestsj/k
- Scroll details panel up/down (vim-style)d/u
orCtrl+d/Ctrl+u
- Page down/up in detailsG
- Go to bottom of detailsg
- Go to top of details
Proxy Control
s
- Start/stop the proxy servert
- Edit target URLc
- Create new request (normal mode) / Complete request with custom response (intercept mode)q
- Quit application
Interception Mode
p
- Toggle pause mode (intercept new requests)a
- Allow selected intercepted requeste
- Edit selected request body in external editorh
- Edit selected request headers in external editorc
- Complete request with custom responseb
- Block selected requestr
- Resume all pending requests
Request Interception
The debugger supports Charles Proxy-style request interception:
- Enable pause mode: Press
p
to start intercepting requests - Make requests: Send JSON-RPC requests to the proxy
- Inspect: Intercepted requests appear in the pending list with βΈ icon
- Modify:
- Press
e
to edit request body in your external editor - Press
h
to edit HTTP headers - Press
c
to create a custom response
- Press
- Control: Press
a
to allow,b
to block, orr
to resume all
External Editor
The debugger uses your system's default editor for request modification:
- Checks
$EDITOR
environment variable - Falls back to
$VISUAL
- Defaults to
vim
, thennano
, thenvi
Modified requests show with a β icon and [MODIFIED] or [BODY]/[HEADERS] labels.
Configuration
Environment Variables
EDITOR
- Preferred text editor for request modificationVISUAL
- Alternative editor (fallback)
Port Conflicts
Some ports may conflict with system services:
- Port 7000: Used by Apple AirPlay on macOS
- Port 5000: Often used by other development tools
Use alternative ports like 8080, 9090, 3000, 4000, 8000, or 8888.
Examples
Basic Monitoring
# Start debugger
# Set target URL in the TUI (press 't')
# Then make requests in another terminal
Request Interception
- Start the debugger:
jsonrpc-debugger
- Set target URL: Press
t
and enter your target - Enable pause mode: Press
p
- Make a request (it will be intercepted)
- Edit the request: Press
e
to modify body orh
for headers - Allow the modified request: Press
a
Custom Responses
- Enable pause mode and intercept a request
- Press
c
to create a custom response - Edit the JSON response in your external editor
- The custom response is sent back to the client
Creating New Requests
- Press
c
in normal mode - Edit the JSON-RPC request template in your external editor
- The request is sent through the proxy to the target
Troubleshooting
Port Already in Use
If you get a "port already in use" error:
# Check what's using the port
|
# Use a different port
Connection Refused
If requests fail with "connection refused":
- Check that the target URL is correct and reachable
- Verify the target server is running
- Test the target directly with curl
- Make sure you've set a target URL (press
t
in the TUI)
Editor Not Found
If external editing fails:
# Set your preferred editor
# VS Code
# Nano
# Vim
JSON Formatting Issues
The debugger displays JSON with:
- 2-space indentation
- Syntax highlighting (keys in cyan, strings in green, numbers in blue, etc.)
- Proper line breaks and formatting
If JSON appears malformed, check that the original request/response is valid JSON.
Development
Running Tests
Building
# Debug build
# Release build
Project Structure
src/
βββ main.rs # CLI and main application loop
βββ app.rs # Application state and logic
βββ ui.rs # TUI rendering and layout
βββ proxy.rs # HTTP proxy server implementation
βββ lib.rs # Library exports for testing
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request