execute_kql_query
Run KQL on Azure Data Explorer (Kusto) and return results.
Use this tool ANY time the user asks a question that needs data from a Kusto cluster (Azure Data Explorer, Azure Monitor Logs, Microsoft Sentinel, Defender XDR Advanced Hunting, or any *.kusto.windows.net endpoint).
Two modes:
- Direct KQL: pass a real KQL query, leave
generate_query=false. - Natural language to KQL: pass an English question and set
generate_query=true. The query is grounded against the cached schema, validated, dry-run against ADX (| take 0), and self-repaired once on schema drift before execution.
Tips for the model:
- If the user already gave you a query in
cluster('x').database('y').Tform, you can omitcluster_urlanddatabase; they will be parsed from the query. - For NL2KQL, call
kql_schema_memory(operation=list_tablesthendiscover) FIRST so the generator has accurate table/column context. - Default output is compact JSON. Use
output_format="csv"for export and"table"for human-readable preview.
Args: query: KQL query, or a natural-language description if generate_query=true. cluster_url: Kusto cluster URL, e.g. https://help.kusto.windows.net. Optional if the query already embeds cluster(...).database(...). database: Database name. Optional if the query already embeds it. output_format: One of json (default), csv, table, generation_only. generate_query: If true, treat query as natural language and convert to KQL before execution. table_name: Optional hint for NL2KQL to bias generation toward a specific table. use_live_schema: When true (default) refresh the table schema from ADX before generation if the cache is stale.
Returns: JSON string. On success contains data, columns, row_count. On failure contains error, error_class, and recovery suggestions. Authentication: Uses the Azure authentication established at server startup; tool execution never launches an interactive login and tokens are never stored. Default query timeout: 2 minutes. Hard server-side ceiling: 10 minutes.