mcp-kql-server
Kusto and Log Analytics MCP server help you execute a KQL (Kusto Query Language) query within an AI prompt, analyze, and visualize the data.
Documentation
MCP KQL Server
mcp-name: io.github.4R9UN/mcp-kql-server

> AI-Powered KQL Query Execution with Natural Language to KQL (NL2KQL) Conversion and Execution
A Model Context Protocol (MCP) server that transforms natural language questions into optimized KQL queries with intelligent schema discovery, AI-powered caching, and seamless Azure Data Explorer integration. Simply ask questions in plain English and get instant, accurate KQL queries with context-aware results.
Latest Version: v2.1.5 - Policy compliant Azure CLI login and migration to the official MCP Python SDK.
π¬ Demo
Watch a quick demo of the MCP KQL Server in action:

π Features
- `execute_kql_query`:
- `kql_schema_memory`:
π MCP Tools Execution Flow
graph TD
A[π€ User Submits KQL Query] --> B{π Query Validation}
B -->|β Invalid| C[π Syntax Error Response]
B -->|β
Valid| D[π§ Load Schema Context]
D --> E{πΎ Schema Cache Available?}
E -->|β
Yes| F[β‘ Load from Memory]
E -->|β No| G[π Discover Schema]
F --> H[π― Execute Query]
G --> I[πΎ Cache Schema + AI Context]
I --> H
H --> J{π― Query Success?}
J -->|β Error| K[π¨ Enhanced Error Message]
J -->|β
Success| L[π Process Results]
L --> M[π¨ Generate Visualization]
M --> N[π€ Return Results + Context]
K --> O[π‘ AI Suggestions]
O --> N
style A fill:#4a90e2,stroke:#2c5282,stroke-width:2px,color:#ffffff
style B fill:#7c7c7c,stroke:#4a4a4a,stroke-width:2px,color:#ffffff
style C fill:#e74c3c,stroke:#c0392b,stroke-width:2px,color:#ffffff
style D fill:#8e44ad,stroke:#6a1b99,stroke-width:2px,color:#ffffff
style E fill:#7c7c7c,stroke:#4a4a4a,stroke-width:2px,color:#ffffff
style F fill:#27ae60,stroke:#1e8449,stroke-width:2px,color:#ffffff
style G fill:#f39c12,stroke:#d68910,stroke-width:2px,color:#ffffff
style H fill:#2980b9,stroke:#1f618d,stroke-width:2px,color:#ffffff
style I fill:#f39c12,stroke:#d68910,stroke-width:2px,color:#ffffff
style J fill:#7c7c7c,stroke:#4a4a4a,stroke-width:2px,color:#ffffff
style K fill:#e74c3c,stroke:#c0392b,stroke-width:2px,color:#ffffff
style L fill:#27ae60,stroke:#1e8449,stroke-width:2px,color:#ffffff
style M fill:#8e44ad,stroke:#6a1b99,stroke-width:2px,color:#ffffff
style N fill:#27ae60,stroke:#1e8449,stroke-width:2px,color:#ffffff
style O fill:#f39c12,stroke:#d68910,stroke-width:2px,color:#ffffffSchema Memory Discovery Flow
The schema memory flow is integrated into query execution, but it now reuses existing cached schema before attempting live discovery. If a table schema is already available in CAG/schema memory, the server will use that cached schema instead of re-indexing it.
graph TD
A[π€ User Requests Schema Discovery] --> B[π Connect to Cluster]
B --> C[π Enumerate Databases]
C --> D[π Discover Tables]
D --> E[π Get Table Schemas]
E --> F[π€ AI Analysis]
F --> G[π Generate Descriptions]
G --> H[πΎ Store in Memory]
H --> I[π Update Statistics]
I --> J[β
Return Summary]
style A fill:#4a90e2,stroke:#2c5282,stroke-width:2px,color:#ffffff
style B fill:#8e44ad,stroke:#6a1b99,stroke-width:2px,color:#ffffff
style C fill:#f39c12,stroke:#d68910,stroke-width:2px,color:#ffffff
style D fill:#2980b9,stroke:#1f618d,stroke-width:2px,color:#ffffff
style E fill:#7c7c7c,stroke:#4a4a4a,stroke-width:2px,color:#ffffff
style F fill:#e67e22,stroke:#bf6516,stroke-width:2px,color:#ffffff
style G fill:#8e44ad,stroke:#6a1b99,stroke-width:2px,color:#ffffff
style H fill:#f39c12,stroke:#d68910,stroke-width:2px,color:#ffffff
style I fill:#2980b9,stroke:#1f618d,stroke-width:2px,color:#ffffff
style J fill:#27ae60,stroke:#1e8449,stroke-width:2px,color:#ffffffπ Prerequisites
- Python 3.10 or higher
- Azure CLI installed. Server startup checks the current token and runs plain interactive `az login` only when needed.
- Access to Azure Data Explorer cluster(s)
π One-Command Installation
Quick Install (Recommended)
From Source
git clone https://github.com/4R9UN/mcp-kql-server.git && cd mcp-kql-server && pip install -e .Alternative Installation Methods
pip install mcp-kql-serverThat's it! The server automatically:
- β Sets up memory directories in `%APPDATA%\KQL_MCP` (Windows) or `~/.local/share/KQL_MCP` (Linux/Mac)
- β Configures optimal defaults for production use
- β Suppresses verbose Azure SDK logs
- β No environment variables required
π± MCP Client Configuration
> One-time install (any platform):
> ```bash
> pip install --upgrade mcp-kql-server
> ```
> After install, configure your MCP client to launch the server via the Python module entry point: `python -m mcp_kql_server`. This works on every platform where Python is on `PATH` and does not depend on the location of the `mcp-kql-server` console script. (The console script is still installed by `pip` and remains supported for backward compatibility β see the alternative snippets below.)
Claude Desktop
Add to your Claude Desktop MCP settings file (`mcp_settings.json`):
Location:
- Windows: `%APPDATA%\Claude\mcp_settings.json`
- macOS: `~/Library/Application Support/Claude/mcp_settings.json`
- Linux: `~/.config/Claude/mcp_settings.json`
{
"mcpServers": {
"mcpKqlServer": {
"type": "stdio",
"command": "python",
"args": ["-m", "mcp_kql_server"]
}
}
}Alternatives: platform-stable launchers or the installed console script
Windows (the `py` launcher is commonly available as `py`; use `Get-Command py` if you need its full path):
{
"mcpServers": {
"mcpKqlServer": {
"type": "stdio",
"command": "py",
"args": ["-3", "-m", "mcp_kql_server"]
}
}
}On macOS / Linux replace `"py"` with `"python3"` and drop the `"-3"` arg.
VSCode (with MCP Extension)
Add to your VSCode MCP configuration:
Settings.json location:
- Windows: `%APPDATA%\Code\User\mcp.json`
- macOS: `~/Library/Application Support/Code/User/mcp.json`
- Linux: `~/.config/Code/User/mcp.json`
{
"servers": {
"mcpKqlServer": {
"type": "stdio",
"command": "py",
"args": ["-3", "-m", "mcp_kql_server", "--transport", "stdio"],
"timeout": 300000,
"env": {
"FASTMCP_TRANSPORT": "stdio",
"MCP_KQL_AUTH_ON_STARTUP": "true",
"MCP_KQL_CHECK_FOR_UPDATES": "false",
"MCP_KQL_SKIP_STARTUP_VERSION_CHECK": "1",
"MCP_KQL_AUTH_CHECK_TIMEOUT_SECONDS": "10",
"MCP_KQL_AUTH_LOGIN_TIMEOUT_SECONDS": "120",
"MCP_KQL_SQLITE_BUSY_TIMEOUT_MS": "30000"
}
}
}
}> If VS Code logs `spawn ...PythonNNN/python.exe ENOENT`, the Python extension is substituting a cached interpreter path for `"python"`. Switch to `"py"` (Windows) / `"python3"` (macOS/Linux), or to the `"mcp-kql-server"` console script that `pip install` drops on `PATH`. See docs/troubleshooting.md for full details.
> Windows tip: use `py -3 -m mcp_kql_server` so VS Code does not need a user-specific Python path. If you must use a full path locally, keep it in your private `mcp.json`, not in shared documentation.
> If the server starts but VS Code still shows no tools, run `MCP: Reset Cached Tools`, then `MCP: Reset Trust`, and restart the server from `MCP: List Servers`. VS Code stores trust and cached tools separately from `mcp.json`, so a previous failed launch can keep the old empty state until you reset it.
Shared HTTP Mode for Multiple MCP Clients
Use shared HTTP when VS Code, GitHub Copilot CLI, agents, or other MCP clients should connect to one persistent MCP KQL server process.
HTTP binds are restricted to loopback by default because tool calls execute with the operator's Azure CLI identity. Put authentication and TLS in a trusted reverse proxy before remote exposure. Non-loopback binding requires the explicit `MCP_KQL_ALLOW_UNAUTHENTICATED_REMOTE_HTTP=true` acknowledgement.
Start the server:
python -m mcp_kql_server --transport http --host 127.0.0.1 --port 8000 --http-path /mcp --stateless-httpClient configuration:
{
"servers": {
"mcpKqlServer": {
"type": "http",
"url": "http://127.0.0.1:8000/mcp"
}
}
}Runtime Settings
| Option or environment variable | Purpose | Default |
|---|---|---|
| `--transport`, `FASTMCP_TRANSPORT` | `stdio`, `http`, `streamable-http`, or `sse` | `stdio` |
| `--host`, `FASTMCP_HOST` | HTTP bind host | `127.0.0.1` |
| `--port`, `FASTMCP_PORT` | HTTP bind port | `8000` |
| `--http-path`, `FASTMCP_STREAMABLE_HTTP_PATH` | Streamable HTTP endpoint path | `/mcp` |
| `--stateless-http`, `FASTMCP_STATELESS_HTTP` | Stateless HTTP mode for shared deployments | `false` |
| `--auth-on-startup` / `--no-auth-on-startup`, `MCP_KQL_AUTH_ON_STARTUP` | Initialize authentication when the server starts | `true` |
| `--check-updates`, `MCP_KQL_CHECK_FOR_UPDATES` | Check PyPI for package updates before startup | `false` |
| `MCP_KQL_AUTH_CHECK_TIMEOUT_SECONDS` | Azure CLI auth check timeout | `10` |
| `MCP_KQL_AUTH_LOGIN_TIMEOUT_SECONDS` | Interactive Azure login timeout | `120` |
| `MCP_KQL_AUTH_MODE` | Kusto authentication mode: `azure-cli` or `managed-identity` | `azure-cli` |
| `AZURE_CLIENT_ID` | Optional user-assigned managed identity client ID | unset |
| `MCP_KQL_SQLITE_BUSY_TIMEOUT_MS` | SQLite busy timeout for concurrent local MCP instances | `30000` |
| `MCP_KQL_MAX_CONCURRENT_QUERIES` | Maximum simultaneous Kusto requests per process | `5` |
| `MCP_KQL_MAX_RESULT_ROWS` | Maximum rows returned in one MCP response | `10000` |
| `MCP_KQL_MAX_RESULT_BYTES` | Maximum default JSON response size | `2000000` |
| `MCP_KQL_MAX_CACHE_ENTRIES` | Maximum persisted query-result cache entries | `1000` |
| `MCP_KQL_MAX_CACHED_RESULT_BYTES` | Maximum size of one cached result | `2000000` |
| `MCP_KQL_CACHE_RESULTS` | Persist bounded query results in local SQLite | `true` |
| `MCP_KQL_EMBEDDING_MODEL` | Sentence Transformers model used for semantic retrieval | `all-MiniLM-L6-v2` |
| `MCP_KQL_LOG_LEVEL` | Server log level written to stderr | `INFO` |
| `MCP_KQL_ALLOW_UNAUTHENTICATED_REMOTE_HTTP` | Explicitly permit a non-loopback HTTP bind | `false` |
The embedding model is lazy loaded. Changing it causes schemas to be re-embedded on refresh, and vectors produced by other models are ignored rather than mixed.
Roo-code Or Cline (VS-code Extentions)
Ask or Add to your Roo-code Or Cline MCP settings:
MCP Settings location:
- All platforms: Through Roo-code extension settings or `mcp_settings.json`
{
"mcp-kql-server": {
"type": "stdio",
"command": "python",
"args": ["-m", "mcp_kql_server"],
"alwaysAllow": []
}
}Generic MCP Client
For any MCP-compatible application:
# Preferred: invoke as a Python module (cross-platform)
python -m mcp_kql_server
# Platform-stable launchers (recommended if `python` is ambiguous on PATH)
py -3 -m mcp_kql_server # Windows
python3 -m mcp_kql_server # macOS / Linux
# Equivalent console script installed by pip
mcp-kql-server
# Shared HTTP mode for multiple clients
python -m mcp_kql_server --transport http --host 127.0.0.1 --port 8000 --http-path /mcp --stateless-http
# Server provides these tools:
# - execute_kql_query: Execute KQL or generate KQL from natural language
# - kql_schema_memory: Discover, cache, and inspect cluster schemasπ§ Quick Start
1. Start the MCP Server (Zero configuration)
python -m mcp_kql_serverServer startup begins an Azure CLI token check in the background and runs plain interactive `az login` only when needed. Kusto tool calls never launch login; they wait for that startup task before executing. To authenticate manually before starting the server, run:
az loginTo inspect the installed server version and runtime defaults:
python -m mcp_kql_server --info --jsonThe server starts immediately with:
- π Auto-created memory path: `%APPDATA%\KQL_MCP\cluster_memory`
- π§ Optimized defaults: No configuration files needed
- π Secure setup: Uses your existing Azure CLI credentials
- β‘ Responsive startup: MCP discovery starts immediately while authentication initializes in the background
3. Use via MCP Client
The server provides two main tools:
> #### `execute_kql_query` - Execute KQL queries or generate KQL from natural language
> #### `kql_schema_memory` - Discover, refresh, and inspect cached cluster schemas
π‘ Usage Examples
Basic Query Execution
Ask your MCP client (like Claude):
> "Execute this KQL query against the help cluster: `cluster('help.kusto.windows.net').database('Samples').StormEvents | take 10` and summarize the result and give me high level insights "
Complex Analytics Query
Ask your MCP client:
> "Query the Samples database in the help cluster to show me the top 10 states by storm event count, include visualization"
Schema Discovery
Ask your MCP client:
> "Discover and cache the schema for the help.kusto.windows.net cluster, then tell me what databases and tables are available"
Data Exploration with Context
Ask your MCP client:
> "Using the StormEvents table in the Samples database on help cluster, show me all tornado events from 2007 with damage estimates over $1M"
Time-based Analysis
Ask your MCP client:
> "Analyze storm events by month for the year 2007 in the StormEvents table, group by event type and show as a visualization"
π― Key Benefits
For Data Analysts
- β‘ Faster Query Development: AI-powered autocomplete and suggestions
- π¨ Rich Visualizations: Instant markdown tables for data exploration
- π§ Context Awareness: Understand your data structure without documentation
For DevOps Teams
- π Automated Schema Discovery: Keep schema information up-to-date
- πΎ Smart Caching: Reduce API calls and improve performance
- π Secure Authentication: Leverage existing Azure CLI credentials
For AI Applications
- π€ Intelligent Query Assistance: AI-generated table descriptions and suggestions
- π Structured Data Access: Clean, typed responses for downstream processing
- π― Context-Aware Responses: Rich metadata for better AI decision making
ποΈ Architecture
%%{init: {'theme':'dark', 'themeVariables': {
'primaryColor':'#1a1a2e',
'primaryTextColor':'#00d9ff',
'primaryBorderColor':'#00d9ff',
'secondaryColor':'#16213e',
'secondaryTextColor':'#c77dff',
'secondaryBorderColor':'#c77dff',
'tertiaryColor':'#0f3460',
'tertiaryTextColor':'#ffaa00',
'tertiaryBorderColor':'#ffaa00',
'lineColor':'#00d9ff',
'textColor':'#ffffff',
'mainBkg':'#0a0e27',
'nodeBorder':'#00d9ff',
'clusterBkg':'#16213e',
'clusterBorder':'#9d4edd',
'titleColor':'#00ffff',
'edgeLabelBackground':'#1a1a2e',
'fontFamily':'Inter, Segoe UI, sans-serif',
'fontSize':'16px',
'flowchart':{'nodeSpacing':60, 'rankSpacing':80, 'curve':'basis', 'padding':20}
}}}%%
graph LR
Client["π₯οΈ MCP ClientClaude / AI / CustomβββββββββNatural LanguageInterface"]
subgraph Server["π MCP KQL Server"]
direction TB
FastMCP["β‘ FastMCPFrameworkβββββββββMCP ProtocolHandler"]
NL2KQL["π§ NL2KQLEngineβββββββββAI QueryGeneration"]
Executor["βοΈ QueryExecutorβββββββββValidation &Execution"]
Memory["πΎ SchemaMemoryβββββββββAI Cache"]
FastMCP --> NL2KQL
NL2KQL --> Executor
Executor --> Memory
Memory --> Executor
end
subgraph Azure["βοΈ Azure Services"]
direction TB
ADX["π Azure DataExplorerβββββββββKusto ClusterKQL Engine"]
Auth["π AzureIdentityβββββββββInteractiveCLI Auth"]
end
%% Client to Server
Client ==>|"π‘ MCP Protocolstdio or streamable HTTP"| FastMCP
%% Server to Azure
Executor ==>|"π Execute KQLQuery & Analyze"| ADX
Executor -->|"π Authenticate"| Auth
Memory -.->|"π₯ Fetch SchemaOn Demand"| ADX
%% Styling - Using cyberpunk palette
style Client fill:#1a1a2e,stroke:#00d9ff,stroke-width:4px,color:#00ffff
style FastMCP fill:#16213e,stroke:#c77dff,stroke-width:3px,color:#c77dff
style NL2KQL fill:#1a1a40,stroke:#ffaa00,stroke-width:3px,color:#ffaa00
style Executor fill:#16213e,stroke:#9d4edd,stroke-width:3px,color:#9d4edd
style Memory fill:#0f3460,stroke:#00d9ff,stroke-width:3px,color:#00d9ff
style ADX fill:#1a1a2e,stroke:#ff6600,stroke-width:4px,color:#ff6600
style Auth fill:#16213e,stroke:#00ffff,stroke-width:2px,color:#00ffff
style Server fill:#0a0e27,stroke:#9d4edd,stroke-width:3px,stroke-dasharray: 5 5
style Azure fill:#0a0e27,stroke:#ff6600,stroke-width:3px,stroke-dasharray: 5 5Report Generated by MCP-KQL-Server | β Star this repo on GitHub
π Production Deployment
Ready to deploy MCP KQL Server to Azure for production use? We provide comprehensive deployment automation for Azure Container Apps with enterprise-grade security and scalability.
π Features
- β Serverless Compute: Azure Container Apps with auto-scaling
- β Managed Identity: Passwordless authentication with Azure AD
- β Infrastructure as Code: Bicep templates for reproducible deployments
- β Monitoring: Integrated Log Analytics and Application Insights
- β Secure by Default: Network isolation, RBAC, and least-privilege access
- β One-Command Deploy: Automated PowerShell and Bash scripts
π Deployment Guide
For complete deployment instructions, architecture details, and troubleshooting:
**π View Production Deployment Guide**
The guide includes:
- ποΈ Detailed architecture diagrams
- βοΈ Step-by-step deployment instructions (PowerShell & Bash)
- π Security configuration best practices
- π Troubleshooting common issues
- π¦ Docker containerization details
Quick Deploy
# PowerShell (Windows)
cd deployment
.\deploy.ps1 -SubscriptionId "YOUR_SUB_ID" -ResourceGroupName "mcp-kql-prod-rg" -ClusterUrl "https://yourcluster.region.kusto.windows.net"
# Bash (Linux/Mac/WSL)
cd deployment
./deploy.sh --subscription "YOUR_SUB_ID" --resource-group "mcp-kql-prod-rg" --cluster-url "https://yourcluster.region.kusto.windows.net"π Project Structure
mcp-kql-server/
βββ mcp_kql_server/
β βββ __init__.py # Package initialization
β βββ mcp_server.py # Main MCP server implementation
β βββ execute_kql.py # KQL query execution logic
β βββ memory.py # Advanced memory management
β βββ kql_auth.py # Azure authentication
β βββ utils.py # Utility functions
β βββ constants.py # Configuration constants
βββ docs/ # Documentation
βββ Example/ # Usage examples
βββ pyproject.toml # Project configuration
βββ README.md # This fileπ Security
- Azure CLI Authentication: Reuses an existing token or starts interactive browser login
- No Credential Storage: Server doesn't store authentication tokens
- Local Memory: Schema cache stored locally, not transmitted
π Troubleshooting
Common Issues
1. Authentication Errors
# Re-authenticate with Azure CLI
az login --tenant your-tenant-id2. Memory Issues
# The memory cache is now managed automatically. If you suspect issues,
# you can clear the cache directory, and it will be rebuilt on the next query.
# Windows:
rmdir /s /q "%APPDATA%\KQL_MCP\unified_memory.json"
# macOS/Linux:
rm -rf ~/.local/share/KQL_MCP/cluster_memory3. Connection Timeouts
π€ Contributing
We welcome contributions! Please do.
π Support
- Issues: GitHub Issues
- PyPI Package: PyPI Project Page
- Author: Arjun Trivedi
- Certified : MCPHub
π Star History
mcp-name: io.github.4R9UN/mcp-kql-server
Happy Querying! π
Frequently asked questions
What is mcp-kql-server?
mcp-kql-server is Kusto and Log Analytics MCP server help you execute a KQL (Kusto Query Language) query within an AI prompt, analyze, and visualize the data.
How do I install mcp-kql-server?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is mcp-kql-server open source?
Yes β it is hosted on GitHub at https://github.com/4R9UN/mcp-kql-server and has 23 stars.
Related MCP tools
Control Gmail, Google Calendar, Docs, Sheets, Slides, Chat, Forms, Tasks, Search & Drive with AI - Comprehensive Google Workspace MCP Server & CLI Tool
Expose your FastAPI endpoints as Model Context Protocol (MCP) tools, with Auth! Python-based implementation. Trusted by 11000+ developers.
Cut AI token costs 95%+ on code exploration. The leading MCP server for precise, symbol-level GitHub code retrieval via tree-sitter AST. Works with Claude Code, Cursor & any MCP client. 313B+ tokens saved.
Open source implementation and extension of Google Researchβs PaperBanana for automated academic figures, diagrams, and research visuals, expanded to new domains like slide generation.
MCP server and Claude plugin for Postgres skills and documentation. Helps AI coding tools generate better PostgreSQL code.
AI-powered OSINT agent with interactive REPL, MCP server, and CLI. 19 tools. Works with Claude, GPT-4, or local models. For authorized security research only.
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP