wpf_list_processes
List all running WPF applications available for inspection
Parameters
No parameters.
Raw schema
{
"type": "object",
"properties": {},
"required": []
}by faze79 · C#
Let AI agents inspect and drive running WPF apps: tree, bindings, screenshots, clicks, text input.
Let AI agents inspect and drive running WPF apps: tree, bindings, screenshots, clicks, text input.
Declared in the repository manifest (mcp.json). Not verified against a live endpoint.
List all running WPF applications available for inspection
Parameters
No parameters.
{
"type": "object",
"properties": {},
"required": []
}Attach to a WPF application by process ID or name
| process_id | integer | optional | Process ID to attach to |
| process_name | string | optional | Process name to attach to (e.g., 'MyApp' or 'MyApp.exe') |
{
"type": "object",
"properties": {
"process_id": {
"type": "integer",
"description": "Process ID to attach to"
},
"process_name": {
"type": "string",
"description": "Process name to attach to (e.g., 'MyApp' or 'MyApp.exe')"
}
},
"required": []
}Get the visual tree hierarchy starting from a root element
| root_handle | string | optional | Handle of root element (optional, defaults to main window) |
| max_depth | integer | optional | Maximum tree depth to traverse |
{
"type": "object",
"properties": {
"root_handle": {
"type": "string",
"description": "Handle of root element (optional, defaults to main window)"
},
"max_depth": {
"type": "integer",
"description": "Maximum tree depth to traverse",
"default": 10,
"minimum": 1,
"maximum": 100
}
},
"required": []
}Get all dependency properties of a UI element
| element_handle | string | required | Handle of the element to inspect |
{
"type": "object",
"properties": {
"element_handle": {
"type": "string",
"description": "Handle of the element to inspect"
}
},
"required": [
"element_handle"
]
}Search for elements by type, name, or property value
| type_name | string | optional | Element type name (e.g., 'Button', 'TextBox', 'System.Windows.Controls.Button') |
| element_name | string | optional | x:Name of the element to find |
| property_filter | object | optional | Property name/value pairs to filter by |
{
"type": "object",
"properties": {
"type_name": {
"type": "string",
"description": "Element type name (e.g., 'Button', 'TextBox', 'System.Windows.Controls.Button')"
},
"element_name": {
"type": "string",
"description": "x:Name of the element to find"
},
"property_filter": {
"type": "object",
"description": "Property name/value pairs to filter by",
"additionalProperties": {
"type": "string"
}
}
},
"required": []
}Get all data bindings for an element with their status
| element_handle | string | required | Handle of the element to inspect |
{
"type": "object",
"properties": {
"element_handle": {
"type": "string",
"description": "Handle of the element to inspect"
}
},
"required": [
"element_handle"
]
}List all binding errors in the attached application
Parameters
No parameters.
{
"type": "object",
"properties": {},
"required": []
}Enumerate resource dictionaries and their contents
| scope | string | optional | Scope of resources to enumerate |
| element_handle | string | optional | Required when scope is 'element' |
{
"type": "object",
"properties": {
"scope": {
"type": "string",
"description": "Scope of resources to enumerate",
"enum": [
"application",
"window",
"element"
],
"default": "application"
},
"element_handle": {
"type": "string",
"description": "Required when scope is 'element'"
}
},
"required": []
}Get applied styles and templates for an element
| element_handle | string | required | Handle of the element to inspect |
{
"type": "object",
"properties": {
"element_handle": {
"type": "string",
"description": "Handle of the element to inspect"
}
},
"required": [
"element_handle"
]
}Monitor a property for changes
| element_handle | string | required | Handle of the element |
| property_name | string | required | Name of the property to watch |
{
"type": "object",
"properties": {
"element_handle": {
"type": "string",
"description": "Handle of the element"
},
"property_name": {
"type": "string",
"description": "Name of the property to watch"
}
},
"required": [
"element_handle",
"property_name"
]
}Visually highlight an element in the running application
| element_handle | string | required | Handle of the element to highlight |
| duration_ms | integer | optional | Duration of highlight in milliseconds |
{
"type": "object",
"properties": {
"element_handle": {
"type": "string",
"description": "Handle of the element to highlight"
},
"duration_ms": {
"type": "integer",
"description": "Duration of highlight in milliseconds",
"default": 2000,
"minimum": 100,
"maximum": 10000
}
},
"required": [
"element_handle"
]
}Get layout information (ActualWidth, ActualHeight, Margin, Padding, etc.)
| element_handle | string | required | Handle of the element |
{
"type": "object",
"properties": {
"element_handle": {
"type": "string",
"description": "Handle of the element"
}
},
"required": [
"element_handle"
]
}Export visual tree to XAML or JSON format
| element_handle | string | optional | Handle of root element (optional, defaults to main window) |
| format | string | optional | Export format |
{
"type": "object",
"properties": {
"element_handle": {
"type": "string",
"description": "Handle of root element (optional, defaults to main window)"
},
"format": {
"type": "string",
"description": "Export format",
"enum": [
"json",
"xaml"
],
"default": "json"
}
},
"required": []
}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.
Demo: an AI agent drives a WPF app and finds a binding bug
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).
.mcp.json:
{
"mcpServers": {
"wpf-visual-tree": {
"command": "C:/path/to/WpfVisualTreeMcp.Server.exe",
"args": []
}
}
}
Prefer the terminal? The same exe is a full CLI: WpfVisualTreeMcp.Server.exe help.
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.
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:
Invoke/Toggle/Select/ExpandCollapse) or a real OS mouse clickIValueProvider.SetValue, with a TextBox.Text / PasswordBox.Password / reflected-Text fallback, or physical=true to type via OS keyboard input (full Unicode BMP)Ctrl+S, Alt+F4, F5, Enter, Ctrl+Shift+F, ...) to an element or the focused window via OS keyboard inputWpfInjectorHelper.exeThe 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.
vs. the general tool categories:
| WpfVisualTreeMcp | Snoop | 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 | ✅ wpf_wait_for | ✅ | ❌ |
| 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 (dnx/tool) + official MCP registry | 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.
dotnet tool install -g WpfVisualTreeMcp # installs the `wpfinspect` command
The 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 server
Download the latest release from GitHub Releases:
WpfVisualTreeMcp-vX.X.X-win-x64.zipC:\Tools\WpfVisualTreeMcp)WpfVisualTreeMcp.Server.exegit clone https://github.com/faze79/WpfVisualTreeMcp.git
cd WpfVisualTreeMcp
dotnet build -c Release
The server uses the official Microsoft/Anthropic MCP SDK for .NET, providing guaranteed compatibility with Claude Code and other MCP clients.
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.exe
You can verify the server was added:
claude mcp list
Option 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:
.exe file/) in paths on Windowsdotnet build -c ReleaseAdd to your Cursor settings (.cursor/mcp.json):
{
"mcpServers": {
"wpf-visual-tree": {
"command": "C:/path/to/WpfVisualTreeMcp/publish/WpfVisualTreeMcp.Server.exe",
"args": []
}
}
}
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.Inspector
In 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.
Use the wpf_list_processes tool to show all running WPF applications.
Attach to the MyApp.exe WPF application and show me the visual tree of the main window.
Check the attached WPF application for any binding errors and explain what's causing them.
Find all Button elements in the visual tree that have IsEnabled set to false.
Export the visual tree of the current window to JSON format so I can analyze the structure.
┌─────────────────────────────────────────────────────────────┐
│ 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.
| Tool | Description |
|---|---|
wpf_list_processes | List all running WPF applications |
wpf_attach | Attach to a WPF application (supports auto_inject for DLL injection) |
wpf_get_visual_tree | Get the visual tree hierarchy (default depth: 25, max: 100) |
wpf_get_element_properties | Get all dependency properties of an element |
wpf_find_elements | Query elements by type, x:Name, visible text, property values and visibility; results include text, automation id, enabled/visible state and screen bounds |
wpf_find_elements_deep | Same query filters without result limit, across all windows including adorners/popups |
wpf_capture_screenshot | Capture a screenshot of the window or element (returns image); mode='screen' captures real on-screen pixels including open popups, dropdowns and context menus |
wpf_get_bindings | Get data bindings for an element (includes MultiBinding, converter, StringFormat) |
wpf_get_binding_errors | List all captured binding errors |
wpf_clear_binding_errors | Clear the captured binding errors list |
wpf_get_data_context | Get DataContext type, properties, INPC status, and inheritance chain |
wpf_get_resources | Enumerate resource dictionaries |
wpf_get_styles | Get applied styles and templates |
wpf_watch_property | Monitor a property for changes |
wpf_set_property | Live-edit a dependency property at runtime (type-converted), to test a change without rebuilding. State-changing, reversible. |
wpf_revert_property | Undo wpf_set_property edits (one, filtered, or all) — restores the prior binding/value/default. |
wpf_highlight_element | Visually highlight an element |
wpf_click_element | Click a control — UI Automation invoke (Invoke/Toggle/Select/ExpandCollapse) by default, physical=true for a real OS mouse click (auto-scrolls into view), click_type='double'/'right' for double/right clicks. State-changing. |
wpf_select_item | Select an item in a ComboBox/ListBox/ListView/TabControl by visible text or index — works with virtualized items. State-changing. |
wpf_wait_for | Wait until an element is visible/exists/enabled/hidden, polling in the target app — no sleep-and-retry loops. |
wpf_set_text | Set text/value of a TextBox/ComboBox/PasswordBox — UI Automation IValueProvider.SetValue by default, physical=true to type via OS keyboard input. State-changing. |
wpf_send_keys | Send a keyboard shortcut (Ctrl+S, Alt+F4, F5, Enter, ...) to an element or the focused window. State-changing. |
wpf_get_layout_info | Get layout information |
wpf_export_tree | Export visual tree to XAML or JSON |
For complete tool documentation, see docs/TOOLS_REFERENCE.md.
ImageContentBlock)IValueProvider + fallbacks (v0.5.0)Ctrl+S, Alt+F4, F5, ...) via OS input (v0.5.0)WpfInjectorHelper.exe (32-bit .NET 8)wpf_select_item — select in ComboBox/ListBox/TabControl by text or indexdnx / dotnet tool install (MCP server package type)wpf_wait_for — wait for an element/condition, no sleep-and-retry loopsLive 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 testSee docs/ROADMAP.md for the full prioritized plan (rationale, design notes, effort, and suggested sequencing).
Contributions are welcome! Please feel free to submit a Pull Request.
Clone the repository:
git clone https://github.com/faze79/WpfVisualTreeMcp.git
cd WpfVisualTreeMcp
Open in Visual Studio 2022 or VS Code:
code .
# or
start WpfVisualTreeMcp.sln
Build and run tests:
dotnet build
dotnet test
Run the sample WPF app for testing:
dotnet run --project samples/SampleWpfApp
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/ # Documentation
[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)Program.cs routes via CliRunner.IsCliCommand)This project is licensed under the MIT License - see the LICENSE file for details.
nuget: WpfVisualTreeMcp@0.9.0