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. For Claude Desktop, add this to your config (~/Library/Application Support/Claude/claudedesktopco
Add this skill
npx mdskills install GreptimeTeam/greptimedb-mcp-serverWell-documented MCP server with comprehensive query tools and strong security features
1# greptimedb-mcp-server23[](https://pypi.org/project/greptimedb-mcp-server/)45[](LICENSE.md)67A Model Context Protocol (MCP) server for [GreptimeDB](https://github.com/GreptimeTeam/greptimedb) — an open-source, cloud-native, unified observability database.89Enables 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.1011## Quick Start1213```bash14# Install15pip install greptimedb-mcp-server1617# Run (connects to localhost:4002 by default)18greptimedb-mcp-server --host localhost --database public19```2021For Claude Desktop, add this to your config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):2223```json24{25 "mcpServers": {26 "greptimedb": {27 "command": "greptimedb-mcp-server",28 "args": ["--host", "localhost", "--database", "public"]29 }30 }31}32```3334## Features3536### Tools3738| Tool | Description |39|------|-------------|40| `execute_sql` | Execute SQL queries with format (csv/json/markdown) and limit options |41| `execute_tql` | Execute TQL (PromQL-compatible) queries for time-series analysis |42| `query_range` | Execute time-window aggregation queries with RANGE/ALIGN syntax |43| `describe_table` | Get table schema including column names, types, and constraints |44| `explain_query` | Analyze SQL or TQL query execution plans |45| `health_check` | Check database connection status and server version |4647### Pipeline Management4849| Tool | Description |50|------|-------------|51| `list_pipelines` | List all pipelines or get details of a specific pipeline |52| `create_pipeline` | Create a new pipeline with YAML configuration |53| `dryrun_pipeline` | Test a pipeline with sample data without writing to database |54| `delete_pipeline` | Delete a specific version of a pipeline |5556### Resources & Prompts5758- **Resources**: Browse tables via `greptime://<table>/data` URIs59- **Prompts**: Built-in templates for common tasks — `pipeline_creator`, `log_pipeline`, `metrics_analysis`, `promql_analysis`, `iot_monitoring`, `trace_analysis`, `table_operation`6061For LLM integration and prompt usage, see [docs/llm-instructions.md](docs/llm-instructions.md).6263## Configuration6465### Environment Variables6667```bash68GREPTIMEDB_HOST=localhost # Database host69GREPTIMEDB_PORT=4002 # MySQL protocol port (default: 4002)70GREPTIMEDB_USER=root # Database user71GREPTIMEDB_PASSWORD= # Database password72GREPTIMEDB_DATABASE=public # Database name73GREPTIMEDB_TIMEZONE=UTC # Session timezone7475# Optional76GREPTIMEDB_HTTP_PORT=4000 # HTTP API port for pipeline management77GREPTIMEDB_HTTP_PROTOCOL=http # HTTP protocol (http/https)78GREPTIMEDB_POOL_SIZE=5 # Connection pool size79GREPTIMEDB_MASK_ENABLED=true # Enable sensitive data masking80GREPTIMEDB_MASK_PATTERNS= # Additional patterns (comma-separated)81GREPTIMEDB_AUDIT_ENABLED=true # Enable audit logging8283# Transport (for HTTP server mode)84GREPTIMEDB_TRANSPORT=stdio # stdio, sse, or streamable-http85GREPTIMEDB_LISTEN_HOST=0.0.0.0 # HTTP server bind host86GREPTIMEDB_LISTEN_PORT=8080 # HTTP server bind port87GREPTIMEDB_ALLOWED_HOSTS= # DNS rebinding protection (comma-separated)88GREPTIMEDB_ALLOWED_ORIGINS= # CORS allowed origins (comma-separated)89```9091### CLI Arguments9293```bash94greptimedb-mcp-server \95 --host localhost \96 --port 4002 \97 --database public \98 --user root \99 --password "" \100 --timezone UTC \101 --pool-size 5 \102 --mask-enabled true \103 --transport stdio104```105106### HTTP Server Mode107108For containerized or Kubernetes deployments. Requires `mcp>=1.8.0`:109110```bash111# Streamable HTTP (recommended for production)112greptimedb-mcp-server --transport streamable-http --listen-port 8080113114# SSE mode (legacy)115greptimedb-mcp-server --transport sse --listen-port 3000116```117118#### DNS Rebinding Protection119120By default, DNS rebinding protection is **disabled** for compatibility with proxies, gateways, and Kubernetes services. To enable it, use `--allowed-hosts`:121122```bash123# Enable DNS rebinding protection with allowed hosts124greptimedb-mcp-server --transport streamable-http \125 --allowed-hosts "localhost:*,127.0.0.1:*,my-service.namespace:*"126127# With custom allowed origins for CORS128greptimedb-mcp-server --transport streamable-http \129 --allowed-hosts "my-service.namespace:*" \130 --allowed-origins "http://localhost:*,https://my-app.example.com"131132# Or via environment variables133GREPTIMEDB_ALLOWED_HOSTS="localhost:*,my-service.namespace:*" \134GREPTIMEDB_ALLOWED_ORIGINS="http://localhost:*" \135 greptimedb-mcp-server --transport streamable-http136```137138If you encounter `421 Invalid Host Header` errors, either disable protection (default) or add your host to the allowed list.139140## Security141142### Read-Only Database User (Recommended)143144Create a read-only user in GreptimeDB using [static user provider](https://docs.greptime.com/user-guide/deployments-administration/authentication/static/#permission-modes):145146```147mcp_readonly:readonly=your_secure_password148```149150### Application-Level Security Gate151152All queries go through a security gate that:153- **Blocks**: DROP, DELETE, TRUNCATE, UPDATE, INSERT, ALTER, CREATE, GRANT, REVOKE, EXEC, LOAD, COPY154- **Blocks**: Encoded bypass attempts (hex, UNHEX, CHAR)155- **Allows**: SELECT, SHOW, DESCRIBE, TQL, EXPLAIN, UNION156157### Data Masking158159Sensitive columns are automatically masked (`******`) based on column name patterns:160- Authentication: `password`, `secret`, `token`, `api_key`, `credential`161- Financial: `credit_card`, `cvv`, `bank_account`162- Personal: `ssn`, `id_card`, `passport`163164Configure with `--mask-patterns phone,email` to add custom patterns.165166### Audit Logging167168All tool invocations are logged:169170```1712025-12-10 10:30:45 - greptimedb_mcp_server.audit - INFO - [AUDIT] execute_sql | query="SELECT * FROM cpu LIMIT 10" | success=True | duration_ms=45.2172```173174Disable with `--audit-enabled false`.175176## Development177178```bash179# Clone and setup180git clone https://github.com/GreptimeTeam/greptimedb-mcp-server.git181cd greptimedb-mcp-server182uv venv && source .venv/bin/activate183uv sync184185# Run tests186pytest187188# Format & lint189uv run black .190uv run flake8 src191192# Debug with MCP Inspector193npx @modelcontextprotocol/inspector uv --directory . run -m greptimedb_mcp_server.server194```195196## License197198MIT License - see [LICENSE.md](LICENSE.md).199200## Acknowledgement201202Inspired by:203- [ktanaka101/mcp-server-duckdb](https://github.com/ktanaka101/mcp-server-duckdb)204- [designcomputer/mysql_mcp_server](https://github.com/designcomputer/mysql_mcp_server)205- [mikeskarl/mcp-prompt-templates](https://github.com/mikeskarl/mcp-prompt-templates)206
Full transparency — inspect the skill content before installing.