Declarative.Avalonia.AgentTools
12.1.1
See the version list below for details.
dotnet add package Declarative.Avalonia.AgentTools --version 12.1.1
NuGet\Install-Package Declarative.Avalonia.AgentTools -Version 12.1.1
<PackageReference Include="Declarative.Avalonia.AgentTools" Version="12.1.1" />
<PackageVersion Include="Declarative.Avalonia.AgentTools" Version="12.1.1" />
<PackageReference Include="Declarative.Avalonia.AgentTools" />
paket add Declarative.Avalonia.AgentTools --version 12.1.1
#r "nuget: Declarative.Avalonia.AgentTools, 12.1.1"
#:package Declarative.Avalonia.AgentTools@12.1.1
#addin nuget:?package=Declarative.Avalonia.AgentTools&version=12.1.1
#tool nuget:?package=Declarative.Avalonia.AgentTools&version=12.1.1
Declarative.Avalonia.AgentTools
In-process MCP (Model Context Protocol) inspector for AI agents that build UI with
Avalonia.Markup.Declarative.
In a debug build it exposes the running app to an agent over loopback so the agent can close the feedback loop while iterating on a view:
get_app_info— windows, focus, popups, theme, versions, hot-reload/interaction state (call first)get_visual_tree— text visual tree with names, local bounds and absoluteabs=/center=client-DIP coords (the frameclick_at/tap/drag/hit_testshare);maxDepth/filterto trim; open popups includedget_layout— detailed layout for one control: bounds, window-relative position, requested vs actual size, alignment, margin/padding, visibility, off-screen/clipped flags, and the ancestor chainget_properties— effective state + every locally-set styled propertyget_property_sources— where each value came from (local / style / template / animation / inherited)get_data_context— the control's view-model rendered as text (debug bindings)get_source— theViewBasecomponent that built a control (which class to edit); optionalfile:linefind_text/hit_test— locate controls by visible text or by pixel coordinate (hit_testalso reports how the control can be driven: automation-invokable / focusable / raw-pointer-only)layout_audit— automated layout lint (zero-size, off-screen, overlap, out-of-parent, text-clipped)list_components— active declarative viewsscreenshot_window(withannotate) /screenshot_control/screenshot_region— PNG screenshots (image content blocks);scaleenlarges with nearest-neighbour so pixel art stays crisp,maxWidthcaps the payload, andscreenshot_regioncrops an arbitrary rectangle — the way to look inside a custom canvas that the visual tree sees as one opaque controlcompare_screenshots/list_screenshots— before/after pixel diff (red diff image + % changed)highlight— draw a frame around a control (or all of a type) and screenshot it;action='clear'clearswait_for/wait_idle— sync after an interaction or hot reloadget_errors— recent build / binding / converter / runtime errors (incl. exceptions in handlers)get_logs— the app's raw log output (Avalonia'sLoggerand stdout/stderr) from an in-process ring buffer, so you can read what the app printed even when the developer, not you, started the processget_render_stats— measured fps, last layout pass count/duration, visual count, size and scaling: catch a performance regression without a profilertap,drag,pointer_press/pointer_move/pointer_release,pointer_wheel,touch_press/touch_move/touch_release,pinch— (optional, off by default) real synthesized input through Avalonia's input pipeline: works on custom controls with hand-written pointer handlers and no automation peer (scrub a Border slider, move a thumb, draw). Includes genuine double clicks (tap count=2really producesClickCount == 2), wheel/touchpad deltas in notches, pen pressure and the inverted eraser end, and multi-finger gesturesinvoke,set_window_size,set_theme,click_at,open_popup,list_bindable,set_view_model,invoke_command— (optional, off by default) remote control: invoke / select / select_item / toggle / set / expand / collapse / focus / scroll / scroll_by / context_menu / key / type (key/typesend real input), plus resize, theme switch, pointer-first click-by-coordinate, open a closed popup, list a DataContext's bindable surface, and an escape hatch to set a view-model property or run anICommand/method directly (structured, actionable errors; reach awkward states without restarting)- your own tools — register app-specific tools so the agent can reach what the generic ones cannot (see below)
Usage
var appBuilder = AppBuilder.Configure<App>()
.UsePlatformDetect()
#if DEBUG
.UseAgentInspector() // loopback MCP server on 127.0.0.1:5599
#endif
.SetupWithLifetime(lifetime);
Your own tools
To the inspector, a custom drawing surface is one opaque Control filling the window — the scene, layers
and pixels inside it are reachable only through tools your app writes. Register them with
WithTools<T>(); instance methods run on a single instance built from your IServiceProvider, so a tool
can take the app's real services in its constructor:
[McpServerToolType]
public sealed class SpriteTools(AppState state)
{
[McpServerTool(Name = "get_sprite_info", ReadOnly = true), Description(
"Returns the open sprite's size, frame count and the selected layer.")]
public string GetSpriteInfo() => $"{state.Sprite.Size}, {state.Sprite.Frames.Count} frame(s)";
}
.UseAgentInspector(o =>
{
o.EnableInteraction = true;
o.Services = serviceProvider;
o.WithTools<SpriteTools>();
})
Mark a state-changing tool type [AgentInteractionTools] and it is registered only when
EnableInteraction is set, leaving your read-only tools available either way.
Enable the MCP in your agent
The server speaks streamable HTTP on loopback, so any MCP client points at the same endpoint —
http://127.0.0.1:5599. Run the app under dotnet watch so the agent's edits hot-reload into the
live process it is inspecting.
Claude Code — one command (or a project-scoped .mcp.json):
claude mcp add --transport http avalonia-agent-inspector http://127.0.0.1:5599
// .mcp.json (project root)
{
"mcpServers": {
"avalonia-agent-inspector": {
"type": "http",
"url": "http://127.0.0.1:5599"
}
}
}
opencode — add it under mcp in opencode.json with type: "remote":
// opencode.json
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"avalonia-agent-inspector": {
"type": "remote",
"url": "http://127.0.0.1:5599",
"enabled": true
}
}
}
Codex — add an [mcp_servers.*] table to ~/.codex/config.toml (or the project's .codex/config.toml):
# ~/.codex/config.toml
[mcp_servers.avalonia-agent-inspector]
url = "http://127.0.0.1:5599"
# First time you use a streamable-HTTP MCP with Codex, enable the RMCP client once:
[features]
experimental_use_rmcp_client = true
Show a live "agent connected" status in your UI (like Chrome DevTools) by subscribing to
AgentConnectionMonitor — events are raised on the UI thread:
#if DEBUG
AgentConnectionMonitor.StatusChanged += (_, e) =>
window.Title = e.IsConnected ? "🟢 Agent connected — My App" : "My App";
#endif
Dev only. Keep the call under
#if DEBUG. This package pulls in the ASP.NET Core web stack and a remote-control surface; it must not ship in Release. The server binds to loopback only, and the tier-2 tools (invoke,set_window_size,set_theme,click_at, the pointer/wheel/touch synthesis tools,set_view_model,invoke_command) stay disabled unless you setEnableInteraction = true.
See the repository's docs/agent-tools.md for the full guide.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Avalonia.Markup.Declarative (>= 12.1.1)
- ModelContextProtocol.AspNetCore (>= 1.4.0)
-
net8.0
- Avalonia.Markup.Declarative (>= 12.1.1)
- ModelContextProtocol.AspNetCore (>= 1.4.0)
-
net9.0
- Avalonia.Markup.Declarative (>= 12.1.1)
- ModelContextProtocol.AspNetCore (>= 1.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 12.1.2-fix-agent.1 | 79 | 8/3/2026 |
| 12.1.1 | 489 | 8/2/2026 |
| 12.1.0 | 121 | 7/18/2026 |
| 12.0.6-preview2 | 115 | 7/8/2026 |
| 12.0.6-preview1 | 103 | 7/7/2026 |
| 12.0.5 | 130 | 7/3/2026 |
| 12.0.5-preview1 | 112 | 6/20/2026 |