Skip to main content
Glama
adx-mcp-server

adx-mcp-server

by pab1it0

Azure 数据资源管理器 MCP 服务器

Microsoft Fabric 中 Azure 数据资源管理器/Eventhouse 的模型上下文协议(MCP) 服务器。

这可以通过标准化的 MCP 接口访问您的 Azure 数据资源管理器/Eventhouse 集群和数据库,从而允许 AI 助手执行 KQL 查询并探索您的数据。

特征

  • [x] 针对 Azure 数据资源管理器执行 KQL 查询

  • [x] 发现和探索数据库资源

    • [x] 列出已配置数据库中的表

    • [x] 查看表模式

    • [x] 表格中的示例数据

    • [x] 获取表统计信息/详细信息

  • [x] 身份验证支持

    • [x] 令牌凭据支持(Azure CLI、MSI 等)

    • [x] AKS 的 Workload Identity 凭据支持

  • [x] Docker 容器化支持

  • [x] 为AI助手提供交互工具

工具列表是可配置的,因此您可以选择要向 MCP 客户端提供的工具。如果您不使用某些功能,或者不想占用太多上下文窗口空间,此功能非常有用。

Related MCP server: EdgeLake MCP Server

用法

  1. 使用 Azure CLI 登录到具有 ADX 群集权限的 Azure 帐户。

  2. 通过.env文件或系统环境变量配置 ADX 集群的环境变量:

# Required: Azure Data Explorer configuration
ADX_CLUSTER_URL=https://yourcluster.region.kusto.windows.net
ADX_DATABASE=your_database

# Optional: Azure Workload Identity credentials 
# AZURE_TENANT_ID=your-tenant-id
# AZURE_CLIENT_ID=your-client-id 
# ADX_TOKEN_FILE_PATH=/var/run/secrets/azure/tokens/azure-identity-token

Azure 工作负载身份支持

现在,在配置了工作负载标识的 Azure Kubernetes 服务 (AKS) 环境中运行时,服务器默认使用 WorkloadIdentityCredential。只要存在必要的环境变量,它就会优先使用 WorkloadIdentityCredential。

对于具有 Azure Workload Identity 的 AKS,只需:For AKS with Azure Workload Identity, you only need to:

  1. 确保 Pod 已设置AZURE_TENANT_ID和AZURE_CLIENT_ID环境变量

  2. 确保令牌文件安装在默认路径或使用ADX_TOKEN_FILE_PATH指定自定义路径

如果这些环境变量不存在,服务器将自动回退到 DefaultAzureCredential,它会按顺序尝试多种身份验证方法。

  1. 将服务器配置添加到客户端配置文件中。例如,对于 Claude Desktop:

{
  "mcpServers": {
    "adx": {
      "command": "uv",
      "args": [
        "--directory",
        "<full path to adx-mcp-server directory>",
        "run",
        "src/adx_mcp_server/main.py"
      ],
      "env": {
        "ADX_CLUSTER_URL": "https://yourcluster.region.kusto.windows.net",
        "ADX_DATABASE": "your_database"
      }
    }
  }
}

注意:如果您在 Claude Desktop 中看到Error: spawn uv ENOENT ,则可能需要指定uv的完整路径或在配置中设置环境变量NO_UV=1 。

Docker 使用

该项目包括 Docker 支持,以便于部署和隔离。

构建 Docker 镜像

使用以下方式构建 Docker 镜像:

docker build -t adx-mcp-server .

使用 Docker 运行

您可以通过多种方式使用 Docker 运行服务器:

直接使用 docker run:

docker run -it --rm \
  -e ADX_CLUSTER_URL=https://yourcluster.region.kusto.windows.net \
  -e ADX_DATABASE=your_database \
  -e AZURE_TENANT_ID=your_tenant_id \
  -e AZURE_CLIENT_ID=your_client_id \
  adx-mcp-server

使用docker-compose:

使用您的 Azure 数据资源管理器凭据创建一个.env文件,然后运行:

docker-compose up

在 Claude Desktop 中使用 Docker 运行

要将容器化服务器与 Claude Desktop 一起使用,请更新配置以使用带有环境变量的 Docker:

{
  "mcpServers": {
    "adx": {
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "-e", "ADX_CLUSTER_URL",
        "-e", "ADX_DATABASE",
        "-e", "AZURE_TENANT_ID",
        "-e", "AZURE_CLIENT_ID",
        "-e", "ADX_TOKEN_FILE_PATH",
        "adx-mcp-server"
      ],
      "env": {
        "ADX_CLUSTER_URL": "https://yourcluster.region.kusto.windows.net",
        "ADX_DATABASE": "your_database",
        "AZURE_TENANT_ID": "your_tenant_id",
        "AZURE_CLIENT_ID": "your_client_id",
        "ADX_TOKEN_FILE_PATH": "/var/run/secrets/azure/tokens/azure-identity-token"
      }
    }
  }
}

此配置通过使用仅带有变量名的-e标志,并在env对象中提供实际值,将环境变量从 Claude Desktop 传递到 Docker 容器。

用作开发容器/GitHub Codespace

此存储库还可用作开发容器,以实现无缝的开发体验。开发容器的安装程序位于devcontainer-feature/adx-mcp-server文件夹中。

有关更多详细信息,请查看devcontainer README 。

发展

欢迎贡献代码!如果您有任何建议或改进,请创建 issue 或提交 pull request。

本项目使用uv来管理依赖项。请按照您平台的说明安装uv :

curl -LsSf https://astral.sh/uv/install.sh | sh

然后,您可以创建一个虚拟环境并使用以下命令安装依赖项:

uv venv
source .venv/bin/activate  # On Unix/macOS
.venv\Scripts\activate     # On Windows
uv pip install -e .

项目结构

该项目已采用src目录结构进行组织:

adx-mcp-server/
├── src/
│   └── adx_mcp_server/
│       ├── __init__.py      # Package initialization
│       ├── server.py        # MCP server implementation
│       ├── main.py          # Main application logic
├── Dockerfile               # Docker configuration
├── docker-compose.yml       # Docker Compose configuration
├── .dockerignore            # Docker ignore file
├── pyproject.toml           # Project configuration
└── README.md                # This file

测试

该项目包括一个全面的测试套件,可确保功能并有助于防止回归。

使用 pytest 运行测试:

# Install development dependencies
uv pip install -e ".[dev]"

# Run the tests
pytest

# Run with coverage report
pytest --cov=src --cov-report=term-missing

测试分为:

  • 配置验证测试

  • 服务器功能测试

  • 错误处理测试

  • 主要应用测试

当添加新功能时,请同时添加相应的测试。

工具

工具

类别

描述

execute_query

询问

对 Azure 数据资源管理器执行 KQL 查询

list_tables

发现

列出配置数据库中的所有表

get_table_schema

发现

获取特定表的架构

sample_table_data

发现

从具有可选样本大小的表中获取样本数据

执照

麻省理工学院


Available Tools

5 tools
execute_queryB

Executes a Kusto Query Language (KQL) query against the configured Azure Data Explorer database and returns the results as a list of dictionaries.

Inputs: query (required). Returns: result

get_table_detailsC

Retrieves table details including TotalRowCount, HotExtentSize

Inputs: table_name (required). Returns: result

get_table_schemaB

Retrieves the schema information for a specified table in the Azure Data Explorer database, including column names, data types, and other schema-related metadata.

Inputs: table_name (required). Returns: result

list_tablesA

Retrieves a list of all tables available in the configured Azure Data Explorer database, including their names, folders, and database associations.

Inputs: no named parameters. Returns: result

sample_table_dataB

Retrieves a random sample of rows from the specified table in the Azure Data Explorer database. The sample_size parameter controls how many rows to return (default: 10).

Inputs: table_name (required), sample_size. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool targets a distinct purpose: listing tables, retrieving schema, retrieving details, sampling data, and executing arbitrary queries. No overlap and clear boundaries between tools.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern (e.g., list_tables, get_table_schema, execute_query) using snake_case, making them predictable and easy to interpret.

    Tool Count5/5

    Five tools is well-scoped for a read-only Azure Data Explorer query server, covering essential operations like listing, schema retrieval, details, sampling, and querying without unnecessary clutter.

    Completeness4/5

    The tool set provides a solid foundation for querying and metadata retrieval. Missing are data modification or ingestion tools, but for a query-focused server this is acceptable, though a bit more (e.g., table statistics) could enhance completeness.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables 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.
      70 PyPI
      24
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to query and explore distributed data across EdgeLake nodes through SQL operations, resource discovery, and schema inspection. Supports complex queries with joins, aggregations, and metadata fields across multiple databases and tables.
      Mozilla Public 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI assistants to query Azure Data Explorer using natural language, eliminating the need to write KQL.
      7
      459 npm
      8
      MIT