数据库查询工具

Elevate MCP Database Tools 是一个AI驱动的数据库查询工具,提供对MySQL和ClickHouse分析数据库的访问,适用于AB测试数据分析和商业智能场景。

  • by Ahmed-M-Elevate
  • Shell
  • 混合部署
  • 更新于
在 GitHub 查看 Ahmed-M-Elevate/elevate-mcp

使用说明

提升MCP数据库工具

MCP(模型上下文协议)服务器,用于查询Elevate AB测试数据库。提供对MySQL(PlanetScale)和ClickHouse分析数据库的人工智能访问。

快速开始

选项1:连接到远程服务器(推荐)

如果你的团队已经部署了MCP服务器,只需配置你的AI客户端:

克劳德代码

添加到 ~/.claude/settings.json:

{
  "mcpServers": {
    "elevate-db": {
      "type": "sse",
      "url": "https://mcp.elevateab.com/sse",
      "headers": {
        "Authorization": "Basic <base64-encoded-credentials>"
      }
    }
  }
}

克劳德桌面版

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json 窗户: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "elevate-db": {
      "type": "sse",
      "url": "https://mcp.elevateab.com/sse",
      "headers": {
        "Authorization": "Basic <base64-encoded-credentials>"
      }
    }
  }
}

光标

添加到光标设置(设置→ MCP服务器):

{
  "elevate-db": {
    "type": "sse",
    "url": "https://mcp.elevateab.com/sse",
    "headers": {
      "Authorization": "Basic <base64-encoded-credentials>"
    }
  }
}

GitHub副本(VS代码)

Copilot中的MCP支持是实验性的。查看最新的配置文档。


选项2:本地安装

先决条件

  • 转到1.21+或下载预构建的二进制文件
  • 数据库凭据(请参阅 .env.example)

步骤1:安装MCP工具箱

选项A:通过Go安装

go install github.com/googleapis/genai-toolbox@latest

选项B:下载二进制文件

# Linux
wget https://github.com/googleapis/genai-toolbox/releases/latest/download/toolbox-linux-amd64 -O toolbox
chmod +x toolbox
sudo mv toolbox /usr/local/bin/

# macOS (Intel)
wget https://github.com/googleapis/genai-toolbox/releases/latest/download/toolbox-darwin-amd64 -O toolbox

# macOS (Apple Silicon)
wget https://github.com/googleapis/genai-toolbox/releases/latest/download/toolbox-darwin-arm64 -O toolbox

chmod +x toolbox
sudo mv toolbox /usr/local/bin/

步骤2:配置环境

cd databases/
cp .env.example .env
# Edit .env with your credentials

步骤3:运行服务器

# Using the wrapper script
./toolbox-wrapper.sh

# Or directly
toolbox --tools-file tools.yaml --address 0.0.0.0 --port 5000

步骤4:配置AI客户端

对于本地安装,请使用命令模式而不是SSE:

克劳德代码 (~/.claude/settings.json):

{
  "mcpServers": {
    "elevate-db": {
      "command": "toolbox",
      "args": ["--tools-file", "/path/to/databases/tools.yaml"]
    }
  }
}

克劳德桌面:

{
  "mcpServers": {
    "elevate-db": {
      "command": "/usr/local/bin/toolbox",
      "args": ["--tools-file", "/path/to/databases/tools.yaml"],
      "env": {
        "DB_USERNAME": "your-username",
        "DB_PASSWORD": "your-password",
        "CLICKHOUSE_USERNAME": "your-ch-username",
        "CLICKHOUSE_PASSWORD": "your-ch-password"
      }
    }
  }
}

可用工具

MySQL工具(27个工具)

