The GreptimeDB MCP Server enables AI assistants to query, analyze, and manage time-series data, logs, metrics, and traces in GreptimeDB through a secure, read-only interface.
Core Query Capabilities: Execute SQL queries (MySQL dialect, SELECT/SHOW/DESCRIBE only), PromQL-compatible TQL queries, and time-window aggregation queries with RANGE/ALIGN syntax. Multiple output formats available (CSV, JSON, Markdown) with configurable result limits and time ranges.
Schema & Resource Management: List all tables as browsable resources with greptime://<table>/data URIs, inspect table schemas (column names, types, constraints), and read table data through resource endpoints.
Pipeline Management: Create, test (dry-run), list, and delete data processing pipelines using YAML configurations. AI-assisted generation of pipeline configurations from log samples.
Specialized Analysis Templates: Access predefined prompts for log analysis with full-text search, metrics monitoring, PromQL-style queries (TQL EVAL), IoT device monitoring with TAG/FIELD semantics, distributed trace analysis for OpenTelemetry spans, and table diagnostics including region health and query optimization.
Query Analysis & Health: Analyze SQL/TQL query execution plans with EXPLAIN functionality for performance optimization, check database connection status and server version.
Security & Privacy: Automatically blocks all DDL/DML operations (DROP, DELETE, INSERT, UPDATE), dynamic SQL execution, and file system access. Masks sensitive data in columns matching patterns like password, api_key, credit_card, and ssn with configurable patterns.
Integration & Configuration: Seamlessly integrates with Claude Desktop and other MCP-compatible AI assistants. Configurable via environment variables or command-line arguments for connection details, HTTP/HTTPS API settings, timezone, connection pool size, and data masking options.
greptimedb-mcp-server
A Model Context Protocol (MCP) server for GreptimeDB — an open-source, cloud-native, unified observability database.
Enables AI assistants to query and analyze GreptimeDB using SQL, TQL (PromQL-compatible), and RANGE queries, with built-in security features like read-only enforcement and data masking.
Quick Start
For Claude Desktop, add this to your config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
Related MCP server: MCP Toolkit
Features
Tools
Tool | Description |
| Execute SQL queries with format (csv/json/markdown) and limit options |
| Execute TQL (PromQL-compatible) queries for time-series analysis |
| Execute time-window aggregation queries with RANGE/ALIGN syntax |
| Get table schema including column names, types, and constraints |
| Analyze SQL or TQL query execution plans |
| Check database connection status and server version |
Pipeline Management
Tool | Description |
| List all pipelines or get details of a specific pipeline |
| Create a new pipeline with YAML configuration |
| Test a pipeline with sample data without writing to database |
| Delete a specific version of a pipeline |
Resources & Prompts
Resources: Browse tables via
greptime://<table>/dataURIsPrompts: Built-in templates for common tasks —
pipeline_creator,log_pipeline,metrics_analysis,promql_analysis,iot_monitoring,trace_analysis,table_operation
For LLM integration and prompt usage, see docs/llm-instructions.md.
Configuration
Environment Variables
CLI Arguments
HTTP Server Mode
For containerized or Kubernetes deployments. Requires mcp>=1.8.0:
DNS Rebinding Protection
By default, DNS rebinding protection is disabled for compatibility with proxies, gateways, and Kubernetes services. To enable it, use --allowed-hosts:
If you encounter 421 Invalid Host Header errors, either disable protection (default) or add your host to the allowed list.
Security
Read-Only Database User (Recommended)
Create a read-only user in GreptimeDB using static user provider:
Application-Level Security Gate
All queries go through a security gate that:
Blocks: DROP, DELETE, TRUNCATE, UPDATE, INSERT, ALTER, CREATE, GRANT, REVOKE, EXEC, LOAD, COPY
Blocks: Encoded bypass attempts (hex, UNHEX, CHAR)
Allows: SELECT, SHOW, DESCRIBE, TQL, EXPLAIN, UNION
Data Masking
Sensitive columns are automatically masked (******) based on column name patterns:
Authentication:
password,secret,token,api_key,credentialFinancial:
credit_card,cvv,bank_accountPersonal:
ssn,id_card,passport
Configure with --mask-patterns phone,email to add custom patterns.
Audit Logging
All tool invocations are logged:
Disable with --audit-enabled false.
Development
License
MIT License - see LICENSE.md.
Acknowledgement
Inspired by: