Summary
Add an MCP (Model Context Protocol) server to SQL Performance Studio so users can connect AI assistants (Claude, etc.) and have conversational analysis of query plans and Query Store data — directly from the app.
Motivation
The app already parses plans, runs 30 analysis rules, and connects to Query Store. An MCP server would expose this data through read-only tools, letting AI assistants provide deeper, contextual analysis without users needing to copy/paste plan XML or manually describe their situation.
Design Principles
- Opt-in by default — MCP server is off until the user explicitly enables it
- Strictly read-only — no tool can execute arbitrary SQL or modify anything on the server
- Same data the app already surfaces — plans, analysis results, Query Store metrics, operator trees, warnings, missing indexes
Proposed Tools
Plan Analysis Tools
| Tool |
Purpose |
get_loaded_plans |
List currently loaded plan files/tabs with summary info (statement count, warning count, DOP) |
get_plan_analysis |
Full analysis result for a loaded plan — warnings, missing indexes, operator tree, runtime stats |
get_plan_warnings |
Warnings only for a loaded plan, with severity and operator context |
get_missing_indexes |
Missing index suggestions with impact percentages and CREATE statements |
get_operator_details |
Detailed properties for a specific operator node (by node ID) |
get_plan_comparison |
Compare two loaded plans — cost, runtime, I/O, memory, wait stats differences |
get_parameters |
Parameter names, types, compiled vs runtime values for a plan statement |
get_wait_stats |
Per-statement wait stats from actual plans |
Query Store Tools (requires active connection)
| Tool |
Purpose |
get_query_store_top |
Top queries by CPU, duration, or reads from Query Store |
get_query_store_plan |
Plan and analysis for a specific Query Store query |
get_query_store_regressed |
Queries with regressed performance (plan changes, increased resource usage) |
Context Tools
| Tool |
Purpose |
get_server_info |
Connected server version, edition, compatibility level |
get_database_context |
Current database name and context from the plan or connection |
What This Does NOT Do
- No arbitrary SQL execution — tools return pre-collected/pre-parsed data only, same as PerformanceMonitor's MCP approach
- No writes — cannot modify server settings, kill sessions, force plans, or change anything
- No file system access — cannot read/write files beyond what the app already does
- No credential exposure — connection details are not surfaced through tools
Implementation Notes
- Follow the same read-only MCP pattern used by PerformanceMonitor
- The MCP server runs locally within the app process
- Tools return the same data structures the app already computes (ParsedPlan, AnalysisResult, QueryStorePlan, etc.)
- Transport: stdio or SSE, depending on what works best with Avalonia's process model
User Experience
- User enables MCP server in app settings (off by default)
- App starts the MCP server on a local endpoint
- User configures their AI assistant to connect to the MCP server
- AI can now ask about loaded plans, run analysis, query Query Store — all read-only
- User gets conversational analysis: "Why is this plan slow?", "What index would help here?", "Compare these two plans"
Summary
Add an MCP (Model Context Protocol) server to SQL Performance Studio so users can connect AI assistants (Claude, etc.) and have conversational analysis of query plans and Query Store data — directly from the app.
Motivation
The app already parses plans, runs 30 analysis rules, and connects to Query Store. An MCP server would expose this data through read-only tools, letting AI assistants provide deeper, contextual analysis without users needing to copy/paste plan XML or manually describe their situation.
Design Principles
Proposed Tools
Plan Analysis Tools
get_loaded_plansget_plan_analysisget_plan_warningsget_missing_indexesget_operator_detailsget_plan_comparisonget_parametersget_wait_statsQuery Store Tools (requires active connection)
get_query_store_topget_query_store_planget_query_store_regressedContext Tools
get_server_infoget_database_contextWhat This Does NOT Do
Implementation Notes
User Experience