GreptimeDB AI服务

@GreptimeTeam/greptimedb-mcp-server
0 Stars 334 次浏览 GreptimeTeam 更新于 2026-08-23

一种实现了模型上下文协议的服务器,使人工智能助手能够安全地与GreptimeDB交互,允许它们通过受控接口探索数据库模式、读取数据和执行SQL查询。

该服务暂未提供标准配置,请参考 README 手动接入

服务介绍

greptimedb-mcp-server

一个用于 GreptimeDB 的 Model Context Protocol (MCP) 服务器实现。

此服务器为 AI 助手提供了一种安全且结构化的方式来探索和分析数据库。它允许它们通过受控接口列出表、读取数据以及执行 SQL 查询,从而确保负责任的数据库访问。

功能

  • list_resources 列出表
  • read_resource 读取表数据
  • list_tools 列出工具
  • call_tool 执行 SQL
  • list_prompts 列出提示
  • get_prompt 按名称获取提示

安装

pip install greptimedb-mcp-server

配置

设置以下环境变量:

GREPTIMEDB_HOST=localhost    # Database host
GREPTIMEDB_PORT=4002         # Optional: Database port (defaults to 4002 if not specified)
GREPTIMEDB_USER=root
GREPTIMEDB_PASSWORD=
GREPTIMEDB_DATABASE=public

或者通过命令行参数:

  • --host 数据库主机
  • --port 数据库端口
  • --user 数据库用户名
  • --password 数据库密码
  • --database 数据库名称

使用

Claude Desktop 集成

在 Claude Desktop 的配置文件中配置 MCP 服务器:

MacOS

位置: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows

位置: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "greptimedb": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/greptimedb-mcp-server",
        "run",
        "-m",
        "greptimedb_mcp_server.server"
      ],
      "env": {
        "GREPTIMEDB_HOST": "localhost",
        "GREPTIMEDB_PORT": "4002",
        "GREPTIMEDB_USER": "root",
        "GREPTIMEDB_PASSWORD": "",
        "GREPTIMEDB_DATABASE": "public"
      }
    }
  }
}

许可证

MIT 许可证 - 详情请参阅 LICENSE.md 文件。

贡献

前提条件

  • 带有 uv 包管理器的 Python
  • GreptimeDB 安装
  • MCP 服务器依赖项

开发

# Clone the repository
git clone https://github.com/GreptimeTeam/greptimedb-mcp-server.git
cd greptimedb-mcp-server

# Create virtual environment
uv venv
source venv/bin/activate  # or `venv\Scripts\activate` on Windows

# Install development dependencies
uv sync

# Run tests
pytest

使用 MCP Inspector 进行调试:

npx @modelcontextprotocol/inspector uv \
  --directory \
  /path/to/greptimedb-mcp-server \
  run \
  -m \
  greptimedb_mcp_server.server

致谢

本库的实现受到以下两个仓库的启发,并融入了它们的代码,在此表示感谢:

谢谢!

相关 MCP 服务