KQL MCP Server
Integrates with Windsurf (Codeium's AI IDE) to provide KQL query execution, schema browsing, and database management capabilities.
Works with GitHub Copilot in VS Code to enable KQL querying, table exploration, and database operations directly from the editor.
Allows ChatGPT to run KQL queries on Azure Data Explorer, Log Analytics, and Sentinel for data analysis, schema exploration, and investigation workflows.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@KQL MCP ServerShow failed login attempts from the last 24 hours"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
KQL MCP Server
The best MCP server for KQL (Kusto Query Language) — supporting Azure Data Explorer, Log Analytics, and Microsoft Sentinel.
Features
Tools
Tool | Description |
| Execute KQL against ADX or Log Analytics |
| List configured connections |
| List databases in an ADX cluster |
| List tables in a database or workspace |
| Get column names, types, and descriptions |
| Get sample rows to understand a table |
| Find tables/columns by keyword |
| Row count and storage size (ADX) |
| Validate KQL syntax and get optimization tips |
| Browse battle-tested query templates |
| Search templates by keyword |
| Look up any KQL operator or function |
| Refresh cached schema data |
Resources (KQL Reference)
Tabular operators:
where,summarize,join,project,extend,parse,mv-expand,make-series, etc.Scalar functions: string, datetime, math, dynamic/JSON, IP address
Aggregation functions:
count,dcount,avg,percentile,make_list,arg_max, etc.Window functions:
prev,next,row_number,row_cumsumTime series functions:
series_decompose_anomalies,series_fit_line,series_decompose_forecastData types and timespan literals
Best practices for performance, readability, and security
Query Templates
Security: Failed logins, impossible travel, suspicious PowerShell, Azure resource deletions, network anomalies
Performance: CPU/memory/disk metrics, slow HTTP requests, dependency failures, exception rates
Operations: Heartbeat health checks, VM events, ingestion volume, alert rule firings
ADX: Query statistics, ingestion failures, extent stats
Time Series: Anomaly detection, forecasting, event rate spikes
Prompts
write-kql— Write a KQL query from a natural language descriptionexplain-kql— Explain what a query does in plain Englishoptimize-kql— Analyze and optimize a query for performanceinvestigate-security-alert— Security investigation plan + queriesperformance-investigation— Performance root cause queriesconvert-sql-to-kql— Convert SQL to KQLschema-explorer— Explore a table and get query suggestions
Related MCP server: MCP KQL Server
Installation
pip install git+https://github.com/rod-trent/KQL-MCP.gitOr clone and install locally:
git clone https://github.com/rod-trent/KQL-MCP.git
cd KQL-MCP
pip install -e .Configuration
Copy .env.example to .env and fill in your connection details:
# Azure Data Explorer
ADX_CLUSTERS='[{"name": "my-cluster", "cluster_url": "https://mycluster.eastus.kusto.windows.net", "database": "mydb"}]'
# Log Analytics / Sentinel
LOG_ANALYTICS_WORKSPACES='[{"name": "sentinel", "workspace_id": "your-workspace-id"}]'
# Authentication (cli = az login, managed_identity, service_principal, interactive)
AZURE_AUTH_METHOD=cliAuthentication
The server supports multiple Azure authentication methods:
Method | Use case |
| Local development — uses |
| Azure-hosted workloads (VMs, Container Apps, etc.) |
| CI/CD pipelines, automated workflows |
| Browser-based interactive login |
For cli auth, log in first:
az loginUsing with AI Assistants
The KQL MCP server works with any AI assistant or IDE that supports the Model Context Protocol (MCP). Choose your platform below.
Claude Desktop
Config file location:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"kql": {
"command": "kql-mcp",
"env": {
"ADX_CLUSTERS": "[{\"name\": \"my-cluster\", \"cluster_url\": \"https://mycluster.eastus.kusto.windows.net\", \"database\": \"mydb\"}]",
"LOG_ANALYTICS_WORKSPACES": "[{\"name\": \"sentinel\", \"workspace_id\": \"your-workspace-id\"}]",
"AZURE_AUTH_METHOD": "cli"
}
}
}
}Alternatively, point to a directory containing your .env file:
{
"mcpServers": {
"kql": {
"command": "kql-mcp",
"cwd": "C:\\path\\to\\KQL-MCP"
}
}
}Restart Claude Desktop after saving. You should see the KQL tools available in a new conversation.
Claude Code (CLI)
claude mcp add kql -- kql-mcpTo pass connection config directly:
claude mcp add kql \
-e ADX_CLUSTERS='[{"name":"prod","cluster_url":"https://mycluster.eastus.kusto.windows.net","database":"mydb"}]' \
-e AZURE_AUTH_METHOD=cli \
-- kql-mcpVerify the server is registered:
claude mcp listChatGPT (OpenAI)
OpenAI supports MCP servers in the ChatGPT desktop app (macOS and Windows).
Config file location:
Windows:
%APPDATA%\ChatGPT\claude_desktop_config.jsonmacOS:
~/Library/Application Support/ChatGPT/claude_desktop_config.json
{
"mcpServers": {
"kql": {
"command": "kql-mcp",
"env": {
"ADX_CLUSTERS": "[{\"name\": \"my-cluster\", \"cluster_url\": \"https://mycluster.eastus.kusto.windows.net\", \"database\": \"mydb\"}]",
"LOG_ANALYTICS_WORKSPACES": "[{\"name\": \"sentinel\", \"workspace_id\": \"your-workspace-id\"}]",
"AZURE_AUTH_METHOD": "cli"
}
}
}
}Restart ChatGPT after saving. MCP tools appear automatically when you start a new conversation.
Note: MCP support in ChatGPT desktop requires the latest version of the app. Check OpenAI's documentation for the most current setup instructions.
Cursor
Open Settings → Cursor Settings → MCP and add a new server, or edit ~/.cursor/mcp.json directly:
{
"mcpServers": {
"kql": {
"command": "kql-mcp",
"env": {
"ADX_CLUSTERS": "[{\"name\": \"my-cluster\", \"cluster_url\": \"https://mycluster.eastus.kusto.windows.net\", \"database\": \"mydb\"}]",
"LOG_ANALYTICS_WORKSPACES": "[{\"name\": \"sentinel\", \"workspace_id\": \"your-workspace-id\"}]",
"AZURE_AUTH_METHOD": "cli"
}
}
}
}Reload Cursor after saving. The KQL tools will be available to Cursor's AI in Agent mode.
Windsurf (Codeium)
Edit ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"kql": {
"command": "kql-mcp",
"env": {
"ADX_CLUSTERS": "[{\"name\": \"my-cluster\", \"cluster_url\": \"https://mycluster.eastus.kusto.windows.net\", \"database\": \"mydb\"}]",
"LOG_ANALYTICS_WORKSPACES": "[{\"name\": \"sentinel\", \"workspace_id\": \"your-workspace-id\"}]",
"AZURE_AUTH_METHOD": "cli"
}
}
}
}Restart Windsurf after saving. MCP tools are available in Cascade (Windsurf's AI agent).
VS Code (GitHub Copilot)
Add to your VS Code settings.json (open via Ctrl+Shift+P → Preferences: Open User Settings (JSON)):
{
"mcp": {
"servers": {
"kql": {
"type": "stdio",
"command": "kql-mcp",
"env": {
"ADX_CLUSTERS": "[{\"name\": \"my-cluster\", \"cluster_url\": \"https://mycluster.eastus.kusto.windows.net\", \"database\": \"mydb\"}]",
"LOG_ANALYTICS_WORKSPACES": "[{\"name\": \"sentinel\", \"workspace_id\": \"your-workspace-id\"}]",
"AZURE_AUTH_METHOD": "cli"
}
}
}
}
}Or add a workspace-scoped .vscode/mcp.json file to share the config with your team:
{
"servers": {
"kql": {
"type": "stdio",
"command": "kql-mcp",
"env": {
"ADX_CLUSTERS": "[{\"name\": \"my-cluster\", \"cluster_url\": \"https://mycluster.eastus.kusto.windows.net\", \"database\": \"mydb\"}]",
"AZURE_AUTH_METHOD": "cli"
}
}
}
}The KQL tools are then available in GitHub Copilot Chat when using Agent mode (@agent).
Any Other MCP-Compatible Client
The server speaks standard MCP over stdio. Any client that supports stdio MCP servers can use it with this generic config shape:
{
"mcpServers": {
"kql": {
"command": "kql-mcp",
"env": {
"ADX_CLUSTERS": "[{\"name\": \"<alias>\", \"cluster_url\": \"https://<cluster>.<region>.kusto.windows.net\", \"database\": \"<database>\"}]",
"LOG_ANALYTICS_WORKSPACES": "[{\"name\": \"<alias>\", \"workspace_id\": \"<workspace-id>\"}]",
"AZURE_AUTH_METHOD": "cli"
}
}
}
}Key values:
Key | Description |
|
|
| JSON array of ADX cluster connections |
| JSON array of Log Analytics workspace connections |
|
|
Refer to your AI client's MCP documentation for the exact config file location and format.
Requirements
Python 3.11+
Azure CLI (
az login) forcliauth mode, or appropriate credentials for other auth methodsAccess to an Azure Data Explorer cluster or Log Analytics / Sentinel workspace
This server cannot be deployed
Maintenance
Related MCP Connectors
Find relevant security data from Sentinel data lake for building effective agents. More:aka.ms/s/de
Connects AI assistants to CloudQuell multi-cloud and AI cost, savings, anomaly, and budget data.
List datasets, schemas, run APL queries, and use prompts for exploration, anomalies, and monitoring.
- mcpOAuthcom.vibgrate
Query your team's drift, vulnerability, and upgrade data from any AI assistant. OAuth 2.1, 51 tools.
Related MCP Servers
- AlicenseAqualityCmaintenanceAI assistants to query and analyze Azure Data Explorer databases through standardized interfaces.557MIT
- AlicenseNot gradedqualityBmaintenanceEnables intelligent KQL query execution against Azure Data Explorer clusters with AI-powered schema caching and natural language to KQL conversion. Provides automated schema discovery and context-aware query assistance for enhanced data exploration.127 PyPI23MIT
- AlicenseNot gradedqualityDmaintenanceEnables users to authenticate with Azure Data Explorer and execute KQL queries via natural language through the Model Context Protocol.205 npmMIT
- AlicenseAqualityAmaintenanceEnables AI assistants to query Azure Data Explorer using natural language, eliminating the need to write KQL.784 npm7MIT