1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 05:10:03 -04:00

Add egui_kittest_mcp server

New binary crate that exposes an MCP (Model Context Protocol) server backed by
the `egui_inspection` protocol. The server bridges a running egui peer — a
spawned `egui_kittest` harness child process or an attached live `eframe` app —
to MCP tool handlers that drive it.

Components:
- `bridge.rs`: spawns / attaches a peer over a unix socket, runs reader+writer
  Tokio tasks that pump `HarnessMessage` ↔ `InspectorCommand` and track the
  peer's `Hello`, latest frame, accesskit tree, and blocked / finished state.
- `tools.rs`: `rmcp`-derived tool router with commands for stepping, event
  injection (click / type / scroll / hover / drag / keys), resizing, screenshot
  capture, accesskit tree queries, and lifecycle (launch / attach / kill).
- `tree.rs`: accesskit-tree projection helpers shared by the tools.
- `shim.rs` / `main.rs`: shim role that lets the same binary act as the child
  inspector for kittest harnesses, relaying bytes between the harness stdio
  and the MCP server's unix socket.
- `server.rs`: rmcp stdio entry point.

Live-app example added at `examples/egui_mcp/`.
This commit is contained in:
lucasmerlin
2026-05-21 12:11:00 +02:00
parent e3bdddf306
commit e15ba138d6
11 changed files with 2553 additions and 9 deletions

View File

@@ -0,0 +1,27 @@
//! Headless `egui_demo_lib` target for the kittest MCP server.
//!
//! Build a [`Harness`] around [`DemoWindows`] and step forever. The
//! [`egui_kittest::InspectorPlugin`] auto-attaches whenever `KITTEST_INSPECTOR` is set
//! (the MCP server's `launch` tool sets it), drives the harness via stdio, and blocks
//! inside `after_step` until the agent requests the next frame.
#![expect(rustdoc::missing_crate_level_docs)]
use egui::Vec2;
use egui_demo_lib::DemoWindows;
use egui_kittest::Harness;
fn main() {
let mut demo = DemoWindows::default();
let mut harness = Harness::builder()
.with_size(Vec2::new(1024.0, 768.0))
.wgpu()
.build_ui(move |ui| {
demo.ui(ui);
});
loop {
harness.step();
}
}