Skip to main content
net10.0net8.0net9.0

In-process MCP (Model Context Protocol) inspector for AI agents building UI with Avalonia.Markup.Declarative. In a debug build it exposes the running app to an agent over loopback: visual-tree dumps with bounds, window/control screenshots, the active component list, and build/binding errors. Debug/dev only β€” do not ship in Release.

Published
Jul 7, 2026
3mo ago
Total Downloads
1.5K
1,492

Install

dotnet add package Declarative.Avalonia.AgentTools --version 12.0.6-preview1
ProductVersions
.NET
net10.0net8.0net9.0

README

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/bounds; maxDepth/filter to trim; open popups included
  • get_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 chain
  • get_properties β€” effective state + every locally-set styled property
  • get_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 β€” the ViewBase component that built a control (which class to edit); optional file:line
  • find_text / hit_test β€” locate controls by visible text or by pixel coordinate
  • layout_audit β€” automated layout lint (zero-size, off-screen, overlap, out-of-parent, text-clipped)
  • list_components β€” active declarative views
  • screenshot_window (with annotate) / screenshot_control β€” PNG screenshots (image content blocks)
  • compare_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' clears
  • wait_for / wait_idle β€” sync after an interaction or hot reload
  • get_errors β€” recent build / binding / converter / runtime errors (incl. exceptions in handlers)
  • invoke, set_window_size, set_theme, click_at β€” (optional, off by default) remote control: invoke / select / select_item / toggle / set / expand / collapse / focus / scroll / scroll_by / context_menu / key / type, plus resize, theme switch, and click-by-coordinate

Usage

var appBuilder = AppBuilder.Configure<App>()
    .UsePlatformDetect()
#if DEBUG
    .UseAgentInspector() // loopback MCP server on 127.0.0.1:5599
#endif
    .SetupWithLifetime(lifetime);

Point your agent's MCP client at the streamable-HTTP endpoint http://127.0.0.1:5599.

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) stay disabled unless you set EnableInteraction = true.

See the repository's docs/agent-tools.md for the full guide.

Changes from Previous Version

No structural changes between v12.0.5 and v12.0.6-preview1.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.