MCP Prompts provide AI-assisted capabilities for database operations. These prompts help users generate SQL queries and understand database elements using natural language.
Transform natural language descriptions into SQL queries. The AI analyzes your database schema and generates appropriate SQL statements tailored to your database structure.
Prompt: “Get the 10 most recent orders”Generated SQL:
Copy
SELECT * FROM orders ORDER BY created_at DESC LIMIT 10;
Aggregations and Analytics
Prompt: “Calculate total revenue by product category”Generated SQL:
Copy
SELECT c.name AS category, SUM(oi.quantity * oi.price) AS total_revenueFROM categories cJOIN products p ON c.id = p.category_idJOIN order_items oi ON p.id = oi.product_idGROUP BY c.id, c.nameORDER BY total_revenue DESC;
Prompt: “Show monthly sales trends for 2024”Generated SQL:
Copy
SELECT DATE_TRUNC('month', created_at) AS month, COUNT(*) AS order_count, SUM(total_amount) AS total_salesFROM ordersWHERE EXTRACT(YEAR FROM created_at) = 2024GROUP BY monthORDER BY month;
Complex Joins and Subqueries
Prompt: “Find employees with salaries above their department average”Generated SQL:
Copy
SELECT e.id, e.name, e.salary, d.name AS departmentFROM employees eJOIN departments d ON e.department_id = d.idWHERE e.salary > ( SELECT AVG(salary) FROM employees WHERE department_id = e.department_id)ORDER BY e.salary DESC;
Prompt: “List customers who haven’t ordered in the last 90 days”Generated SQL:
Copy
SELECT c.id, c.name, c.email, MAX(o.created_at) AS last_order_dateFROM customers cLEFT JOIN orders o ON c.id = o.customer_idGROUP BY c.id, c.name, c.emailHAVING MAX(o.created_at) < CURRENT_DATE - INTERVAL '90 days'OR MAX(o.created_at) IS NULLORDER BY last_order_date DESC NULLS LAST;
Time-Based Queries
Prompt: “Show all users who signed up in the last 30 days”Generated SQL:
Copy
SELECT * FROM usersWHERE created_at >= CURRENT_DATE - INTERVAL '30 days'ORDER BY created_at DESC;
Prompt: “Get hourly user registrations for today”Generated SQL:
Copy
SELECT DATE_TRUNC('hour', created_at) AS hour, COUNT(*) AS registrationsFROM usersWHERE DATE(created_at) = CURRENT_DATEGROUP BY hourORDER BY hour;
Get AI-generated explanations of database tables, columns, relationships, and data patterns. This is useful for understanding unfamiliar databases, onboarding new team members, or documenting existing schemas.
Prompt: “Explain the users table structure”Response:
Copy
The 'users' table stores user account information with the following structure:Primary Fields:- id: Unique identifier (auto-incrementing integer)- email: User's email address (unique, used for authentication)- name: User's display nameStatus & Metadata:- status: Account status ('active', 'inactive', 'suspended')- created_at: Account creation timestamp- updated_at: Last modification timestampRelationships:- Referenced by 'orders' table via user_id foreign key- Referenced by 'user_preferences' table via user_id foreign keyIndexes:- Primary key on 'id'- Unique index on 'email'- Index on 'status' for filtering active users
Column Explanations
Prompt: “What is the purpose of the created_at column?”Response:
Copy
The 'created_at' column is a timestamp field that tracks when each recordwas first inserted into the table.Key characteristics:- Type: TIMESTAMP- Default: CURRENT_TIMESTAMP (automatically set on insert)- Nullable: NO (always has a value)- Timezone: Stored in UTCCommon uses:- Audit trail for record creation- Filtering recent records (e.g., "created in last 30 days")- Sorting records chronologically- Analytics and reporting on creation trends
Relationship Explanations
Prompt: “Explain the relationships between orders, customers, and products”Response:
Copy
The database implements a classic e-commerce order model:customers → orders (One-to-Many):- Each customer can have multiple orders- orders.customer_id references customers.id- Enforced by foreign key constraint with CASCADE deleteorders → order_items (One-to-Many):- Each order contains multiple line items- order_items.order_id references orders.id- order_items is a junction table linking orders to productsproducts → order_items (One-to-Many):- Each product can appear in multiple order line items- order_items.product_id references products.id- Stores quantity and price at time of purchaseData Flow:1. Customer places order → creates orders record2. Items added to order → creates order_items records3. Each order_item links to a product and stores snapshot of price/quantity
Schema Overview
Prompt: “Give me an overview of the database schema”Response:
Copy
This database implements a multi-tenant SaaS application with the following modules:User Management:- users: User accounts and authentication- user_roles: Role assignments (admin, user, viewer)- user_sessions: Active login sessionsOrganization:- organizations: Tenant/company records- organization_members: User-to-organization relationships- organization_settings: Per-tenant configurationCore Business:- projects: Main workspace entities- tasks: Work items within projects- comments: Discussion threads on tasks- attachments: File uploads linked to tasksSystem:- audit_logs: Track all user actions- notifications: User notification queue- webhooks: External integration endpointsDesign Patterns:- Soft deletes: deleted_at column for reversible deletions- Timestamps: created_at/updated_at on all tables- UUIDs: Primary keys use UUID for distributed systems