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.
This server enables AI assistants to query and analyze GreptimeDB through SQL, TQL (PromQL-compatible), and RANGE queries. It includes security features like read-only enforcement and sensitive data masking, along with prompt templates for common analysis tasks.
Features
Resources
list_resources - List all tables in the database as browsable resources
read_resource - Read table data via
greptime://<table>/dataURIs
Related MCP server: MCP Toolkit
Tools
Tool | Description |
| Execute SQL queries with format (csv/json/markdown) and limit options |
| Get table schema including column names, types, and constraints |
| Check database connection status and server version |
| Execute TQL (PromQL-compatible) queries for time-series analysis |
| Execute time-window aggregation queries with RANGE/ALIGN syntax |
| Analyze SQL or TQL query execution plans |
| 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 |
Prompts
MCP prompt system APIs:
list_prompts - List available prompt templates
get_prompt - Get a prompt template by name with argument substitution
Available prompt templates:
Prompt | Description |
| Generate GreptimeDB pipeline YAML configuration from log samples |
| Log analysis with full-text search and aggregation |
| Comprehensive metrics analysis for monitoring data |
| PromQL-style queries using GreptimeDB TQL EVAL syntax |
| IoT device monitoring with TAG/FIELD semantics and device aggregation |
| Distributed trace analysis for OpenTelemetry spans |
| Table diagnostics: schema, region health, storage analysis, and query optimization |
Using Prompts in Claude Desktop
In Claude Desktop, MCP prompts need to be added manually to your conversation:
Click the + button in the conversation input area
Select MCP Server
Choose Prompt/References
Select the prompt you want to use (e.g.,
pipeline_creator)Fill in the required arguments
Note: Prompts are not automatically available via / slash commands in Claude Desktop. You must add them through the UI as described above.
LLM Instructions
Add this to your system prompt or custom instructions to help AI assistants use this MCP server effectively:
Example: Creating a Pipeline
Ask Claude to help create a pipeline by providing your log sample:
Claude will:
Analyze your log format
Generate a pipeline YAML configuration
Create the pipeline using
create_pipelinetoolTest it with
dryrun_pipelinetool
Security
All queries pass through a security gate that:
Blocks DDL/DML operations: DROP, DELETE, TRUNCATE, UPDATE, INSERT, ALTER, CREATE, GRANT, REVOKE
Blocks dynamic SQL execution: EXEC, EXECUTE, CALL
Blocks data modification: REPLACE INTO
Blocks file system access: LOAD, COPY, OUTFILE, LOAD_FILE, INTO DUMPFILE
Blocks encoded content bypass attempts: hex encoding (0x...), UNHEX(), CHAR()
Prevents multiple statement execution with dangerous operations
Allows read-only operations: SELECT, SHOW, DESCRIBE, TQL, EXPLAIN, UNION, INFORMATION_SCHEMA
Data Masking
Sensitive data in query results is automatically masked to protect privacy:
Default masked column patterns:
Authentication:
password,passwd,pwd,secret,token,api_key,access_key,private_key,credential,authFinancial:
credit_card,card_number,cvv,cvc,pin,bank_account,account_number,iban,swiftPersonal:
ssn,social_security,id_card,passport
Configuration:
Masked values appear as ****** in all output formats (CSV, JSON, Markdown).
Installation
After installation, run the server:
Configuration
Set the following environment variables:
Or via command-line args:
--hostthe database host,localhostby default,--portthe database port, must be MySQL protocol port,4002by default,--http-portthe HTTP API port for pipeline management,4000by default,--http-protocolthe HTTP protocol for API calls (http or https),httpby default,--userthe database username, empty by default,--passwordthe database password, empty by default,--databasethe database name,publicby default,--timezonethe session time zone, empty by default (using server default time zone),--pool-sizethe connection pool size,5by default,--mask-enabledenable data masking for sensitive columns,trueby default,--mask-patternsadditional sensitive column patterns (comma-separated), empty by default.
Usage
Tool Examples
execute_sql
Execute SQL queries with optional format and limit:
Formats: csv (default), json, markdown
execute_tql
Execute PromQL-compatible time-series queries:
query_range
Execute time-window aggregation queries:
describe_table
Get table schema information:
explain_query
Analyze query execution plan:
health_check
Check database connection (no parameters required).
Pipeline Management
list_pipelines
List all pipelines or filter by name:
create_pipeline
Create a new pipeline with YAML configuration:
dryrun_pipeline
Test a pipeline with sample data (no actual write):
delete_pipeline
Delete a specific version of a pipeline:
Claude Desktop Integration
Configure the MCP server in Claude Desktop's configuration file:
MacOS
Location: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows
Location: %APPDATA%/Claude/claude_desktop_config.json
Option 1: Using pip installed command (recommended)
Option 2: Using uv with source directory
License
MIT License - see LICENSE.md file for details.
Contribute
Prerequisites
Python with
uvpackage managerGreptimeDB installation
MCP server dependencies
Development
Use MCP Inspector for debugging:
Acknowledgement
This library's implementation was inspired by the following two repositories and incorporates their code, for which we express our gratitude:
Thanks!