KQL (Azure Data Explorer) logo

KQL (Azure Data Explorer)

Community
4r9un

Kusto and Log Analytics MCP server help you execute a KQL (Kusto Query Language) query within an AI prompt, analyze, and visualize the data.

Publisher4r9un
Repositorymcp-kql-server
LanguagePython
Forks
6
Stars
23
Available tools
0
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    KQL (Azure Data Explorer) exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    23 stars and 6 forks from the linked repository.

MCP KQL Server

mcp-name: io.github.4R9UN/mcp-kql-server

MseeP.ai Security Assessment Badge

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.2 - Hardcoded 10-minute Kusto servertimeout, ADX-side dry-run validation for generated queries, schema-drift recovery loop, and fully schema-driven NL2KQL with no hardcoded table or column names.

Verified on MseeP MCP Registry PyPI version Python

CI/CD Pipeline codecov Security Rating Code Quality

FastMCP Azure Data Explorer MCP Protocol Maintenance MCP Badge

šŸŽ¬ Demo

Watch a quick demo of the MCP KQL Server in action:

MCP KQL Server Demo

šŸš€ Features

  • execute_kql_query:

    • Natural Language to KQL: Generate KQL queries from natural language descriptions.
    • Direct KQL Execution: Execute raw KQL queries.
    • Multiple Output Formats: Supports JSON, CSV, and table formats.
    • Strict Schema Validation: Uses discovered schema memory and validation before execution.
    • Schema-Grounded Repair: Repairs invalid columns only when a valid table schema can prove the replacement.
  • schema_memory:

    • Schema Discovery: Discover and cache schemas for tables.
    • Database Exploration: List all tables within a database.
    • AI Context: Get ranked CAG context for tables, with optional table-scoped strict schema output.
    • Analysis Reports: Generate reports with visualizations.
    • Cache Management: Clear or refresh the schema cache.
    • Memory Statistics: Get statistics about the memory usage.

šŸ“Š MCP Tools Execution Flow

mermaid
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:#ffffff

Schema 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.

mermaid
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 and authenticated (az login)
  • Access to Azure Data Explorer cluster(s)

šŸš€ One-Command Installation

Quick Install (Recommended)

From Source

bash
git clone https://github.com/4R9UN/mcp-kql-server.git && cd mcp-kql-server && pip install -e .

Alternative Installation Methods

bash
pip install mcp-kql-server

That'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
json
{
  "mcpServers": {
    "mcp-kql-server": {
      "type": "stdio",
      "command": "python",
      "args": ["-m", "mcp_kql_server"]
    }
  }
}

Windows (the py launcher always lives at C:\Windows\py.exe):

json
{
  "mcpServers": {
    "mcp-kql-server": {
      "type": "stdio",
      "command": "py",
      "args": ["-3", "-m", "mcp_kql_server"]
    }
  }
}

On macOS / Linux replace "py" with "python3" and drop the "-3" arg.

Or use the console script that pip install drops on PATH:

json
{
  "mcpServers": {
    "mcp-kql-server": {
      "type": "stdio",
      "command": "mcp-kql-server",
      "args": []
    }
  }
}

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
json
{
  "servers": {
    "mcp-kql-server": {
      "type": "stdio",
      "command": "python",
      "args": ["-m", "mcp_kql_server"]
    }
  }
}

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.

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
json
{
  "mcp-kql-server": {
    "type": "stdio",
    "command": "python",
    "args": ["-m", "mcp_kql_server"],
    "alwaysAllow": []
  }
}

Generic MCP Client

For any MCP-compatible application:

bash
# 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

# Server provides these tools:
# - execute_kql_query: Execute KQL or generate KQL from natural language
# - schema_memory: Discover, cache, and inspect cluster schemas

šŸ”§ Quick Start

1. Authenticate with Azure (One-time setup)

bash
az login

2. Start the MCP Server (Zero configuration)

bash
python -m mcp_kql_server

The 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

3. Use via MCP Client

The server provides two main tools:

execute_kql_query - Execute KQL queries or generate KQL from natural language

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

mermaid
%%{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 Client<br/><b>Claude / AI / Custom</b><br/>─────────<br/>Natural Language<br/>Interface"]
    
    subgraph Server["šŸš€ MCP KQL Server"]
        direction TB
        FastMCP["⚔ FastMCP<br/>Framework<br/>─────────<br/>MCP Protocol<br/>Handler"]
        NL2KQL["🧠 NL2KQL<br/>Engine<br/>─────────<br/>AI Query<br/>Generation"]
        Executor["āš™ļø Query<br/>Executor<br/>─────────<br/>Validation &<br/>Execution"]
        Memory["šŸ’¾ Schema<br/>Memory<br/>─────────<br/>AI Cache"]
        
        FastMCP --> NL2KQL
        NL2KQL --> Executor
        Executor --> Memory
        Memory --> Executor
    end
    
    subgraph Azure["ā˜ļø Azure Services"]
        direction TB
        ADX["šŸ“Š Azure Data<br/>Explorer<br/>─────────<br/><b>Kusto Cluster</b><br/>KQL Engine"]
        Auth["šŸ” Azure<br/>Identity<br/>─────────<br/>Device Code<br/>CLI Auth"]
    end
    
    %% Client to Server
    Client ==>|"šŸ“” MCP Protocol<br/>STDIO/SSE"| FastMCP
    
    %% Server to Azure
    Executor ==>|"šŸ” Execute KQL<br/>Query & Analyze"| ADX
    Executor -->|"šŸ” Authenticate"| Auth
    Memory -.->|"šŸ“„ Fetch Schema<br/>On 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 5

Report 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

bash
# 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: Leverages your existing Azure device login
  • No Credential Storage: Server doesn't store authentication tokens
  • Local Memory: Schema cache stored locally, not transmitted

šŸ› Troubleshooting

Common Issues

  1. Authentication Errors

    bash
    # Re-authenticate with Azure CLI
    az login --tenant your-tenant-id
  2. Memory Issues

    bash
    # 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_memory
  3. Connection Timeouts

    • Check cluster URI format
    • Verify network connectivity
    • Confirm Azure permissions

šŸ¤ Contributing

We welcome contributions! Please do.

šŸ“ž Support

🌟 Star History

Star History Chart


mcp-name: io.github.4R9UN/mcp-kql-server

Happy Querying! šŸŽ‰

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "mcp-kql-server": {
      "command": "uvx",
      "args": [
        "mcp-kql-server"
      ]
    }
  }
}

Use KQL (Azure Data Explorer) MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once KQL (Azure Data Explorer) is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add KQL (Azure Data Explorer) as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the KQL (Azure Data Explorer) MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "kql-azure-data-explorer": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-kql-server"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the KQL (Azure Data Explorer) MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the KQL (Azure Data Explorer) MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use KQL (Azure Data Explorer) to help me with this task?
KQL (Azure Data Explorer)
Sure. I read it.
Here is what I found using KQL (Azure Data Explorer).

Frequently asked questions

What is the KQL (Azure Data Explorer) MCP server used for?

KQL (Azure Data Explorer) is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use KQL (Azure Data Explorer) MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use KQL (Azure Data Explorer) with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use KQL (Azure Data Explorer) MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With KQL (Azure Data Explorer) connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect KQL (Azure Data Explorer) MCP to TypingMind?

KQL (Azure Data Explorer) runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does KQL (Azure Data Explorer) MCP provide in TypingMind?

KQL (Azure Data Explorer) exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use KQL (Azure Data Explorer) MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If KQL (Azure Data Explorer) requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter šŸ‘‡