Kusto NL2KQL MCP server

Enables natural language querying of Azure Data Explorer (Kusto) databases by translating questions into KQL queries without requiring KQL expertise
Back to servers
Setup instructions
Provider
Alex Neyler
Release date
Apr 19, 2025
Language
C#
Stats
3 stars

The MCP Server is designed to interface with Kusto databases, allowing you to query and manage resources effectively. This tool leverages Azure OpenAI to help interpret and generate Kusto Query Language (KQL) queries based on natural language inputs.

Installation and Setup

To use the MCP server, you need to create a configuration file and run the server with this configuration.

Creating a Settings File

Create a settings.yaml file with the following structure:

model:
  endpoint: <Azure OpenAI Endpoint>
  deployment: <Deployment Name>

kusto:
  - name: <Table Name>
    category: <Category>
    database: <Database Name>
    table: <Table Name>
    endpoint: <Kusto Endpoint>
    prompts:
      - type: <Prompt Type>
        content: |
          <Prompt Content>

Configuration Parameters

Model Section

  • endpoint: Your Azure OpenAI service endpoint URL
  • deployment: The deployment name for your Azure OpenAI model

Kusto Section

  • name: Identifier for the Kusto table
  • category: Category classification for the table
  • database: Name of your Kusto database
  • table: Specific table name within the database
  • endpoint: The Kusto cluster endpoint URL
  • prompts: A collection of prompts to help the model understand and query your data
    • type: Can be system, user, or assistant
    • content: The prompt text, which may include KQL queries

Usage Example

Here's a complete configuration example:

model:
  endpoint: https://myopenai.openai.azure.com
  deployment: gpt-4

kusto:
  - name: mytable
    category: mycategory
    database: mydatabase
    table: table
    endpoint: https://table.kusto.windows.net
    prompts:
      - type: system
        content: |
          The table contains the following columns:
          * Id: id of the resource
          * Name: name of the resource
          * CreationTime: timestamp when the resource was created
          * LastModified: timestamp when the resource was last modified
          * Owner: owner of the resource
      - type: user
        content: When was the resource 'my resource' created in mycategory/mytable?
      - type: assistant
        content: |
          table
          | where name == 'my resource'
          | project CreationTime
      - type: user
        content: How many resources were created after April 1st, 2025?
      - type: assistant
        content: |
          table
          | where CreationTime > datetime(2025-04-01)
          | summarize count()
      - type: user
        content: Which owner owns the most resources in mycategory/mytable?
      - type: assistant
        content: |
          table
          | summarize Resources=count() by Owner
          | order by Resources desc
          | take 1
          | project Owner

Running the MCP Server

To start the MCP server, use the --settings argument pointing to your configuration file:

mcp-server --settings path/to/settings.yaml

Authentication

Authentication is handled through the currently logged-in Windows user. Make sure you:

  • Have run az login if using Azure CLI
  • Are logged into Visual Studio or VS Code with appropriate credentials
  • Have appropriate permissions to access the configured Kusto databases

The more detailed your system prompts and examples in the configuration file, the better the model will understand your data schema and generate appropriate KQL queries.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "kusto-nl2kql" '{"command":"docker","args":["run","-i","--rm","-v","${workspaceFolder}/settings.yaml:/app/settings.yaml","-e","AZURE_OPENAI_KEY","-e","KUSTO_ACCESS_TOKEN","alexeyler/kusto-mcp-server"],"env":{"AZURE_OPENAI_KEY":"${input:azure-open-ai-key}","KUSTO_ACCESS_TOKEN":"${input:kusto-token}"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "kusto-nl2kql": {
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "-v",
                "${workspaceFolder}/settings.yaml:/app/settings.yaml",
                "-e",
                "AZURE_OPENAI_KEY",
                "-e",
                "KUSTO_ACCESS_TOKEN",
                "alexeyler/kusto-mcp-server"
            ],
            "env": {
                "AZURE_OPENAI_KEY": "${input:azure-open-ai-key}",
                "KUSTO_ACCESS_TOKEN": "${input:kusto-token}"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "kusto-nl2kql": {
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "-v",
                "${workspaceFolder}/settings.yaml:/app/settings.yaml",
                "-e",
                "AZURE_OPENAI_KEY",
                "-e",
                "KUSTO_ACCESS_TOKEN",
                "alexeyler/kusto-mcp-server"
            ],
            "env": {
                "AZURE_OPENAI_KEY": "${input:azure-open-ai-key}",
                "KUSTO_ACCESS_TOKEN": "${input:kusto-token}"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later