Expand description
§Dioxus Inspector
HTTP bridge for inspecting and debugging Dioxus Desktop apps. Embed this in your app to enable MCP-based debugging from Claude Code.
§Quick Start
ⓘ
use dioxus::prelude::*;
use dioxus_inspector::{start_bridge, EvalResponse};
fn main() {
dioxus::launch(app);
}
fn app() -> Element {
use_inspector_bridge(9999, "my-app");
rsx! { div { "Hello, inspector!" } }
}
fn use_inspector_bridge(port: u16, app_name: &str) {
use_hook(|| {
let mut eval_rx = start_bridge(port, app_name);
spawn(async move {
while let Some(cmd) = eval_rx.recv().await {
let result = document::eval(&cmd.script).await;
let response = match result {
Ok(val) => EvalResponse::success(val.to_string()),
Err(e) => EvalResponse::error(e.to_string()),
};
let _ = cmd.response_tx.send(response);
}
});
});
}§Architecture
Claude Code <--MCP--> dioxus-mcp <--HTTP--> dioxus-inspector <--eval--> WebView- Call
start_bridgewith a port and app name - Poll the returned receiver for
EvalCommands - Execute JavaScript via
document::eval()and send responses back
§HTTP Endpoints
| Endpoint | Method | Purpose |
|---|---|---|
/status | GET | App status, PID, uptime |
/eval | POST | Execute JavaScript in webview |
/query | POST | Query DOM by CSS selector |
/dom | GET | Get simplified DOM tree |
/inspect | POST | Element visibility analysis |
/validate-classes | POST | Check CSS class availability |
/diagnose | GET | Quick UI health check |
/screenshot | POST | Capture window (macOS only) |
/resize | POST | Resize window (requires app handling) |
§Platform Support
- Screenshot capture: macOS only (uses Core Graphics)
- All other features: Cross-platform
Structs§
- Bridge
State - Shared state for the HTTP bridge.
- Eval
Command - Command sent from HTTP server to Dioxus app for JavaScript evaluation.
- Eval
Request - Request to evaluate JavaScript in the webview.
- Eval
Response - Response from JavaScript evaluation.
- Query
Request - Query request for CSS selector.
- Resize
Request - Request to resize the window.
- Resize
Response - Response from resize operation.
- Status
Response - Status response showing bridge health.
Functions§
- start_
bridge - Start the inspector HTTP bridge.