Overview
What it does
- Real-time SQL query execution on large datasets
- Millisecond response times for analytics
- Natural language to SQL conversion
- Column-oriented storage for fast aggregations
- Distributed query processing
- Time-series data optimization
- Read-only queries for data safety
- Database and table schema exploration
Use Cases
- Business Dashboards: Real-time metrics and KPIs
- Log Analysis: Monitor application and system logs
- User Analytics: Track behavior and engagement patterns
- E-commerce Insights: Sales, inventory, and customer analytics
- Financial Analysis: Transaction and market data processing
- Time-Series Data: IoT sensors, metrics, and monitoring
- Ad-hoc Exploration: Quick data discovery and analysis
- Funnel & Cohort Analysis: User journey and retention metrics
Quick Start
Set Up ClickHouse Instance
- Sign up at clickhouse.cloud/signup
- Create a new service
- Note your connection details from the dashboard:
- Host:
xyz.clickhouse.cloud(your unique hostname) - Port:
8443(HTTPS default) - Database:
default(or your custom database) - Username:
default(or custom user) - Password: Set during service creation
- Host:
- Up to 25GB storage
- Fully managed infrastructure
- Automatic backups and scaling
- SSL/TLS encryption by default
- No infrastructure management
- Host:
sql-clickhouse.clickhouse.com - Port:
8443 - Username:
demo - Password: (leave empty)
- Database:
default
- Install ClickHouse on your infrastructure
- Configure network access and SSL
- Set up authentication
- Note connection details
Add to NimbleBrain Studio
- Open NimbleBrain Studio
- Navigate to Settings → MCP Servers
- Click Add Server
- Search for “ClickHouse” in the server registry
- Click Configure
- Enter your connection details:
- CLICKHOUSE_HOST: Your ClickHouse hostname
- CLICKHOUSE_PORT:
8443(Cloud) or8123(self-hosted HTTP) - CLICKHOUSE_USER: Your username (usually
default) - CLICKHOUSE_PASSWORD: Your password
- CLICKHOUSE_DATABASE: Database name (optional, defaults to
default) - CLICKHOUSE_SECURE:
true(recommended for Cloud)
- Click Test Connection to verify
- Click Save & Enable
Test Your Connection
- Studio calls the
list_databasestool - ClickHouse returns all database names
- You see available databases
Available Tools
run_select_query - Execute SQL queries for analytics
run_select_query - Execute SQL queries for analytics
| Parameter | Type | Required | Description |
|---|---|---|---|
| query | string | Yes | SQL SELECT query to execute |
columns: Array of column namesrows: Array of result rows (each row is an array of values)
CLICKHOUSE_MCP_QUERY_TIMEOUT.list_databases - Discover available databases
list_databases - Discover available databases
| Parameter | Type | Required | Description |
|---|---|---|---|
| (none) | - | - | No parameters required |
- JSON array of database names
system contain ClickHouse metadata and monitoring information. Your business data is typically in default or custom databases.list_tables - Explore database schema and structure
list_tables - Explore database schema and structure
| Parameter | Type | Required | Description |
|---|---|---|---|
| database | string | Yes | Name of the database to query |
| like | string | No | Filter tables by pattern (e.g., 'user%' for tables starting with “user”) |
| not_like | string | No | Exclude tables by pattern (e.g., '%_tmp' to exclude temporary tables) |
- Array of table objects with comprehensive metadata:
database: Database namename: Table nameengine: Storage engine (e.g., MergeTree)columns: Array of column details (name, type, default, comment)total_rows: Number of rows in tabletotal_bytes: Storage size in bytesprimary_key: Primary key columnssorting_key: Sort order for optimizationcomment: Table description- Plus: engine details, compression stats, partition info
total_rows and total_bytes fields help you understand data volume. ClickHouse can handle billions of rows efficiently!run_chdb_select_query - Query data with embedded engine
run_chdb_select_query - Query data with embedded engine
| Parameter | Type | Required | Description |
|---|---|---|---|
| query | string | Yes | SQL query to execute with chDB |
- JSON array of result objects (each row as an object with column names as keys)
- Embedded ClickHouse engine (no separate server needed)
- Query any source: Local files (CSV, JSON, Parquet), URLs, databases
- In-memory or file-based storage
- No ETL required: Query data directly from source
- Perfect for: Data exploration, prototyping, lightweight analytics
CHDB_ENABLED=true in your Studio configuration. Requires CHDB_DATA_PATH for persistent storage or defaults to in-memory.Authentication
Connection Configuration
Configure these parameters in NimbleBrain Studio (Settings → MCP Servers → ClickHouse): Required Parameters:| Parameter | Description | Example |
|---|---|---|
| CLICKHOUSE_HOST | Your ClickHouse server hostname | abc123.clickhouse.cloud |
| CLICKHOUSE_USER | Database username | default |
| CLICKHOUSE_PASSWORD | Database password | your_secure_password |
| Parameter | Description | Default | Notes |
|---|---|---|---|
| CLICKHOUSE_PORT | Connection port | 8443 (secure) or 8123 (HTTP) | Auto-set based on CLICKHOUSE_SECURE |
| CLICKHOUSE_DATABASE | Default database | default | Connect to specific database |
| CLICKHOUSE_SECURE | Enable SSL/TLS | true | Always true for ClickHouse Cloud |
| CLICKHOUSE_VERIFY | Verify SSL certificates | true | Recommended for production |
| CLICKHOUSE_CONNECT_TIMEOUT | Connection timeout (seconds) | 30 | Increase for slow networks |
| CLICKHOUSE_SEND_RECEIVE_TIMEOUT | Query timeout (seconds) | 300 | Increase for long-running queries |
ClickHouse Cloud vs Self-Hosted
ClickHouse Cloud (Recommended):| Tier | Storage | Compute | Price | Best For |
|---|---|---|---|---|
| Free | 25GB | 8GB RAM | $0/mo | Testing, small projects |
| Development | 100GB | 16GB RAM | ~$50/mo | Dev/staging environments |
| Production | 1TB+ | 32GB+ RAM | ~$300+/mo | Production workloads |
| Enterprise | Custom | Custom | Custom | Large-scale deployments |
- ✅ Fully managed (no DevOps)
- ✅ Automatic backups
- ✅ SSL/TLS by default
- ✅ Auto-scaling
- ✅ High availability
- Free open-source software
- You manage infrastructure costs (compute, storage, networking)
- Full control over configuration
- Requires DevOps expertise for:
- Installation and upgrades
- Backup and recovery
- Security and SSL setup
- Performance tuning
- Monitoring and alerts
Security Best Practices
Use Read-Only Credentials for Studio
Use Read-Only Credentials for Studio
- Prevents accidental data deletion or modification
- Safe for business users to explore data
- ClickHouse MCP already enforces
readonly=1, but database-level permissions add extra security
readonly=1 setting, ensuring queries cannot modify data even if the user has write permissions.Always Enable SSL/TLS in Production
Always Enable SSL/TLS in Production
- SSL/TLS enabled by default
- Automatic certificate management
- Just set
CLICKHOUSE_SECURE=true
- Configure SSL certificates in ClickHouse server
- Set
CLICKHOUSE_SECURE=true - Set
CLICKHOUSE_VERIFY=trueto validate certificates
Restrict Network Access
Restrict Network Access
- Configure IP allowlists in the Cloud console
- Add your office IPs
- Add Studio’s IP ranges (contact NimbleBrain support)
- Configure firewall rules (iptables, security groups)
- Limit access to known IPs
- Use VPN for remote access
- Disable public internet access if possible
Use Strong Passwords & Rotate Regularly
Use Strong Passwords & Rotate Regularly
- Minimum 16 characters
- Mix of uppercase, lowercase, numbers, symbols
- Not reused from other services
- Not based on dictionary words
- Unique per environment (dev, staging, prod)
- Rotate every 90 days
- Rotate immediately if:
- Employee leaves with access
- Suspected credential compromise
- Security audit recommendation
- Store in a password manager (1Password, LastPass, etc.)
- Never commit passwords to git repos
- Use environment variables, not hardcoded values
Monitor Query Activity
Monitor Query Activity
- Unusual query patterns
- Long-running queries
- Failed authentication attempts
- Queries accessing sensitive tables
- Unusual access times (nights, weekends)
- Multiple failed authentication attempts
- Queries to sensitive tables
- Unusual data volume exports
- Performance degradation
Managing Credentials in Studio
Update your ClickHouse connection details anytime:- Go to Settings → MCP Servers
- Find “ClickHouse” in your server list
- Click Edit Configuration
- Update your connection parameters
- Click Test Connection to verify changes
- Click Save
Example Workflows
- Sales Analytics
- User Behavior Analysis
- Log Analysis & Troubleshooting
- Time-Series Metrics
- Funnel Analysis
- Cohort Retention Analysis
- A/B Test Analysis
- Real-Time Dashboard
- Studio converts your question to SQL
- Queries your
salesororderstable - Aggregates by region with date filtering
- Calculates metrics (total, count, average)
- Returns results in readable format
| Region | Order Count | Total Sales | Avg Order Value |
|---|---|---|---|
| West | 15,234 | $1,250,000 | $82.05 |
| East | 12,890 | $987,500 | $76.61 |
| South | 10,456 | $890,000 | $85.12 |
Troubleshooting
Connection Refused
Connection Refused
- Incorrect host or port
- Firewall blocking connection
- ClickHouse server not running (self-hosted)
- Network connectivity issues
-
Verify Connection Details:
- Go to Settings → MCP Servers → ClickHouse → Edit
- Check
CLICKHOUSE_HOSTmatches your instance - For Cloud: Should be
xyz.clickhouse.cloud - For Playground: Should be
sql-clickhouse.clickhouse.com
-
Check Port Configuration:
- Cloud (HTTPS): Port
8443,CLICKHOUSE_SECURE=true - Self-hosted (HTTP): Port
8123,CLICKHOUSE_SECURE=false - Self-hosted (HTTPS): Port
8443,CLICKHOUSE_SECURE=true
- Cloud (HTTPS): Port
-
Test from Command Line:
-
Check Firewall Rules:
- ClickHouse Cloud: Add your IP to allowlist in Cloud console
- Self-hosted: Check firewall rules allow inbound on ClickHouse port
- Corporate network: Verify outbound connections allowed
Authentication Failed
Authentication Failed
- Wrong username or password
- Password contains special characters not properly encoded
- User doesn’t exist in ClickHouse
- User doesn’t have necessary permissions
-
Verify Credentials:
- Double-check username and password in Studio config
- Check for typos, extra spaces, or incorrect capitalization
- ClickHouse passwords are case-sensitive
-
Reset Password:
- Cloud: Reset in ClickHouse Cloud dashboard
- Self-hosted: Update via SQL or configuration file
-
Check User Exists:
-
Grant Permissions:
-
Special Characters in Password:
- If password contains
@,#,%, etc., ensure proper encoding - Try resetting to a simpler password temporarily for testing
- If password contains
Query Timeout
Query Timeout
- Query scanning too much data
- Missing indexes or poor table design
- Unoptimized query (no WHERE clause on large table)
- Server overloaded
-
Add Date/Time Filters:
-
Use LIMIT:
-
Increase Timeout:
- In Studio: Add
CLICKHOUSE_MCP_QUERY_TIMEOUT=60(seconds) - Or in query: Use Studio to request “with longer timeout”
- In Studio: Add
-
Optimize Query:
-
Check Table Design:
- Verify ORDER BY key matches your query patterns
- Consider partitioning by date
- Create materialized views for complex queries
Table or Database Not Found
Table or Database Not Found
- Table or database name is misspelled
- Table doesn’t exist in the specified database
- User doesn’t have permission to see the table
- Wrong database specified
-
List Available Databases:
-
List Tables in Database:
-
Check Table Name:
- ClickHouse table names are case-sensitive
Users≠users≠USERS- Use exact capitalization
-
Check Database Context:
-
Verify Permissions:
Memory Limit Exceeded
Memory Limit Exceeded
- Query returning too many rows
- Large GROUP BY creating many groups
- JOINing very large tables
- Not enough memory allocated
-
Add LIMIT:
-
Filter More Aggressively:
-
Aggregate Instead of Returning Raw Data:
-
Use Sampling for Exploration:
-
For ClickHouse Cloud:
- Memory auto-scales, but very large queries may still hit limits
- Consider upgrading to higher tier for more memory
Syntax Error in Query
Syntax Error in Query
- ClickHouse SQL syntax differs from other databases
- Using MySQL/PostgreSQL-specific functions
- Incorrect function names
- Malformed query
-
Use Studio’s Natural Language:
- Let Studio generate SQL automatically
- Ask in plain English: “Show me top 10 users by activity”
- Studio handles ClickHouse-specific syntax
-
Common ClickHouse Differences:
-
Check ClickHouse Documentation:
- ClickHouse SQL Reference
- Functions may have different names than MySQL/PostgreSQL
-
Test Incrementally:
- Start with simple SELECT
- Add complexity step by step
- Identify what causes the error
Slow Query Performance
Slow Query Performance
-
Missing Date Filters:
-
ORDER BY Doesn’t Match Table Sort Key:
-
Not Using PREWHERE:
-
Large Result Sets:
- Always use LIMIT
- Return aggregated data instead of raw rows
- Use sampling for exploration
-
Check Query Performance:
SSL/TLS Certificate Errors
SSL/TLS Certificate Errors
- Self-signed certificates
- Expired certificates
- Certificate chain issues
- System trust store not configured
-
For ClickHouse Cloud:
- Certificates are valid and trusted
- Ensure
CLICKHOUSE_SECURE=true - Ensure
CLICKHOUSE_VERIFY=true - Should work automatically
-
For Self-Hosted with Valid Certs:
- Ensure certificates are from trusted CA
- System trust store should recognize them
- Use
CLICKHOUSE_VERIFY=true
-
For Self-Hosted with Self-Signed Certs (DEV ONLY):
- Not recommended for production
- Set
CLICKHOUSE_VERIFY=false - Disables certificate verification
-
Update System Trust Store:
- Ensure your OS has updated CA certificates
- On Ubuntu:
sudo apt-get update ca-certificates - On macOS: Usually automatic via OS updates
Links & Resources
GitHub Repository
ClickHouse Documentation
ClickHouse Cloud
ClickHouse SQL Playground
Related MCP Servers
Looking for other data and analytics tools?PostgreSQL
MongoDB
Finnhub
Learning Resources
What is ClickHouse?
What is ClickHouse?
-
Column-Oriented: Stores data by columns, not rows
- Traditional databases: Store full rows together
- ClickHouse: Stores each column separately
- Result: 100-1000x faster for analytics queries
- Massively Parallel: Distributes queries across cores and servers
- Real-Time: Query billions of rows in milliseconds
- Highly Compressed: 10-100x compression ratios
- Scalable: From single server to hundreds of nodes
- Analytics and business intelligence
- Real-time dashboards
- Log processing and monitoring
- Time-series data
- Event tracking and user analytics
- Transactional workloads (OLTP)
- Frequent updates to individual rows
- Small datasets (less than millions of rows)
- Document storage
Natural Language to SQL in Studio
Natural Language to SQL in Studio
- Understands your intent (revenue analysis)
- Identifies entities (revenue, product, category, time period)
- Maps to your database schema
- Generates optimized ClickHouse SQL
- Executes and formats results
ClickHouse Performance Tips
ClickHouse Performance Tips
ClickHouse Data Modeling Best Practices
ClickHouse Data Modeling Best Practices
OLAP vs OLTP: When to Use ClickHouse
OLAP vs OLTP: When to Use ClickHouse
- Online Analytical Processing
- Optimized for: Reading and aggregating large datasets
- Use for: Analytics, reports, dashboards, business intelligence
- Online Transaction Processing
- Optimized for: Frequent small updates and inserts
- Use for: Application databases, user data, transactions
| Feature | ClickHouse (OLAP) | PostgreSQL (OLTP) |
|---|---|---|
| Read Speed | Extremely fast (billions/sec) | Moderate |
| Write Speed | Batch inserts only | Individual inserts fast |
| Updates | Not supported | Frequent updates OK |
| Deletes | Expensive | Fast |
| Use Case | Analytics, reporting | Application backend |
| Data Volume | Billions of rows | Millions of rows |
| Query Type | Aggregations, scans | Lookups, joins |
- ✅ Analyzing logs (millions of log lines per day)
- ✅ User behavior analytics (clickstream data)
- ✅ Business intelligence dashboards
- ✅ Time-series metrics and monitoring
- ✅ Financial analysis (transactions, market data)
- ✅ Ad-hoc data exploration
- ❌ User profile storage (use PostgreSQL)
- ❌ Shopping cart data (use Redis/PostgreSQL)
- ❌ Content management (use MongoDB/PostgreSQL)
- ❌ Frequent updates to individual records
- ❌ Transaction processing (orders, payments)