Apache Druid 的 Model Context Protocol (MCP) 服务器 — 提供工具和资源,通过 Claude Desktop、VS Code 和其他 MCP 客户端查询和管理 Druid 数据源。
npx apache-druid-mcp
# 使用 SSE 传输运行
docker run -p 3000:3000 \
-e DRUID_URL=https://your-druid-cluster.com:8888 \
-e DRUID_USERNAME=your-username \
-e DRUID_PASSWORD=your-password \
anilreddy399/apache-druid-mcp:latest --transport sse --port 3000
# 使用 stdio 传输运行(用于直接 MCP 通信)
docker run -i \
-e DRUID_URL=https://your-druid-cluster.com:8888 \
-e DRUID_USERNAME=your-username \
-e DRUID_PASSWORD=your-password \
anilreddy399/apache-druid-mcp:latest
npm install
npm run build
npm start
DRUID_URL - Druid 路由器/代理 URL(默认:http://localhost:8888)DRUID_USERNAME - 认证用户名(大多数生产集群需要)DRUID_PASSWORD - 认证密码(大多数生产集群需要)DRUID_TIMEOUT - 请求超时时间(以毫秒为单位,默认:30000)# 默认 stdio 传输(适用于 MCP 客户端)
apache-druid-mcp
# SSE 传输,适用于基于 HTTP 的客户端
apache-druid-mcp --transport sse --port 3000
在您的 Claude Desktop 配置文件中添加此配置:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"apache-druid": {
"command": "npx",
"args": ["apache-druid-mcp"],
"env": {
"DRUID_URL": "https://your-druid-cluster.com:8888",
"DRUID_USERNAME": "your-username",
"DRUID_PASSWORD": "your-password"
}
}
}
}
对于本地开发(无需认证):
{
"mcpServers": {
"apache-druid": {
"command": "npx",
"args": ["apache-druid-mcp"],
"env": {
"DRUID_URL": "http://localhost:8888"
}
}
}
}
settings.json 中添加:{
"mcp.servers": {
"apache-druid": {
"command": "npx",
"args": ["apache-druid-mcp"],
"env": {
"DRUID_URL": "https://your-druid-cluster.com:8888",
"DRUID_USERNAME": "your-username",
"DRUID_PASSWORD": "your-password"
}
}
}
}
对于基于 HTTP 的 AI 编码助手,使用 SSE 传输:
{
"mcpServers": [
{
"name": "apache-druid",
"url": "http://localhost:3000/sse",
"env": {
"DRUID_URL": "https://your-druid-cluster.com:8888",
"DRUID_USERNAME": "your-username",
"DRUID_PASSWORD": "your-password"
}
}
]
}
启动带有 SSE 传输的服务器:
npx apache-druid-mcp --transport sse --port 3000
MCP 服务器提供了这些工具来与 Apache Druid 进行交互:
execute_sql_query执行针对 Druid 数据源的 SQL 查询。
参数:
query (字符串,必需) - 要执行的 SQL 查询context (对象,可选) - 查询上下文参数示例:
SELECT __time, page, COUNT(*) as views
FROM wikipedia
WHERE __time >= CURRENT_TIMESTAMP - INTERVAL '1' HOUR
GROUP BY 1, 2
ORDER BY views DESC
LIMIT 10
list_datasources获取 Druid 集群中所有可用数据源的列表。
get_datasource_metadata获取特定数据源的详细元数据,包括模式、段、大小和区间。
参数:
datasource (字符串,必需) - 数据源名称test_connection测试到 Druid 集群的连接,并返回状态信息。
通过以下资源访问 Druid 集群的信息:
druid://cluster/status - 当前集群状态和健康状况druid://datasources - 所有数据源的列表druid://datasource/{name} - 特定数据源的详细元数据# 使用默认设置启动
npx apache-druid-mcp
# 连接到远程 Druid 集群
DRUID_URL=https://druid.example.com:8888 npx apache-druid-mcp
# 带认证
DRUID_URL=https://secure-druid.com:8888 \
DRUID_USERNAME=admin \
DRUID_PASSWORD=secret \
npx apache-druid-mcp
配置完成后,您可以向 Claude 发出如下请求:
# 自定义超时时间和 SSE 传输
DRUID_TIMEOUT=60000 npx apache-druid-mcp --transport sse --port 8080
Apache 许可证 2.0