工具 说明
list_tables 列出所有数据库表
query 执行SELECT查询
execute 执行任何SQL语句
get_all_shops 获取所有有订阅信息的商店
get_active_shops 激活(未卸载)商店
search_shop_by_domain 按域名搜索店铺
get_shop_by_id 按ID获取店铺详细信息
get_shops_by_plan 按订阅计划购买店铺
get_test_by_id 获取测试/实验详细信息
list_tests_by_store 列出商店的测试
get_test_variations 获取测试变化
get_active_tests 获取所有正在运行的测试
get_tests_by_status 按状态筛选测试
get_tests_by_type 按类型筛选测试
get_test_history 获取测试生命周期历史记录
get_test_suggestions 获取测试建议
update_test_status 更新测试状态
get_orders_by_visitor 按访客ID获取订单
get_orders_by_date_range 获取日期范围内的订单
get_order_variations 获取订单的测试变体
get_line_items_by_order 获取订单行项目
get_shop_stats 获取店铺统计数据
get_test_stats 获取测试统计数据
get_recent_activity 获取最近的测试活动
get_promo_codes 获取有效促销代码
get_product_variants_by_test 获取价格变体
get_shipping_by_variation 获取发货确认

ClickHouse分析工具(19个工具)

工具 说明
ch_list_tables 列出ClickHouse表格
ch_describe_table 描述表模式
ch_query 执行SELECT查询
ch_execute 执行任何SQL语句
ch_get_events_summary 按类型列出的事件计数
ch_get_daily_traffic 每日页面浏览量和访问者
ch_get_hourly_traffic 每小时交通模式
ch_get_top_pages 按流量划分的首页
ch_get_device_breakdown 按设备类型划分的流量
ch_get_browser_breakdown 按浏览器划分的流量
ch_get_geo_breakdown 按国家划分的交通量
ch_get_traffic_sources 按来源划分的流量
ch_get_conversion_funnel 转化漏斗指标
ch_get_cart_abandonment 购物车放弃率
ch_get_order_revenue 收入指标
ch_get_daily_revenue 每日收入明细
ch_get_product_performance 产品销售指标
ch_get_test_analytics 测试事件分解
ch_get_test_variant_performance 变体性能

看 TOOLS.md 获取所有工具的详细文档。


使用示例

让克劳德查询数据

"Show me all active tests for mystore.myshopify.com"

"What's the conversion funnel for elevate-demo.myshopify.com last month?"

"Find orders from January 2025 with test variations"

"Compare device breakdown for our top 3 stores"

常见工作流程

检查商店健康状况:

1. Get store details: get_shop_by_id
2. List active tests: list_tests_by_store
3. Check conversion: ch_get_conversion_funnel
4. Review traffic: ch_get_daily_traffic

分析测试性能:

1. Get test info: get_test_by_id
2. Get variations: get_test_variations
3. Get analytics: ch_get_test_analytics
4. Compare variants: ch_get_test_variant_performance

文件

文件 描述
tools.yaml MCP工具定义和SQL查询
.env.example 环境变量模板
README.md 此文件
TOOLS.md 详细的工具文档
DEPLOYMENT.md 服务器部署指南
toolbox-wrapper.sh 加载env的启动脚本

工具集和只读模式

使用包装脚本

这 toolbox-wrapper.sh 脚本自动加载 .env 并支持工具集:

# Run with all tools (default)
./toolbox-wrapper.sh

# Run in READ-ONLY mode (safe for production)
READ_ONLY=true ./toolbox-wrapper.sh

# Or set in .env file
# READ_ONLY=true

手动工具集选择

# Read-only (safe for production) - excludes execute, update tools
toolbox --tools-file tools.yaml --toolset readonly

# MySQL only
toolbox --tools-file tools.yaml --toolset mysql

# ClickHouse only
toolbox --tools-file tools.yaml --toolset clickhouse

# All tools (default)
toolbox --tools-file tools.yaml --toolset all

只读工具集

这 readonly 工具集不包括这些写入操作:

  • execute -MySQL写操作
  • ch_execute -ClickHouse写入操作
  • update_test_status -测试状态更新

用于安全生产访问。


安全

  • 永不承诺 .env -包含数据库凭据
  • 使用只读工具集 用于生产查询
  • 启用身份验证 通过URL公开时
  • 限制IP访问 在生产部署中

看 部署.md 用于安全配置。


故障排除

连接被拒绝

# Check if server is running
curl http://localhost:5000/health

# Check environment variables
cat .env

数据库错误

# Test MySQL connection
mysql -h aws.connect.psdb.cloud -u $DB_USERNAME -p

# Test ClickHouse connection
curl "https://$CLICKHOUSE_HOST:8443/?query=SELECT%201"

未找到工具

确保tools.yaml位于正确的路径中,然后重新启动MCP服务器。


支持