Apache Druid MCP服务器
Apache Druid的模型上下文协议(MCP)服务器-通过Claude Desktop、VS Code和其他MCP客户端提供查询和管理Druid数据源的工具和资源。
特性
- 🔍 对Apache Druid执行SQL查询
- 📊 列出并探索数据源
- 📋 获取详细的元数据,包括模式、段和大小信息
- 🔗 测试Druid集群连接
- 🚀 多种传输协议:stdio(默认)和服务器发送事件(SSE)
- 🐳 通过已发布的镜像支持Docker
快速开始
NPX(推荐)
npx apache-druid-mcp码头工人
# Run with SSE transport
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
# Run with stdio transport (for direct MCP communication)
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-德鲁伊路由器/代理URL(默认值:http://localhost:8888)DRUID_USERNAME-身份验证用户名(大多数生产集群都需要)DRUID_PASSWORD-身份验证密码(大多数生产集群都需要)DRUID_TIMEOUT-请求超时(毫秒)(默认值:30000)
运输选项
# Default stdio transport (for MCP clients)
apache-druid-mcp
# SSE transport for HTTP-based clients
apache-druid-mcp --transport sse --port 3000Claude桌面集成
将此配置添加到您的Claude Desktop配置文件中:
macOS
~/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"
}
}
}
}VS代码集成
使用MCP扩展
- 安装VS Code的MCP扩展
- 添加到您的VS代码设置.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"
}
}
}
}使用Codeium或Continue.dev
对于基于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 10list_datasources
获取Druid集群中所有可用数据源的列表。
get_datasource_metadata
获取特定数据源的详细元数据,包括模式、段、大小和间隔。
参数:
datasource(string,必填)-数据源的名称
test_connection
测试与Druid集群的连接并返回状态信息。
可用资源
通过以下资源访问Druid集群信息:
druid://cluster/status-当前群集状态和运行状况druid://datasources-所有数据源列表druid://datasource/{name}-特定数据源的详细元数据
例子
基本用法
# Start with default settings
npx apache-druid-mcp
# Connect to remote Druid cluster
DRUID_URL=https://druid.example.com:8888 npx apache-druid-mcp
# With authentication
DRUID_URL=https://secure-druid.com:8888 \
DRUID_USERNAME=admin \
DRUID_PASSWORD=secret \
npx apache-druid-mcp与Claude Desktop一起使用
配置后,您可以询问Claude:
- “显示Druid中可用的数据源”
- “查询维基百科数据源,查找过去一小时的首页”
- “事件数据源的架构是什么?”
- “测试与德鲁伊的连接”
高级配置
# Custom timeout and SSE transport
DRUID_TIMEOUT=60000 npx apache-druid-mcp --transport sse --port 8080许可证
Apache许可证2.0
