diff --git a/azure-devops-mcp.yaml b/azure-devops-mcp.yaml new file mode 100644 index 00000000000..96de5316925 --- /dev/null +++ b/azure-devops-mcp.yaml @@ -0,0 +1,15 @@ +name: Akuvo MCP Servers +version: 0.0.1 +schema: v1 + +mcpServers: + - name: Azure DevOps + command: npx + args: + - "-y" + - "@tiberriver256/mcp-server-azure-devops" + env: + AZURE_DEVOPS_AUTH_METHOD: pat + AZURE_DEVOPS_ORG_URL: https://dev.azure.com/YOUR_ACTUAL_ORG + AZURE_DEVOPS_PAT: your_actual_personal_access_token + AZURE_DEVOPS_DEFAULT_PROJECT: YOUR_ACTUAL_PROJECT_NAME \ No newline at end of file diff --git a/docs/docs.json b/docs/docs.json index 88cea7782f4..0cdaa0f2664 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -265,6 +265,7 @@ "guides/sentry-mcp-error-monitoring", "guides/snyk-mcp-continue-cookbook", "guides/supabase-mcp-database-workflow", + "guides/prisma-mcp-database-development", "guides/dlt-mcp-continue-cookbook", "guides/netlify-mcp-continuous-deployment", "guides/chrome-devtools-mcp-performance" diff --git a/docs/guides/overview.mdx b/docs/guides/overview.mdx index 70afbfef90a..356814909c5 100644 --- a/docs/guides/overview.mdx +++ b/docs/guides/overview.mdx @@ -31,6 +31,7 @@ Step-by-step guides for integrating Model Context Protocol (MCP) servers with Co - [Sentry Error Monitoring Cookbook](/guides/sentry-mcp-error-monitoring) - Automated error analysis with Sentry MCP to identify patterns and create actionable GitHub issues - [Snyk + Continue Hub Agent Cookbook (MCP)](/guides/snyk-mcp-continue-cookbook) - Integrate Snyk MCP via Continue Hub to scan code, deps, IaC, and containers - [Supabase Database Workflow Cookbook](/guides/supabase-mcp-database-workflow) - Audit Row Level Security in your Supabase database, identify vulnerabilities, and automatically generate fixes using Supabase MCP +- [Prisma Database Development Cookbook](/guides/prisma-mcp-database-development) - Build AI-powered database development workflows with Prisma MCP for schema design, migrations, and database management - [dlt Data Pipelines Cookbook](/guides/dlt-mcp-continue-cookbook) - Build AI-powered data pipelines with dlt MCP for pipeline inspection, schema management, and debugging ## What Advanced Tutorials Are Available diff --git a/docs/guides/prisma-mcp-database-development.mdx b/docs/guides/prisma-mcp-database-development.mdx new file mode 100644 index 00000000000..1826ff6d010 --- /dev/null +++ b/docs/guides/prisma-mcp-database-development.mdx @@ -0,0 +1,763 @@ +--- +title: "Database Development Workflow with Prisma MCP" +description: "Build an AI-powered database development workflow using Continue CLI with Prisma MCP to design schemas, create migrations, and manage your database with natural language." +sidebarTitle: "Prisma Database Development with MCP" +--- + + + A complete database development workflow that uses Continue CLI with Prisma MCP to design schemas, generate migrations, seed data, and manage your PostgreSQL database - all through natural language prompts. + + +## What You'll Learn + +This cookbook teaches you to: + +- Use [Prisma Remote MCP](https://hub.continue.dev/prisma/prisma-remote-mcp) to build database workflows +- Design database schemas with AI assistance +- Generate and apply migrations automatically +- Create realistic seed data for development +- Launch Prisma Studio for visual database management +- Set up automated database health checks + +## Prerequisites + +Before starting, ensure you have: + +- Node.js 18+ installed locally +- [Continue CLI](https://docs.continue.dev/guides/cli) with **active credits** (required for API usage) +- Basic understanding of SQL and database concepts +- A project directory where you want to set up your database + + + + ```bash + npm i -g @continuedev/cli + ``` + + + + 1. Visit [Continue Organizations](https://hub.continue.dev/settings/organizations) + 2. Sign up or log in to your Continue account + 3. Navigate to your organization settings + 4. Click **"API Keys"** and then **"+ New API Key"** + 5. Copy the API key immediately (you won't see it again!) + 6. Login to the CLI: `cn login` + + + + For the Prisma Remote MCP to work, you need to authenticate with Prisma: + + 1. Visit [Continue Hub Secrets](https://hub.continue.dev/settings/secrets) + 2. Click **"+ Add Secret"** + 3. Add your Prisma authentication token: + - **Key**: `prisma/prisma-remote-mcp/PRISMA_AUTH_TOKEN` + - **Value**: Your Prisma auth token (get from [Prisma Console](https://console.prisma.io)) + + + The Prisma Remote MCP runs on Prisma's hosted infrastructure and requires authentication to access your databases and projects. + + + + + + Continue CLI with Prisma Remote MCP can generate complete database schemas, write migrations, and even create realistic seed data - you just describe what you need! + + +## Step 1: Set Up Your Database + + + + + Prisma MCP works with any PostgreSQL database, including Prisma Postgres: + + 1. **Create a Prisma Account** (optional, for hosted databases) + - Visit [Prisma Console](https://console.prisma.io) + - Sign up or log in + + 2. **Authenticate via Continue CLI** + + **Prompt:** + ``` + Log me into the Prisma Console + ``` + + The AI will use the `Prisma-Login` tool to authenticate. + + 3. **Create a Database** + + **Prompt:** + ``` + Create a new Prisma Postgres database in the US region for my e-commerce project + ``` + + + You can also use **any PostgreSQL database** by configuring your connection string in `.env`: + ``` + DATABASE_URL="postgresql://user:password@localhost:5432/mydb" + ``` + + + + + + If you prefer to use a local PostgreSQL database: + + 1. **Install PostgreSQL** locally + - macOS: `brew install postgresql` + - Linux: `sudo apt-get install postgresql` + - Windows: Download from [postgresql.org](https://www.postgresql.org/download/) + + 2. **Start PostgreSQL service** + ```bash + # macOS + brew services start postgresql + + # Linux + sudo service postgresql start + ``` + + 3. **Create a database** + ```bash + createdb myapp_dev + ``` + + 4. **Configure connection in `.env`** + ```bash + DATABASE_URL="postgresql://localhost:5432/myapp_dev" + ``` + + + For development, you can also use Docker: + ```bash + docker run --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres + ``` + + + + + +## Prisma Database Workflow Options + + + Skip the manual setup and use our pre-built Prisma Continuous AI agent that includes + optimized prompts, rules, and the Prisma MCP for consistent database development. + + + + **How Prisma Remote MCP Works**: + - Connects to Prisma's hosted MCP server via `mcp-remote` + - Runs on Prisma's infrastructure (no local installation required) + - Provides tools for migrations, schema management, and database operations + - Integrates with Prisma Studio for visual database exploration + - Includes AI safety guardrails to prevent accidental data loss + + **Available Prisma Remote MCP Tools**: + - `migrate-status` - Check migration status + - `migrate-dev` - Create and execute migrations + - `migrate-reset` - Reset the database + - `Prisma-Postgres-account-status` - Check authentication + - `Create-Prisma-Postgres-Database` - Provision new databases + - `Prisma-Login` - Authenticate with Prisma + - `Prisma-Studio` - Launch the data explorer + + **Installation**: Add [Prisma Remote MCP from Continue Hub](https://hub.continue.dev/prisma/prisma-remote-mcp) + + + + + **Perfect for:** Rapid database development with AI-powered schema design and migration generation + + + + Visit the [Prisma Continuous AI Agent](https://hub.continue.dev/continuedev/prisma-continuous-ai) on Continue Hub and click **"Install Agent"** or run: + + ```bash + cn --agent continuedev/prisma-continuous-ai + ``` + + This agent includes: + - **Optimized prompts** for schema design and migration workflows + - **Built-in rules** for database best practices + - **[Prisma Remote MCP](https://hub.continue.dev/prisma/prisma-remote-mcp)** for reliable database operations + - **Automatic schema validation** and safety checks + + + + Navigate to your project directory and enter this prompt in the Continue CLI TUI: + + ``` + Design a database schema for an e-commerce platform with products, users, orders, and reviews + ``` + + That's it! The agent handles everything automatically. + + + + + **Why Use the Agent?** Get consistent results with pre-tested prompts and built-in database design best practices. + + + + + + + + Add the [Prisma Remote MCP](https://hub.continue.dev/prisma/prisma-remote-mcp) from Continue Hub to your configuration. + + Visit [Continue Hub - Prisma Remote MCP](https://hub.continue.dev/prisma/prisma-remote-mcp) and click **"Install"**. + + The MCP will connect automatically when Continue CLI needs it. + + + Make sure you've added your `PRISMA_AUTH_TOKEN` to [Continue Hub Secrets](https://hub.continue.dev/settings/secrets) as described in the Prerequisites step. + + + + + Test your connection with this prompt: + + ``` + Initialize Prisma in my project with PostgreSQL and create a basic schema + ``` + + + + Use this prompt template with Continue CLI to design your schema: + + ``` + I need to design a database schema for [your project description]. + + Requirements: + - Create tables for [list your entities] + - Add appropriate relationships between tables + - Include timestamps and soft deletes where needed + - Use UUIDs for primary keys + - Add indexes for commonly queried fields + + Generate: + 1. Complete Prisma schema file + 2. Initial migration + 3. Basic seed data for development + 4. Show me how to apply the migration + ``` + + + + + + + + To use the pre-built agent, you need either: + - **Continue CLI Pro Plan** with the models add-on, OR + - **Your own API keys** added to Continue Hub secrets + + The agent will automatically detect and use your configuration. For Prisma Remote MCP: + - **Prisma authentication token** added to Continue Hub secrets + - **PostgreSQL database** (local or hosted via Prisma Postgres) + - Prisma Remote MCP connects to Prisma's hosted infrastructure (no local installation required) + + +--- + + + **AI Safety Guardrails**: Prisma detects when destructive commands like `prisma migrate reset --force` are invoked through AI agents and requires explicit user consent before proceeding. + + +## Step 2: Design Your Database Schema with AI + +Use Continue CLI to design your database schema through natural language prompts. + + + + **Prompt:** + ``` + Design a complete e-commerce database schema with: + + Tables: + - Users (authentication, profiles, addresses) + - Products (variants, inventory, categories) + - Orders (line items, status tracking, shipping) + - Reviews (ratings, comments, helpful votes) + - Carts (temporary shopping carts) + + Requirements: + - Use UUIDs for all IDs + - Add proper relationships (foreign keys) + - Include created_at and updated_at timestamps + - Add soft deletes for users and products + - Create indexes for: + * Product searches (name, category) + * Order lookups (user_id, status, created_at) + * Review queries (product_id, user_id) + + Generate the Prisma schema and initial migration. + ``` + + + + **Prompt:** + ``` + Design a SaaS multi-tenant database schema with: + + Tables: + - Organizations (tenants) + - Users (with organization membership) + - Projects (belonging to organizations) + - Tasks (belonging to projects) + - Comments (on tasks) + - Subscriptions (billing info) + + Requirements: + - Ensure data isolation between organizations + - Add role-based access control (admin, member, viewer) + - Track who created and updated records + - Add indexes for tenant-scoped queries + - Include audit logging fields + + Generate a Prisma schema that enforces multi-tenancy. + ``` + + + + **Prompt:** + ``` + Design a blog platform database with: + + Tables: + - Users (authors and readers) + - Posts (with drafts and published states) + - Comments (nested/threaded) + - Tags (many-to-many with posts) + - Categories (hierarchical) + - Likes (on posts and comments) + + Features: + - SEO-friendly slugs for posts + - View count tracking + - Featured/pinned posts + - Comment moderation status + + Include proper indexes for: + - Post listing by date, popularity, category + - Tag-based searches + - User activity tracking + ``` + + + + + **Prisma Remote MCP Capabilities for Schema Design**: + - Validates schema syntax automatically + - Suggests optimal data types and relationships + - Recommends indexes based on query patterns + - Warns about potential performance issues + - Leverages Prisma's hosted AI models for enhanced schema recommendations + + +## Step 3: Generate and Apply Migrations + +Create database migrations from your schema design and apply them safely. + +**Example: Complete Migration Workflow** + +``` +I've designed my Prisma schema. Now I need to: + +1. Check the current migration status +2. Create a new migration named "initial_schema" +3. Review the generated SQL before applying +4. Apply the migration to the database +5. Verify all tables were created correctly + +For the migration: +- Include all schema changes +- Add helpful comments in the SQL +- Show me the migration file contents +- Confirm the migration was applied successfully + +Database: PostgreSQL +Environment: Development +``` + +**Expected Output:** +The AI will: +- Run `prisma migrate status` to check current state +- Generate migration with `prisma migrate dev --name initial_schema` +- Show you the SQL file contents for review +- Apply the migration automatically +- Verify tables exist using database inspection + + + **Best Practice**: Always review AI-generated migrations before applying to production. Test in development first! + + +## Step 4: Seed Your Database with Realistic Data + +Generate realistic seed data for development and testing. + + + + **Prompt:** + ``` + Create a comprehensive seed script for my e-commerce database: + + Generate: + - 50 users with realistic names and emails + - 200 products across 10 categories + * Include product variants (size, color) + * Set realistic prices and inventory + - 100 orders with random items + * Various order statuses (pending, shipped, delivered) + * Created at different dates over the past 6 months + - 300 product reviews + * Ratings from 1-5 stars + * Realistic review text + * Mix of helpful/not helpful votes + + Requirements: + - Use realistic fake data (not just "User 1", "Product 1") + - Maintain referential integrity + - Distribute data realistically (more delivered than pending orders) + - Add some edge cases (cancelled orders, out-of-stock items) + + Create the seed.ts file and show me how to run it. + ``` + + + + **Prompt:** + ``` + Create seed data for my SaaS application: + + Organizations: + - 10 organizations (different sizes: small, medium, enterprise) + - Each with appropriate subscription tier + + Users: + - 50 total users distributed across organizations + - Mix of roles (admin, member, viewer) + - Realistic activity patterns + + Projects and Tasks: + - 30 projects across all organizations + - 200 tasks with various statuses + - Assign tasks to users in the same organization + - Add comments from team members + + Demonstrate multi-tenancy by ensuring data isolation. + Create the seed script with TypeScript. + ``` + + + + + **Prisma Seed Best Practices**: + - Use `faker` or similar libraries for realistic data + - Run seeds in transactions for consistency + - Make seeds idempotent (safe to run multiple times) + - Include edge cases and test scenarios + + +## Step 5: Launch Prisma Studio for Visual Management + +Use Prisma Studio to visually explore and manage your database. + +**Prompt:** +``` +Launch Prisma Studio so I can visually inspect my database tables and data +``` + +The AI will: +- Run `prisma studio` command +- Open Studio in your browser (usually http://localhost:5555) +- Show you how to navigate the interface + + + **Prisma Studio Features**: + - Browse all tables and relationships + - Edit records directly + - Filter and search data + - View relationship connections visually + + +## Step 6: Automate Database Health Checks + +Set up automated database monitoring with Continue CLI and GitHub Actions: + +```yaml +name: Database Health Monitor + +on: + push: + branches: + - main + paths: + - 'prisma/**' + pull_request: + paths: + - 'prisma/**' + schedule: + # Run daily at 3 AM UTC + - cron: "0 3 * * *" + workflow_dispatch: # Allow manual triggers + +jobs: + check-database-health: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install Dependencies + run: | + npm install + npm install -g @continuedev/cli + echo "✅ Dependencies installed" + + - name: Setup Database + env: + DATABASE_URL: ${{ secrets.DATABASE_URL }} + run: | + npx prisma migrate deploy + echo "✅ Migrations applied" + + - name: Analyze Database Schema + env: + CONTINUE_API_KEY: ${{ secrets.CONTINUE_API_KEY }} + DATABASE_URL: ${{ secrets.DATABASE_URL }} + run: | + echo "🔍 Analyzing database health..." + + cn -p "Using Prisma MCP, perform a comprehensive database health check: + + 1. Migration Status: + - Check if all migrations are applied + - Identify pending migrations + - Detect migration conflicts + + 2. Schema Analysis: + - Verify all foreign key relationships are valid + - Check for missing indexes on foreign keys + - Identify tables without primary keys + - Find unused indexes (if possible) + + 3. Data Integrity: + - Check for orphaned records (broken foreign keys) + - Verify required fields don't have nulls + - Identify duplicate records in unique columns + + 4. Performance Review: + - Suggest missing indexes based on schema + - Identify large tables that might need partitioning + - Check for inefficient data types + + 5. Best Practices: + - Verify created_at/updated_at timestamps exist + - Check for soft delete implementations + - Ensure proper enum usage + + Generate a detailed health report with: + - Critical issues that need immediate attention + - Warnings for potential problems + - Optimization suggestions + - SQL scripts to fix identified issues + + If critical issues are found, fail the workflow." + + - name: Save Health Report + if: always() + run: | + echo "## 📊 Database Health Report" >> $GITHUB_STEP_SUMMARY + echo "Generated at $(date)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Check the 'Analyze Database Schema' step for the full report" >> $GITHUB_STEP_SUMMARY + + - name: Upload Health Report + if: always() + uses: actions/upload-artifact@v4 + with: + name: database-health-report + path: | + *.md + *.sql +``` + + + **Required GitHub Secrets**: + - `CONTINUE_API_KEY`: Your Continue API key from [hub.continue.dev/settings/api-keys](https://hub.continue.dev/settings/api-keys) + - `DATABASE_URL`: PostgreSQL connection string for your test database + + Add these at: **Repository Settings → Secrets and variables → Actions** + + +## What You've Built + +After completing this guide, you have a complete **AI-powered database development workflow** that: + +- **Designs schemas** - AI generates complete database schemas from natural language descriptions +- **Creates migrations** - Automatically generates and applies database migrations +- **Seeds data** - Generates realistic test data for development +- **Monitors health** - Runs automated checks for schema issues and performance problems +- **Visual management** - Provides GUI access via Prisma Studio + + + Your system now operates at **[Level 2 Continuous AI](https://blog.continue.dev/what-is-continuous-ai-a-developers-guide/)** - AI handles schema design and migration generation with human oversight for production deployments. + + +## Advanced Database Development Prompts + +Enhance your workflow with these advanced Continue CLI prompts: + + + + Analyze existing schema and suggest improvements for scalability, including partitioning strategies and denormalization opportunities + + + Review slow queries and generate optimized indexes, explain plans, and query rewrites + + + Generate data transformation scripts when changing schema structure (e.g., splitting tables, normalizing data) + + + Create backup strategies and generate recovery scripts for disaster scenarios + + + +## Real-World Use Cases + +### Use Case 1: Adding Multi-Tenancy to Existing Schema + +**Prompt:** +``` +I need to add multi-tenancy to my existing database schema: + +Current tables: users, products, orders + +Requirements: +- Add an organizations table +- Link all existing tables to organizations +- Ensure data isolation between tenants +- Migrate existing data to a default organization +- Add organization_id to all relevant indexes + +Generate: +1. Updated Prisma schema with multi-tenant support +2. Migration to add organization_id columns +3. Data migration script to populate organization_id +4. Updated seed script with multi-tenant data +5. Queries demonstrating tenant isolation +``` + +### Use Case 2: Adding Full-Text Search + +**Prompt:** +``` +Add full-text search to my blog platform: + +Tables: posts (title, content), comments (text) + +Requirements: +- Use PostgreSQL full-text search capabilities +- Create search indexes for posts and comments +- Add search ranking/relevance +- Support phrase matching and stemming +- Highlight matching terms in results + +Generate: +1. Migration to add tsvector columns and GIN indexes +2. Prisma schema updates +3. Example search queries using raw SQL +4. Helper functions for search in TypeScript +``` + +### Use Case 3: Implementing Audit Logging + +**Prompt:** +``` +Add comprehensive audit logging to track all data changes: + +Tables to audit: users, orders, products + +Requirements: +- Record all INSERT, UPDATE, DELETE operations +- Store: who made changes, when, what changed, old/new values +- Implement using PostgreSQL triggers or application-level +- Query audit history for specific records +- Implement data retention policy (keep 90 days) + +Generate: +1. Audit log table schema +2. Triggers or Prisma middleware for logging +3. Queries to view audit history +4. Cleanup script for old audit records +``` + +## Security Best Practices + + + **Database Security Guidelines**: + - Never commit `.env` files with database credentials + - Use environment variables for all sensitive configuration + - Implement row-level security (RLS) for multi-tenant apps + - Review all AI-generated SQL before running in production + - Use read replicas for analytics queries + - Enable SSL/TLS for database connections + - Regularly rotate database passwords + - Use least-privilege database users for applications + + +## Troubleshooting + +### Prisma Remote MCP Connection Issues + +If you encounter issues with Prisma Remote MCP: + +1. Verify your `PRISMA_AUTH_TOKEN` is correctly set in [Continue Hub Secrets](https://hub.continue.dev/settings/secrets) +2. Check that the secret key is exactly: `prisma/prisma-remote-mcp/PRISMA_AUTH_TOKEN` +3. Ensure you have network connectivity to `https://mcp.prisma.io` +4. Verify your Prisma account has access to the database at [Prisma Console](https://console.prisma.io) +5. Check your DATABASE_URL is correctly set in `.env` (for local Prisma CLI operations) + +### Common Migration Issues + +| Issue | Solution | +|:------|:---------| +| Migration conflicts | Reset development database with `prisma migrate reset` | +| Schema drift detected | Run `prisma migrate dev` to sync schema with database | +| Connection refused | Verify DATABASE_URL and database is running | +| Permission denied | Check database user has CREATE/ALTER privileges | + +### AI Safety Guardrails + +When Prisma Remote MCP detects destructive operations (like `migrate reset`): + +1. You'll see a confirmation prompt +2. Review what will be deleted +3. Type "yes" to confirm or "no" to cancel +4. The AI will wait for your response before proceeding + + + This safety feature prevents accidental data loss when AI agents run database commands. The Prisma Remote MCP enforces these guardrails on the server side for enhanced security. + + +## Next Steps + +- Explore [Prisma Client](https://www.prisma.io/docs/concepts/components/prisma-client) for type-safe database queries +- Set up [Prisma Accelerate](https://www.prisma.io/docs/accelerate) for connection pooling +- Configure [Prisma Pulse](https://www.prisma.io/docs/pulse) for real-time database events +- Learn about [Prisma Optimize](https://www.prisma.io/docs/optimize) for query performance insights +- Join the [Continue Discord](https://discord.gg/continue) for support + +## Resources + +- [Prisma Remote MCP on Continue Hub](https://hub.continue.dev/prisma/prisma-remote-mcp) +- [Prisma MCP Documentation](https://www.prisma.io/docs/postgres/integrations/mcp-server) +- [Prisma Schema Reference](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference) +- [Prisma Migrate Guide](https://www.prisma.io/docs/concepts/components/prisma-migrate) +- [Prisma Best Practices](https://www.prisma.io/docs/guides/performance-and-optimization) +- [Model Context Protocol Docs](https://modelcontextprotocol.io/introduction) +- [Continue CLI Guide](https://docs.continue.dev/guides/cli) +- [Continuous AI Best Practices](https://blog.continue.dev/what-is-continuous-ai-a-developers-guide/)