WpfVisualTreeMcp
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
> **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)
1. Download and extract the latest release zip (requires the .NET 8 Desktop Runtime).
2. Register it in your MCP client — for Claude Code, add to .mcp.json:
3. 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.
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 click
- **Set Text** *(new in v0.5.0)* - Fill a TextBox/ComboBox/PasswordBox via UI Automation IValueProvider.SetValue, with a TextBox.Text / PasswordBox.Password / reflected-Text fallback, or physical=true to 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 input
- **Layout 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:**