WpfVisualTreeMcp
WpfVisualTreeMcp
Let AI agents see, debug and drive running WPF apps. Snoop + Playwright for AI, exposed over the Model Context Protocol — visual tree, data bindings, screenshots, clicks, text input and keyboard, against any running WPF process, no source changes needed.

An AI agent queries controls by visible text, fills the form, selects a list item, clicks Submit — then explains why the Status box stayed empty by pulling the app's binding errors. Every step is one MCP tool call (or CLI command).
Quickstart (60 seconds)
Download and extract the latest release zip (requires the .NET 8 Desktop Runtime).
Register it in your MCP client — for Claude Code, add to
.mcp.json:{ "mcpServers": { "wpf-visual-tree": { "command": "C:/path/to/WpfVisualTreeMcp.Server.exe", "args": [] } } }Ask your agent: "Look at my running WPF app and tell me why the Save button is disabled."
Prefer the terminal? The same exe is a full CLI: WpfVisualTreeMcp.Server.exe help.
Related MCP server: mcp-test-utils
Overview
WpfVisualTreeMcp is a Model Context Protocol (MCP) server that allows AI coding agents (Claude Code, Cursor, GitHub Copilot) to inspect and interact with running WPF applications. Think of it as giving your AI assistant the same capabilities as tools like Snoop WPF or Visual Studio's Live Visual Tree.
Why This Matters
Debugging WPF UI issues traditionally requires manual inspection with specialized tools. This project bridges that gap by exposing WPF inspection capabilities through MCP, enabling AI agents to:
Understand UI structure during code reviews
Diagnose binding errors automatically
Suggest fixes for layout issues
Assist with UI refactoring tasks
Analyze visual tree hierarchies in real-time
Features
Core Inspection
Process Discovery - List all running WPF applications available for inspection
Visual Tree Navigation - Traverse the complete visual tree hierarchy
Logical Tree Access - Navigate the logical tree structure
Property Inspection - Read all dependency properties of any UI element
Binding & Resources
Binding Analysis - Inspect bindings with converter, StringFormat, FallbackValue, MultiBinding support
DataContext Inspection - View DataContext type, properties, INPC status, and inheritance chain
Binding Error Detection - Automatically capture and report binding errors with classification
Resource Enumeration - Browse resource dictionaries at any scope
Style Inspection - View applied styles and templates
Search & Monitoring
Element Search - Find elements by type, name, or property values
Deep Search - Search entire tree including AdornerLayer and Popup elements
Property Watching - Monitor property changes in real-time
Interaction & Export
Screenshot Capture - Capture window/element screenshots visible to AI agents
Element Highlighting - Visually highlight elements in the running app
Control Click (v0.4.0) - Click elements via UI Automation (
Invoke/Toggle/Select/ExpandCollapse) or a real OS mouse clickSet Text (new in v0.5.0) - Fill a TextBox/ComboBox/PasswordBox via UI Automation
IValueProvider.SetValue, with aTextBox.Text/PasswordBox.Password/ reflected-Textfallback, orphysical=trueto type via OS keyboard input (full Unicode BMP)Send Keys (new in v0.5.0) - Send keyboard shortcuts (
Ctrl+S,Alt+F4,F5,Enter,Ctrl+Shift+F, ...) to an element or the focused window via OS keyboard inputLayout Information - Get detailed layout metrics
Tree Export - Export visual tree to XAML or JSON format
Auto-Injection - Inject Inspector into running WPF processes (no source changes needed); multi-architecture since v0.6.0 — a 64-bit server can inject into 32-bit WPF apps via a bundled
WpfInjectorHelper.exe
Dual-Mode CLI (new in v0.4.0)
The same WpfVisualTreeMcp.Server.exe runs as either an MCP stdio server
(no arguments, default) or as a one-shot CLI (any recognised subcommand).
Useful when the MCP server isn't connected, for scripting, and for verifying
the pipeline manually. Run WpfVisualTreeMcp.Server.exe help for the full
command list. Output is JSON on stdout; diagnostics go to stderr.
How it compares
vs. the general tool categories:
WpfVisualTreeMcp | FlaUI / WinAppDriver | Generic computer-use (screenshot + mouse) | ||
Consumer | AI agents (MCP) + humans (CLI) | Humans (GUI) | Test code (C#) | AI agents |
Visual tree, dependency properties | ✅ | ✅ | ❌ (UIA view only) | ❌ |
Data bindings, binding errors, DataContext | ✅ | ✅ | ❌ | ❌ |
Find controls by visible text / properties | ✅ | manual | partial (UIA) | pixel guessing |
Click / type / select / shortcuts | ✅ | ❌ | ✅ | ✅ (blind) |
Wait for UI conditions (no sleep loops) | ✅ | ❌ | ✅ | ❌ |
Element screenshots + popup-aware screen capture | ✅ | ❌ | partial | full screen only |
Works without target source changes | ✅ (auto-injection) | ✅ | ✅ | ✅ |
vs. other WPF MCP servers. Most WPF MCP servers are built on UI Automation (FlaUI): they read the accessibility tree, and can only reach WPF internals — bindings, DataContext, ViewModel state — if you install their in-process probe into the app you want to inspect. This server takes the Snoop route instead: it injects at runtime, so it reads the real visual tree and diagnoses binding errors and DataContext with zero changes to the target app — nothing to add to your build, nothing to ship into production.
WpfVisualTreeMcp | UIA-based servers (FlaUI) | Other injection-based servers | |
Sees the real visual tree (not just the UIA view) | ✅ injection | ❌ accessibility tree | ✅ |
Binding errors + DataContext without a probe in the target | ✅ | ❌ (needs in-process probe) | partial |
Interaction surface | click (UIA + physical, double/right), set-text w/ read-back, send-keys, select-item (virtualized) | click / type / select | usually invoke-only |
Wait for element conditions | ✅ | ✅ | ❌ |
Popup / dropdown / context-menu screenshots | ✅ screen mode | partial | screenshot only |
Cross-architecture injection (x64 ⇄ x86) | ✅ | n/a | ❌ |
Dual-mode: MCP server and one-shot CLI | ✅ | ❌ | ❌ |
Distribution | NuGet ( | varies | varies |
In short: UIA-based tools see what accessibility exposes, and computer-use agents see pixels. This project gives the agent the same insider view a WPF developer has in Snoop — with no probe to install in the target app — plus the widest set of hands to act on it, over a protocol every AI coding tool speaks.
Installation
Prerequisites
Windows 10/11
.NET 8.0 SDK or later
A WPF application to inspect
Installation
Option 1: .NET tool / NuGet (Recommended)
dotnet tool install -g WpfVisualTreeMcp # installs the `wpfinspect` commandThe package is also published as an MCP server package (PackageType: McpServer),
so MCP clients that support NuGet-hosted servers can launch it directly:
dnx WpfVisualTreeMcp # runs the MCP stdio serverOption 2: Download Release
Download the latest release from GitHub Releases:
Download
WpfVisualTreeMcp-vX.X.X-win-x64.zipExtract to a folder (e.g.,
C:\Tools\WpfVisualTreeMcp)The MCP server executable is
WpfVisualTreeMcp.Server.exe
Option 3: Build from Source
git clone https://github.com/faze79/WpfVisualTreeMcp.git
cd WpfVisualTreeMcp
dotnet build -c ReleaseConfiguration
The server uses the official Microsoft/Anthropic MCP SDK for .NET, providing guaranteed compatibility with Claude Code and other MCP clients.
Claude Code
Option 1: Command Line (Recommended)
Use the claude mcp add command to add the server directly:
# Add to current project only
claude mcp add wpf-visual-tree -- C:/path/to/WpfVisualTreeMcp/publish/WpfVisualTreeMcp.Server.exe
# Add globally (available in all projects)
claude mcp add --scope user wpf-visual-tree -- C:/path/to/WpfVisualTreeMcp/publish/WpfVisualTreeMcp.Server.exeYou can verify the server was added:
claude mcp listOption 2: Project-level JSON Configuration
Create or edit .mcp.json in your project root:
{
"mcpServers": {
"wpf-visual-tree": {
"command": "C:/path/to/WpfVisualTreeMcp/publish/WpfVisualTreeMcp.Server.exe",
"args": []
}
}
}Option 3: Global JSON Configuration
Add to ~/.claude/settings.json:
{
"mcpServers": {
"wpf-visual-tree": {
"command": "C:/path/to/WpfVisualTreeMcp/publish/WpfVisualTreeMcp.Server.exe",
"args": []
}
}
}Important Notes:
Use absolute paths to the built
.exefileUse forward slashes (
/) in paths on WindowsBuild in Release mode for production:
dotnet build -c ReleaseRestart Claude Code after configuration changes
Cursor
Add to your Cursor settings (.cursor/mcp.json):
{
"mcpServers": {
"wpf-visual-tree": {
"command": "C:/path/to/WpfVisualTreeMcp/publish/WpfVisualTreeMcp.Server.exe",
"args": []
}
}
}Self-Hosted Mode (Recommended)
For your WPF application to be inspectable, add a reference to the Inspector DLL and initialize it on startup:
Add a project reference to
WpfVisualTreeMcp.InspectorIn your
App.xaml.cs:
using System.Diagnostics;
using System.Windows;
using WpfVisualTreeMcp.Inspector;
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
// Initialize the WPF Visual Tree Inspector
InspectorService.Initialize(Process.GetCurrentProcess().Id);
}
protected override void OnExit(ExitEventArgs e)
{
InspectorService.Instance?.Dispose();
base.OnExit(e);
}
}This enables the MCP server to connect to your application via named pipes for real-time inspection.
Usage Examples
List Running WPF Applications
Use the wpf_list_processes tool to show all running WPF applications.Attach and Inspect Visual Tree
Attach to the MyApp.exe WPF application and show me the visual tree of the main window.Find Binding Errors
Check the attached WPF application for any binding errors and explain what's causing them.Search for Elements
Find all Button elements in the visual tree that have IsEnabled set to false.Export Visual Tree
Export the visual tree of the current window to JSON format so I can analyze the structure.Architecture
┌─────────────────────────────────────────────────────────────┐
│ AI Agent (Claude Code) │
└─────────────────────────┬───────────────────────────────────┘
│ MCP Protocol (stdio)
▼
┌─────────────────────────────────────────────────────────────┐
│ WpfVisualTreeMcp Server │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────┐ │
│ │ MCP Handler │ │ Tree Navigator │ │ Injector │ │
│ │ (Tools/Res.) │ │ & Inspector │ │ Manager │ │
│ └────────┬────────┘ └────────┬────────┘ └──────┬──────┘ │
└───────────┼────────────────────┼───────────────────┼────────┘
│ │ │
└────────────────────┼───────────────────┘
│ Named Pipes / IPC
▼
┌─────────────────────────────────────────────────────────────┐
│ Target WPF Application │
│ ┌─────────────────────────────────────────────────────────┐│
│ │ Injected Inspector DLL ││
│ │ • VisualTreeHelper access ││
│ │ • LogicalTreeHelper access ││
│ │ • Property/Binding inspection ││
│ │ • Resource dictionary enumeration ││
│ └─────────────────────────────────────────────────────────┘│
└─────────────────────────────────────────────────────────────┘For detailed architecture documentation, see docs/ARCHITECTURE.md.
Available Tools
Tool | Description |
| List all running WPF applications |
| Attach to a WPF application (supports |
| Get the visual tree hierarchy (default depth: 25, max: 100) |
| Get all dependency properties of an element |
| Query elements by type, x:Name, visible text, property values and visibility; results include text, automation id, enabled/visible state and screen bounds |
| Same query filters without result limit, across all windows including adorners/popups |
| Capture a screenshot of the window or element (returns image); |
| Get data bindings for an element (includes MultiBinding, converter, StringFormat) |
| List all captured binding errors |
| Clear the captured binding errors list |
| Get DataContext type, properties, INPC status, and inheritance chain |
| Enumerate resource dictionaries |
| Get applied styles and templates |
| Monitor a property for changes |
| Live-edit a dependency property at runtime (type-converted), to test a change without rebuilding. State-changing, reversible. |
| Undo |
| Visually highlight an element |
| Click a control — UI Automation invoke ( |
| Select an item in a ComboBox/ListBox/ListView/TabControl by visible text or index — works with virtualized items. State-changing. |
| Wait until an element is visible/exists/enabled/hidden, polling in the target app — no sleep-and-retry loops. |
| Set text/value of a TextBox/ComboBox/PasswordBox — UI Automation |
| Send a keyboard shortcut ( |
| Get layout information |
| Export visual tree to XAML or JSON |
For complete tool documentation, see docs/TOOLS_REFERENCE.md.
Roadmap
Phase 1: Core Inspection ✅
Project structure and architecture
Process discovery and enumeration
Basic process attachment
Visual tree navigation
Property inspection
Element search
Phase 2: Advanced Features ✅
IPC communication via named pipes
Binding analysis and error detection
Resource dictionary enumeration
Style and template inspection
Property change monitoring (with notifications)
Phase 3: Interaction & Diagnostics ✅
Element highlighting overlay
XAML/JSON export
Screenshot capture (returns MCP
ImageContentBlock)DLL auto-injection into running WPF processes (x64/x86)
AdornerLayer and Popup visual tree traversal
Phase 4: CLI + Driving the App ✅ (v0.4.0 / v0.5.0)
Dual-mode executable (MCP stdio + one-shot CLI) (v0.4.0)
Control click via UI Automation patterns (v0.4.0)
Physical OS mouse click as opt-in fallback (v0.4.0)
User-level Claude Code skill bundling the CLI (v0.4.0)
Set text/value via UI Automation
IValueProvider+ fallbacks (v0.5.0)Physical keyboard typing with Unicode BMP support (v0.5.0)
Keyboard shortcuts (
Ctrl+S,Alt+F4,F5, ...) via OS input (v0.5.0)
Phase 5: Multi-architecture ✅ (v0.6.0)
Cross-bitness auto-injection (64-bit server → 32-bit target)
Architecture-matching
WpfInjectorHelper.exe(32-bit .NET 8)Removes v0.5.0 known limitation; both x86 and x64 WPF apps drivable
Phase 6: Query engine & full driving ✅ (v0.7.0)
Query elements by visible text, property values, visibility
Enriched results: text, automation id, enabled/visible state, screen bounds
wpf_select_item— select in ComboBox/ListBox/TabControl by text or indexDouble / right click; scroll-into-view before physical input
Screen-mode screenshots (popups, dropdowns, context menus visible)
Set-text read-back verification; weak element-handle cache
Critical IPC serialization fix (request parameters were silently dropped)
Phase 7: Distribution & agent ergonomics ✅ (v0.7.1 / v0.8.0)
NuGet package, installable via
dnx/dotnet tool install(MCP server package type)Published to nuget.org (trusted publishing / OIDC) and the official MCP registry
Binding-error capture fixed (was never wired up), IPC parameter-drop fix
wpf_wait_for— wait for an element/condition, no sleep-and-retry loopsConcurrent IPC connections (a long wait no longer blocks other commands)
Next up
Live property editing shipped in v0.9.0 (wpf_set_property + wpf_revert_property).
Next: wpf_diff to measure the before/after effect automatically.
wpf_set_property/wpf_revert_property— live-edit a dependency property, then undo (v0.9.0)wpf_diff— before/after snapshot to verify a change's effectwpf_record→wpf_export_test— record a driven workflow, export an xUnit + driver testInspector-only NuGet package for self-hosted mode (reference instead of injection)
Streaming binding-error / property-change notifications to the MCP client
WinUI 3 support
See docs/ROADMAP.md for the full prioritized plan (rationale, design notes, effort, and suggested sequencing).
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development Setup
Clone the repository:
git clone https://github.com/faze79/WpfVisualTreeMcp.git cd WpfVisualTreeMcpOpen in Visual Studio 2022 or VS Code:
code . # or start WpfVisualTreeMcp.slnBuild and run tests:
dotnet build dotnet testRun the sample WPF app for testing:
dotnet run --project samples/SampleWpfApp
Project Structure
WpfVisualTreeMcp/
├── src/
│ ├── WpfVisualTreeMcp.Server/ # MCP Server (.NET 8) - Uses official MCP SDK
│ │ ├── Program.cs # Server initialization with MCP SDK
│ │ ├── WpfTools.cs # 20 WPF tools (17 inspection + click/set-text/send-keys)
│ │ ├── Cli/CliRunner.cs # One-shot CLI front-end (v0.4.0)
│ │ └── Services/ # Process & IPC management
│ ├── WpfVisualTreeMcp.Inspector/ # Injected DLL (.NET Framework 4.8)
│ ├── WpfVisualTreeMcp.Injector/ # Managed injection logic (CreateRemoteThread; net48 + net8.0)
│ ├── WpfVisualTreeMcp.InjectorHelper/# x86 .NET 8 helper exe for cross-arch injection (v0.6.0)
│ ├── WpfVisualTreeMcp.Bootstrapper/ # Native C++ DLL for CLR hosting
│ └── WpfVisualTreeMcp.Shared/ # Shared models & IPC contracts
├── samples/
│ └── SampleWpfApp/ # Test application
├── tests/
│ └── WpfVisualTreeMcp.Tests/ # Unit tests (48 tests)
├── publish/ # Published server + native DLLs
│ └── native/{x64,x86}/ # Architecture-specific bootstrapper
└── docs/ # DocumentationTechnical Details
MCP SDK: Built with the official C# MCP SDK from Microsoft/Anthropic
Protocol: JSON-RPC 2.0 over stdio transport
Target Framework: .NET 8.0 (Server) / .NET Framework 4.8 + .NET 8.0-windows (Inspector, dual-target)
IPC: Named Pipes for server-to-application communication
Tools: 24 tools auto-discovered via
[McpServerTool]attributes (18 read-only inspection incl.wpf_wait_for+ 6 state-changing:wpf_click_element,wpf_select_item,wpf_set_text,wpf_send_keys,wpf_set_property,wpf_revert_property)CLI: same executable runs as one-shot CLI when given a subcommand (
Program.csroutes viaCliRunner.IsCliCommand)
Acknowledgments
Inspired by Snoop WPF - the original WPF spy utility
Built on the Model Context Protocol by Anthropic
Thanks to the .NET and WPF community
License
This project is licensed under the MIT License - see the LICENSE file for details.
This server cannot be installed
Maintenance
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/faze79/WPFVisualTreeMcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server