execute_sql
Run custom SQL queries on Fabric warehouses or SQL Analytics endpoints for data retrieval or modification when predefined tools are not suitable.
Instructions
Execute an arbitrary SQL statement or batch against a warehouse or SQL Analytics Endpoint.
Prefer dedicated tools for common operations: use read_table or read_view to fetch rows, count_table_rows or count_view_rows to count, list_tables, list_views, list_schemas to discover objects, get_table_columns or get_view_columns to inspect schemas, and delete_table, rename_table, or clear_table to mutate. Dedicated tools return structured, typed results with no dialect pitfalls or batch-truncation surprises.
WARNING: this tool executes arbitrary SQL against the target. DDL (DROP,
ALTER, TRUNCATE) and DML (DELETE, UPDATE) are permitted unless
FABRIC_MCP_READONLY=1 is set. Use only when the user explicitly
requests data modification. Default to SELECT when the user's intent is
read-only investigation.
Supports both Warehouse and SQL Analytics Endpoint items. Multi-statement
batches are allowed; only the last result set is returned. DDL/DML
statements that produce no result set return columns=[] and rows=[].
datetime and Decimal column values are pre-serialised to strings.
bytes / varbinary columns are base64-encoded and their column names are
suffixed with __base64.
For large tables, add a TOP clause or WHERE predicate to the query rather
than relying solely on max_rows. The driver fetches at most
max_rows + 1 rows (enough to detect truncation) so memory is bounded,
but pushing the limit into the query itself is always more efficient.
Args:
workspace: Workspace name or GUID.
item: Warehouse or SQL Analytics Endpoint name or GUID.
query: SQL statement or batch to execute.
max_rows: Maximum rows to return (1-10000, default 1000). When the
result set is larger the response includes "truncated": true.
Returns:
A dict with keys columns (list[str]), rows (list[list[Any]]),
rowcount (int; -1 when the driver does not report a count),
row_count_returned (int), and truncated (bool).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| item | Yes | ||
| query | Yes | ||
| max_rows | No | ||
| workspace | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||