Practical examples for using AI agents with PostgreSQL, TimescaleDB, and TigerData through Model Context Protocol (MCP)
This cookbook provides hands-on recipes demonstrating how to leverage AI coding assistants (Claude Code, Gemini CLI, etc.) with TigerData and TimescaleDB. Each recipe is designed as a copy-paste prompt that guides AI agents through complex database operations.
- π€ AI-Assisted Database Management - Use natural language to create, configure, and optimize databases
- π Time-Series Data Analysis - Analyze sensor data, identify patterns, and detect anomalies
- β‘ Performance Optimization - Benchmark queries, tune configurations, and implement best practices
- π Query Performance Debugging - Use pg_stat_statements and EXPLAIN ANALYZE to find bottlenecks
- ποΈ Data Lifecycle Management - Implement retention policies and compression strategies
- π Safe Experimentation - Use database forks to test changes without risk
- Tiger Cloud account - Sign up at https://tigerdata.com
- AI coding assistant - Claude Code (recommended), Gemini CLI, Cursor, or others
- Python 3.x - Optional, for data generation
- psql - PostgreSQL client (recommended)
Tiger CLI is an open-source command-line interface and MCP server for database management with AI assistance.
# Install
curl -fsSL https://cli.tigerdata.com | sh
# Verify
tiger versiontiger auth loginThis opens your browser to complete authentication with Tiger Cloud.
tiger mcp installThe installer automatically detects and configures compatible AI tools:
- Claude Code (recommended)
- Codeium
- Cursor
- Gemini CLI (generous free tier)
- Google Antigravity
- Kiro CLI
- VS Code with Copilot
- Windsurf
Note: Most tools require paid subscriptions. Gemini CLI offers a free tier sufficient for these recipes.
In your AI assistant, check for these available MCP tools:
mcp__tiger__search_docs- Search Tiger/Postgres documentationmcp__tiger__service_list- List Tiger servicesmcp__tiger__service_create- Create new servicesmcp__tiger__service_fork- Fork existing servicesmcp__tiger__db_execute_query- Execute database queriesmcp__tiger__view_skill- Access pg-aiguide skills
Recipes are numbered to indicate the recommended learning order. Start with Recipe 00 for service management basics.
Recipe 00: Tiger Service Management β Start here!
- List, create, start, stop, and resize database services
- View service logs for debugging
- Master complete database lifecycle operations
- Manage default service for your session
Recipe 01: Create Database and Schema
- Create a TimescaleDB service with optimized schema
- Learn about hypertables, continuous aggregates, and time partitioning
- Load sample data from CSV files
Recipe 02: Data Analysis
- Explore database structure and data distribution
- Calculate statistics and identify outliers
- Understand time-series patterns
Recipe 03: Performance Analysis
- Compare query performance with and without continuous aggregates
- Measure execution times and resource usage
- Understand materialized view benefits
Recipe 04: Safe Experimentation with Forks
- Learn database forking for risk-free testing
- Test destructive operations without production impact
- Use multiple fork strategies (NOW, LAST_SNAPSHOT, PITR)
Recipe 05: Database Optimization
- Analyze hypertable chunk sizes and partitioning
- Configure compression and indexes
- Get specific optimization recommendations
Recipe 06: Advanced Performance Analysis
- Use pg_stat_statements to identify slow queries
- Master EXPLAIN ANALYZE for query plan interpretation
- Optimize queries based on execution analysis
These workflows show how to combine recipes for common use cases:
Perfect for first-time users learning the basics:
- Recipe 00 (sections 1-6) - Learn service management basics
- List services, get service details, view logs
- Understand service lifecycle operations
- Recipe 01 - Create your first database with optimized schema
- Set up hypertables and continuous aggregates
- Load sample sensor data
- Recipe 02 - Analyze the data you just loaded
- Understand data distribution and patterns
- Identify outliers and anomalies
- Recipe 03 - Understand query performance
- See the benefits of continuous aggregates
- Learn about query execution times
For optimizing existing databases and queries:
- Recipe 02 - Understand your data first
- Analyze data volume, distribution, and patterns
- Identify which queries you run most often
- Recipe 06 - Identify slow queries
- Use pg_stat_statements to find bottlenecks
- Analyze query execution plans with EXPLAIN
- Recipe 05 - Optimize database configuration
- Adjust chunk intervals and compression
- Add appropriate indexes
- Recipe 04 - Test optimizations safely
- Fork database to test changes
- Verify improvements before production
For making changes to production databases without risk:
- Recipe 04 - Create a fork of your production database
- Use NOW, LAST_SNAPSHOT, or PITR strategy
- Verify fork is an exact copy
- Apply changes to the fork - Test your changes in isolation
- Schema modifications, new indexes, retention policies
- Configuration tuning, query optimizations
- Verify results on fork - Ensure changes work as expected
- Run performance tests
- Check data integrity
- Apply to production - Once verified on fork
- Document what worked
- Apply the same changes to production
- Delete fork to avoid ongoing costs
For rapid testing of database features:
- Recipe 00 (section 2) - Create a new test service
- Use natural language: "Create a new 'my-experiment' Tiger service"
- Minimal resources for cost efficiency
- Recipe 01 - Set up schema on test service
- Load sample data for realistic testing
- Experiment freely - Try whatever you want
- Test new features, queries, configurations
- No risk to production data
- Recipe 00 (section 10) - Delete when done
- Clean up test service to avoid costs
- "Delete 'my-experiment' using bash command 'tiger service delete'"
This cookbook prioritizes safety:
- β Read-only recipes - Analysis recipes (02, 03) only query data
- β New database creation - Recipe 01 creates new databases, doesn't modify existing
- β Fork-based testing - Recipe 04 uses isolated database copies for experiments
- β
Two-step modifications - Recipes 05 and 06 use analyze-then-apply workflow:
- Step 1: Analyze and save recommendations to file (safe, read-only)
- Step 2: Apply changes after human review (requires explicit approval)
Human-in-the-loop: No destructive operations occur without your explicit review and approval.
Each recipe follows this structure:
- Safety Note - Clearly indicates if recipe is read-only, creates new resources, or modifies existing
- Description - What you'll learn and accomplish
- Prerequisites - Required setup and dependencies
- Prompt - Copy-paste text for your AI assistant (split into steps for modifications)
- What to Expect - Detailed explanation of AI actions
- Verification - SQL queries to check results
- Troubleshooting - Common issues and solutions
Simply copy the prompt from a recipe and paste it into your AI assistant. The AI will use Tiger MCP tools to complete the task.
For recipes with modifications (05, 06):
- Run Step 1 prompt to analyze and generate recommendations
- Review the generated recommendations file
- Run Step 2 prompt to apply approved changes
cookbook/
βββ README.md # This file
βββ CLAUDE.md # Guide for Claude Code instances
βββ Recipe-Template.md # Template for creating new recipes
βββ spec.md # Repository specification
βββ recipes/ # Individual recipe files
β βββ 00-tiger-service-management.md
β βββ 01-create-database-schema.md
β βββ 02-data-analysis.md
β βββ 03-performance-analysis.md
β βββ 04-safe-experimentation-with-forks.md
β βββ 05-database-optimization.md
β βββ 06-advanced-performance-analysis.md
βββ test-data/ # Sample data files for recipes
βββ README.md # Info about test data
# Verify installation
tiger version
# Re-authenticate
tiger auth login
# Reinstall MCP integration
tiger mcp install
# Restart your AI assistant tool# Check authentication status
tiger auth status
# List your services
tiger service list
# Or check the web console
open https://console.tigerdata.com- Confirm Python 3.x:
python3 --version - Check directory write permissions
- Review error messages from the AI assistant
- Verify CSV data files are present
Have a useful recipe or improvement? Contributions are welcome!
- Fork this repository
- Create your recipe using Recipe-Template.md
- Submit a pull request
- TimescaleDB Documentation: https://www.tigerdata.com/docs
- Tiger CLI GitHub: https://github.com/timescale/tiger-cli
- pg-aiguide: https://github.com/timescale/pg-aiguide
- TigerData Console: https://console.tigerdata.com
- MCP Specification: https://modelcontextprotocol.io
- TigerData Workshops - Full workshop materials
- Tiger CLI - Command-line interface for TigerData
- pg-aiguide - PostgreSQL and TimescaleDB best practices MCP server
MIT License
Based on the Agentic Postgres Workshop created by Anton Umnikov/Tiger Data.