XamlMcp: an MCP server for XAML apps

XamlMcp lets Claude Code, Codex, GitHub Copilot, and other AI coding assistants inspect and drive live Avalonia, WPF, WinUI 3, and .NET MAUI applications. Use the Model Context Protocol to read the UI tree, properties, styles, and resources; capture screenshots; send input; and run automation actions.

Checking NuGet… Apache-2.0
Use it when Your AI needs live UI context

Debug visual state, inspect control properties, reproduce interactions, or verify a UI change.

Architecture Agent package + MCP server

A small in-process framework agent connects to the xamlmcp server over an authenticated local transport.

Supported XAML frameworks

The same protocol covers four UI frameworks. Some operations depend on platform or runtime capabilities; check the full feature matrix for exact limits.

Install the XAML MCP server

The application references one framework agent. Your development environment also needs the xamlmcp MCP server tool.

Install a framework agent

Choose the package that matches the application.

Terminal
dotnet add package XamlMcp.Avalonia --version VERSION
dotnet add package XamlMcp.Wpf --version VERSION
dotnet add package XamlMcp.WinUI --version VERSION
dotnet add package XamlMcp.Maui --version VERSION

Choose how to run the MCP server

The client setup below runs the pinned package with dnx and needs no global installation. If you prefer a permanent xamlmcp command, install the .NET tool:

Terminal
dotnet tool install --global XamlMcp.Server --version VERSION

Attach the agent

Select your framework for the exact startup code and release-gating behavior.

Add the fluent attachment in BuildAvaloniaApp. This form stays inert unless XAML_MCP=1 exists at launch.

Program.cs
using XamlMcp.Avalonia;

AppBuilder.Configure<App>()
    .UsePlatformDetect()
    .AttachXamlMcp();

For hard exclusion from Release binaries, wrap .AttachXamlMcp() in your own #if DEBUG.

Configure Claude, Codex, and GitHub Copilot

XamlMcp runs as a local stdio MCP server. Your client starts it when needed; you do not run a persistent server process. The commands below pin the published preview and require the .NET 10 SDK.

Claude CodeCLI

Add XamlMcp for your Claude Code user account. Use --scope project instead if you want a committable project configuration.

Terminal
claude mcp add --scope user xamlmcp -- dnx XamlMcp.Server@VERSION

Run claude mcp list to confirm the server is registered. Claude Code MCP documentation ↗

CodexCLI, app, and IDE

Add the server once. Codex CLI, the Codex app, and the IDE extension share the same MCP configuration.

Terminal
codex mcp add xamlmcp -- dnx XamlMcp.Server@VERSION

Run codex mcp list or use /mcp inside Codex to verify the connection. Codex MCP documentation ↗

GitHub CopilotVS Code

Create .vscode/mcp.json in the repository.

.vscode/mcp.json
{
  "servers": {
    "xamlmcp": {
      "command": "dnx",
      "args": ["XamlMcp.Server@VERSION"]
    }
  }
}

Select Start above the server entry, then open Copilot Chat in Agent mode and enable its tools. GitHub Copilot MCP documentation ↗

Other MCP clientsGeneric stdio

For clients that use the common mcpServers configuration shape, register the executable directly.

MCP configuration
{
  "mcpServers": {
    "xamlmcp": {
      "command": "dnx",
      "args": ["XamlMcp.Server@VERSION"]
    }
  }
}

Configuration filenames and top-level keys vary by client. Use stdio transport. If you install XamlMcp.Server globally, you can replace the dnx command and arguments with xamlmcp.

Verify the XamlMcp connection

Launch the instrumented application first. For Avalonia's fluent attachment form, launch it with XAML_MCP=1. Then open Claude Code or Codex with the XamlMcp server enabled and ask:

Prompt
Use XamlMcp to list the running applications, attach to my app, and show its UI tree.

The client performs this tool sequence:

Discoverlist-apps
Connectattach(instanceId)
Inspecttree

If the client returns the application's UI tree, the framework package, discovery transport, MCP server, authentication, and client configuration are working together. These are MCP tool calls made by the AI client, not terminal commands.

Native dialogs and windows

A native file picker or message box is a separate Win32 window. It does not belong to the application's XAML tree, so it will not appear in tree and ordinary XamlMcp input cannot address it.

The optional Windows Driver runs inside XamlMcp.Server to cover that boundary. It is disabled by default. Enable it in the command registered with your MCP client:

Terminal
claude mcp add --scope user xamlmcp -- dnx XamlMcp.Server@VERSION --enable-driver
codex mcp add xamlmcp -- dnx XamlMcp.Server@VERSION --enable-driver

dialog-wait and dialog-act handle app-opened native dialogs. window-list and window-act inspect and manage the application's top-level windows.

The Driver only accepts windows owned by the attached process. Dialogs must appear after a mutating XamlMcp call, file paths must stay inside configured roots, and elevated applications and non-interactive sessions are rejected.

XAML inspection and automation tools

XamlMcp exposes a consistent tool surface across frameworks. The capability map returned by attach is authoritative for the current process.

ToolsPurpose
tree, search, ancestorsNavigate visual or logical UI nodes.
props, set-propRead properties, value sources, automation patterns, and command slots; write or clear local values.
styles, resourcesInspect style information and resolved resources.
screenshotCapture a window or node as an MCP image.
input, actionSend input or use automation patterns and bound commands.
assets, open-assetEnumerate and read framework assets through safe identifiers.
dialog-*, window-*Optional Windows driver for app-owned native dialogs and windows.