GreptimeDB MCP Server exposes GreptimeDB as a Model Context Protocol (MCP) server so AI assistants and tools can query metrics, logs, and traces using a consistent, secure interface. It translates MCP tool calls into SQL, TQL (PromQL-compatible), and time-range queries, returning structured results in CSV/JSON/Markdown formats. The server is intended for environments where you want programmatic access to observability data without giving an LLM or external agent full write privileges.
It is useful for debugging, analytics, automated report generation, and integration with assistant clients (e.g., Claude Desktop). The server supports read-only enforcement, data masking, audit logging, and multiple transport modes (stdio, SSE, streamable HTTP) to suit local, desktop, and containerized deployments.
Features
Read-only query execution with blocking of harmful DDL/DML operations
Support for SQL, TQL (PromQL-compatible), and RANGE/ALIGN time-window queries
Results returned in CSV, JSON, or Markdown table formats
Built-in data masking and audit logging options
Pipeline and dashboard management (create, list, dry-run, delete)
HTTP server mode with streamable HTTP or SSE transports for container/Kubernetes deployments
Prompts and resource URIs for LLM-driven workflows (e.g., pipeline_creator, metrics_analysis)
Available Tools
Key tools exposed to MCP clients:
Tool
Purpose
execute_sql
Run ad-hoc SQL queries; supports format and row limits
execute_tql
Run PromQL-compatible TQL queries for time-series analysis
query_range
Run RANGE/ALIGN windowed aggregation queries across a time range
describe_table
Return schema (columns, types, constraints) for a table
If you encounter “421 Invalid Host Header”, add the host to allowed hosts or disable protection (default).
Security
Recommended: create a read-only database user and use the server in read-only mode. The server enforces an application-level security gate that blocks destructive statements, including but not limited to:
DROP, DELETE, TRUNCATE, UPDATE, INSERT
ALTER, CREATE, GRANT, REVOKE
EXEC, LOAD, COPY
Optional safeguards:
Data masking (regex patterns) to hide sensitive fields
Audit logging to track queries and responses
Connection pool and session timezone settings
Use Cases
Ad-hoc metrics investigation: use execute_tql to run PromQL-style queries and return results as JSON for an LLM to analyze trends.
Log ingestion pipeline development: create and dry-run a YAML pipeline to validate parsing and transformation before writing to GreptimeDB.
Time-window analysis: run query_range with ALIGN to compute rolling aggregations (e.g., per-minute averages across a 24-hour window).
Dashboard automation: programmatically create/update Perses dashboard definitions after analysis or alerts are generated.
Desktop assistant integration: wire greptimedb-mcp-server into Claude Desktop to enable conversational querying over observability data without exposing write permissions.
For full examples, prompts, and LLM instructions, see the project repository: https://github.com/GreptimeTeam/greptimedb-mcp-server.