Snoop now includes an integrated MCP server that enables AI assistants like Claude to interact with and inspect WPF applications in real-time. This powerful feature bridges traditional debugging tools with modern AI assistance, enabling automated UI inspection, debugging, and analysis.
The Model Context Protocol (MCP) is an open protocol that standardizes how AI applications interact with external tools and data sources. By integrating MCP into Snoop, AI assistants can now:
- Browse and analyze WPF visual trees
- Inspect element properties and bindings
- Search for specific UI elements
- Capture visual screenshots
- Help diagnose layout and binding issues
- Generate detailed bug reports
- Snoop 6.1.0 or later
- .NET 6.0+ (for fallback implementation) or .NET 8.0+ (for official MCP SDK)
- An MCP-compatible AI assistant (e.g., Claude Desktop)
- Launch Snoop and attach to a WPF application
- Click the MCP Server button in the menu bar
- In the MCP Server window, click Start Server
- The server will start on an available port between 47700-47799
- Copy the SSE endpoint URL shown in the window
To connect Claude Desktop to the Snoop MCP server:
- Open Claude Desktop settings
- Navigate to the MCP servers configuration
- Add a new server configuration:
{
"mcpServers": {
"snoop": {
"command": "sse",
"args": ["http://localhost:47700/sse"]
}
}
}Note: Replace 47700 with the actual port shown in your Snoop MCP Server window.
- Restart Claude Desktop
- Claude will now have access to the Snoop MCP tools
The Snoop MCP server exposes 7 specialized tools:
Retrieves the hierarchical structure of UI elements in the WPF application.
Parameters:
maxDepth(number, 1-50): Maximum tree depth to retrieve (default: 10)includeProperties(boolean): Include key properties for each element (default: false)
Returns:
- JSON tree structure with type, name, path, and optional properties
Example Use Case: "Show me the visual tree structure of the current window"
Gets detailed information about the currently selected element in Snoop.
Parameters: None
Returns:
- Element type
- Key properties
- Binding errors
- Child count
Example Use Case: "What properties does the selected button have?"
Retrieves all properties of a specific element by path.
Parameters:
path(string, required): Element path (e.g., "0/2/1")filter(string, optional): Filter properties by name
Returns:
- Filtered list of properties with names, values, and types
Example Use Case: "Show me all margin-related properties for the element at path 0/1/3"
Programmatically selects an element in the Snoop UI.
Parameters:
path(string, required): Element path to select
Returns:
- Success confirmation
Side Effect:
- Updates the Snoop UI to show the selected element
Example Use Case: "Select the third child element at the root level"
Searches the visual tree for elements matching specific criteria.
Parameters:
typeName(string, optional): Element type to search for (e.g., "Button", "TextBox")elementName(string, optional): Element name to search formaxResults(number, optional): Maximum number of results to return (default: 20)
Returns:
- List of matching elements with paths and details
Example Use Case: "Find all TextBox elements in the application"
Analyzes data bindings on the currently selected element.
Parameters: None
Returns:
- Binding paths
- Binding modes
- Data sources
- Binding errors and warnings
Example Use Case: "Are there any binding errors on the selected element?"
Captures a visual screenshot of a specific element.
Parameters:
maxWidth(number, optional): Maximum width in pixels (default: 800)maxHeight(number, optional): Maximum height in pixels (default: 600)
Returns:
- Base64-encoded PNG image
Example Use Case: "Show me what the selected element looks like"
Scenario: A panel is not displaying correctly.
User: "The main panel looks wrong. Can you help me debug it?"
AI with Snoop MCP:
1. Uses get_visual_tree to understand the layout hierarchy
2. Uses find_elements to locate the panel
3. Uses select_element to focus on it
4. Uses get_element_properties to check Width, Height, Margin, Padding
5. Uses get_element_preview to capture a visual screenshot
6. Identifies the issue (e.g., wrong alignment or margin)
Scenario: Data is not displaying in a DataGrid.
User: "My DataGrid is empty even though I have data."
AI with Snoop MCP:
1. Uses find_elements to locate the DataGrid
2. Uses get_bindings to check binding configuration
3. Identifies binding errors or incorrect paths
4. Suggests fixes based on the binding analysis
Scenario: Application feels slow during scrolling.
User: "Scrolling is laggy in my list."
AI with Snoop MCP:
1. Uses get_visual_tree with includeProperties to analyze the list structure
2. Identifies virtualization issues or excessive elements
3. Uses get_element_properties to check VirtualizingPanel properties
4. Suggests optimizations (e.g., enable virtualization, reduce complexity)
Scenario: Need to report a visual bug to the team.
User: "Generate a bug report for this layout issue."
AI with Snoop MCP:
1. Uses get_visual_tree to document the affected hierarchy
2. Uses get_element_properties to capture relevant property values
3. Uses get_element_preview to create visual evidence
4. Uses get_bindings to check for related binding issues
5. Generates a comprehensive markdown bug report with screenshots
The MCP server is implemented with two variants:
Official SDK (NET 8.0+):
- Uses
ModelContextProtocol.AspNetCorepackage - Built on ASP.NET Core WebApplication
- Leverages official MCP SDK for protocol handling
Fallback (.NET 6.0, .NET Framework 4.6.2+):
- Custom HttpListener-based implementation
- Manual JSON-RPC 2.0 protocol handling
- Server-Sent Events via streaming response
AI Assistant (Claude)
↕ (SSE connection)
MCP Server (localhost:47700-47799)
↕ (Dispatcher invocation)
Snoop UI (WPF Application)
↕ (Tree inspection)
Target WPF Application
All operations are executed on the WPF UI thread via Dispatcher to ensure thread safety.
- Server only listens on localhost (not accessible remotely)
- No authentication required (local-only access)
- Server can be stopped at any time from the MCP Server window
- All operations are read-only except select_element (which only changes Snoop's UI)
Problem: Server fails to start or shows an error.
Solutions:
- Check if ports 47700-47799 are already in use
- Ensure firewall is not blocking localhost connections
- Verify .NET runtime version meets requirements
- Check Snoop logs for detailed error messages
Problem: Claude Desktop shows "Connection failed" for Snoop server.
Solutions:
- Verify the server is running (check MCP Server window)
- Confirm the correct port in Claude Desktop configuration
- Restart Claude Desktop after configuration changes
- Check the SSE endpoint URL matches exactly
Problem: MCP tools execute but return no data or errors.
Solutions:
- Ensure a WPF application is attached to Snoop
- Verify the visual tree is loaded in Snoop
- Check if the requested element paths are valid
- Try refreshing the tree in Snoop
Problem: Tools are slow or Snoop becomes unresponsive.
Solutions:
- Reduce maxDepth when calling get_visual_tree
- Limit maxResults when using find_elements
- Disable includeProperties if not needed
- Close the MCP Server window when not in use
- Start specific: Use find_elements to locate specific elements before inspecting properties
- Limit depth: When exploring trees, start with lower maxDepth and increase as needed
- Use filters: Apply filters in get_element_properties to reduce noise
- Combine tools: Use multiple tools in sequence for comprehensive analysis
- Capture evidence: Use get_element_preview to document visual states
- Check bindings early: Always check get_bindings when debugging data display issues
- Server is localhost-only (cannot be accessed remotely)
- Requires an active Snoop session attached to a WPF application
- Element paths are relative to current tree state (can change if tree updates)
- Screenshot quality depends on element size and complexity
- Some properties may not be readable due to security or access restrictions
Potential features under consideration:
- Multi-application support (manage multiple attached apps)
- Property editing via MCP (write operations)
- Event monitoring and triggering
- Performance profiling integration
- Custom tool extensibility API
- WebSocket transport option
- Authentication for remote scenarios
If you have ideas for improving the MCP integration or encounter issues, please:
- Check existing issues at GitHub Issues
- Submit new issues with detailed reproduction steps
- Contribute pull requests with enhancements
The MCP integration follows the same license as Snoop (MIT License).