Token导航 LogoToken导航TokenDH.com
GreptimeDB MCP logo
数据服务stdio官方级别未说明来源级核验

GreptimeDB MCP

MCP Server

A Model Context Protocol (MCP) server implementation for GreptimeDB

工具数

13

提示词数

0

GitHub Stars

27

资源数

0
数据安全数据分析PythonClaudeClaude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

GreptimeTeam

提供方

GreptimeTeam

最后核验

2026/5/18 04:05

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install greptimedb-mcp-server

详细介绍

greoptimedb-mcp服务器

](https://pypi.org/project/greptimedb-mcp-server/) build workflow ![MCP Registry](https://registry.modelcontextprotocol.io/?q=io.github.GreptimeTeam%2Fgreptimedb-mcp-server) ![MIT License](LICENSE.md)

一种模型上下文协议(MCP)服务器 GreptimeDB --一个开源的可观察性数据库,在一个引擎中处理度量、日志和跟踪。

使AI助手能够使用SQL、TQL(兼容PromQL)和RANGE查询查询和分析GreptimeDB,并具有只读强制和数据屏蔽等内置安全功能。

快速开始

# Install
pip install greptimedb-mcp-server

# Run (connects to localhost:4002 by default)
greptimedb-mcp-server --host localhost --database public

对于Claude Desktop,请将此添加到您的配置中(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):

{
  "mcpServers": {
    "greptimedb": {
      "command": "greptimedb-mcp-server",
      "args": ["--host", "localhost", "--database", "public"]
    }
  }
}

特性

工具

工具说明
execute_sql使用格式(csv/json/makdown)和限制选项执行SQL查询
execute_tql执行TQL(兼容PromQL)查询以进行时间序列分析
query_range使用RANGE/ALIGN语法执行时间窗口聚合查询
describe_table获取包含列名、类型和约束的表架构
explain_query分析SQL或TQL查询执行计划
health_check检查数据库连接状态和服务器版本

管道管理

工具说明
list_pipelines列出所有管道或获取特定管道的详细信息
create_pipeline使用YAML配置创建新管道
dryrun_pipeline使用示例数据测试管道,而不写入数据库
delete_pipeline删除管道的特定版本

仪表板管理

工具说明
list_dashboards列出所有Perses仪表板定义
create_dashboard创建或更新Perses仪表板定义
delete_dashboard删除仪表板定义

资源和提示

  • 资源:通过浏览表格 greptime:///data URI
  • 提示:用于常见任务的内置模板-- pipeline_creator, log_pipeline, metrics_analysis, promql_analysis, iot_monitoring, trace_analysis, table_operation

有关LLM集成和快速使用,请参阅 docs/llm-instructions.md.

配置

环境变量

GREPTIMEDB_HOST=localhost      # Database host
GREPTIMEDB_PORT=4002           # MySQL protocol port (default: 4002)
GREPTIMEDB_USER=root           # Database user
GREPTIMEDB_PASSWORD=           # Database password
GREPTIMEDB_DATABASE=public     # Database name
GREPTIMEDB_TIMEZONE=UTC        # Session timezone

# Optional
GREPTIMEDB_HTTP_PORT=4000      # HTTP API port for pipeline/dashboard management
GREPTIMEDB_HTTP_PROTOCOL=http  # HTTP protocol (http/https)
GREPTIMEDB_POOL_SIZE=5         # Connection pool size
GREPTIMEDB_MASK_ENABLED=true   # Enable sensitive data masking
GREPTIMEDB_MASK_PATTERNS=      # Additional patterns (comma-separated)
GREPTIMEDB_AUDIT_ENABLED=true  # Enable audit logging

# Transport (for HTTP server mode)
GREPTIMEDB_TRANSPORT=stdio     # stdio, sse, or streamable-http
GREPTIMEDB_LISTEN_HOST=0.0.0.0 # HTTP server bind host
GREPTIMEDB_LISTEN_PORT=8080    # HTTP server bind port
GREPTIMEDB_ALLOWED_HOSTS=      # DNS rebinding protection (comma-separated)
GREPTIMEDB_ALLOWED_ORIGINS=    # CORS allowed origins (comma-separated)

CLI参数

greptimedb-mcp-server \
  --host localhost \
  --port 4002 \
  --database public \
  --user root \
  --password "" \
  --timezone UTC \
  --pool-size 5 \
  --mask-enabled true \
  --transport stdio

HTTP服务器模式

用于容器化或Kubernetes部署。需要 mcp>=1.8.0:

# Streamable HTTP (recommended for production)
greptimedb-mcp-server --transport streamable-http --listen-port 8080

# SSE mode (legacy)
greptimedb-mcp-server --transport sse --listen-port 3000

DNS重新绑定保护

默认情况下,DNS重新绑定保护为 残疾的 为了与代理、网关和Kubernetes服务兼容。要启用它,请使用 --allowed-hosts:

# Enable DNS rebinding protection with allowed hosts
greptimedb-mcp-server --transport streamable-http \
  --allowed-hosts "localhost:*,127.0.0.1:*,my-service.namespace:*"

# With custom allowed origins for CORS
greptimedb-mcp-server --transport streamable-http \
  --allowed-hosts "my-service.namespace:*" \
  --allowed-origins "http://localhost:*,https://my-app.example.com"

# Or via environment variables
GREPTIMEDB_ALLOWED_HOSTS="localhost:*,my-service.namespace:*" \
GREPTIMEDB_ALLOWED_ORIGINS="http://localhost:*" \
  greptimedb-mcp-server --transport streamable-http

如果你遇到 421 Invalid Host Header 错误,禁用保护(默认)或将您的主机添加到允许列表中。

安全

只读数据库用户(推荐)

使用以下命令在GreptimeDB中创建只读用户 静态用户提供者:

mcp_readonly:readonly=your_secure_password

应用级安全门

所有查询都通过一个安全门:

  • 积木:删除、删除、截断、更新、插入、更改、创建、授予、撤销、执行、加载、复制
  • 积木:编码的旁路尝试(十六进制、UNHEX、CHAR)
  • 允许:选择、显示、描述、TQL、解释、联合

数据屏蔽

敏感列会自动屏蔽(******)基于列名模式:

  • 身份验证: password, secret, token, api_key, credential
  • 财务: credit_card, cvv, bank_account
  • 个人的: ssn, id_card, passport

配置为 --mask-patterns phone,email 添加自定义图案。

审计日志

记录所有工具调用:

2025-12-10 10:30:45 - greptimedb_mcp_server.audit - INFO - [AUDIT] execute_sql | query="SELECT * FROM cpu LIMIT 10" | success=True | duration_ms=45.2

禁用 --audit-enabled false.

发展

# Clone and setup
git clone https://github.com/GreptimeTeam/greptimedb-mcp-server.git
cd greptimedb-mcp-server
uv venv && source .venv/bin/activate
uv sync

# Run tests
pytest

# Format & lint
uv run black .
uv run flake8 src

# Debug with MCP Inspector
npx @modelcontextprotocol/inspector uv --directory . run -m greptimedb_mcp_server.server

许可证

MIT许可证-请参阅 许可证.md.

致谢

灵感来源:

目录标签

目录标签

数据安全数据分析PythonClaudedeveloper-tools数据库查询本地部署时间序列分析管道管理仪表盘管理

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

13

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP