get_query_plan
Generate estimated SQL execution plans in XML, tree, JSON, or Mermaid format without executing the query. Works for Fabric Warehouse and SQL Analytics Endpoints.
Instructions
Capture the estimated SHOWPLAN_XML execution plan for a SQL query without executing it.
This tool does NOT execute the query — it only retrieves the estimated execution
plan as SHOWPLAN_XML. Because no data is modified, this tool is permitted even
under FABRIC_MCP_READONLY=1.
The plan XML uses the standard namespace
http://schemas.microsoft.com/sqlserver/2004/07/showplan and can be opened
in SSMS, Azure Data Studio, or uploaded to pastetheplan.com for visual analysis.
Since the query is not executed, DDL/DML query text is safe to plan without modifying any data.
Supports both Warehouse and SQL Analytics Endpoint items.
Format options:
"xml"(default, backwards-compatible) — returns the raw SHOWPLAN_XML string inplan_xml. Existing callers relying on{"plan_xml": str}continue to work unchanged."tree"— parses the XML into a native nested list of dicts (one entry per statement) inplan. Best for agent reasoning over the plan structure."json"— same tree, serialised to an indented JSON string inplan_json. Ready to write out or pass through as compact text."mermaid"— renders a Mermaidflowchart TDdiagram string inmermaid. Paste into mermaid.live or embed in GitHub Markdown.
Artifact formats (SVG/HTML/DOT) are CLI-only. They write files to disk and
are only available via fdw sql plan --format <fmt> -o <file>. The MCP
server never writes files (ambiguous cwd, invisible side-effects).
Args:
workspace: Workspace name or GUID.
item: Warehouse or SQL Analytics Endpoint name or GUID.
query: SQL statement to generate an estimated execution plan for.
format: Output format — one of "xml" (default), "tree",
"json", or "mermaid".
Returns: A dict whose shape depends on format:
- ``xml`` → ``{"format": "xml", "plan_xml": str}``
- ``tree`` → ``{"format": "tree", "plan": list[dict]}``
- ``json`` → ``{"format": "json", "plan_json": str}``
- ``mermaid`` → ``{"format": "mermaid", "mermaid": str}``
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| item | Yes | ||
| query | Yes | ||
| format | No | xml | |
| workspace | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||