Skip to content

MCP Server Integration

DevDb Pro provides a Model Context Protocol (MCP) server that allows AI-powered IDEs and tools to access your database schema and structure. This enables intelligent code assistance, query generation, and database-aware AI features.

What is MCP?

The Model Context Protocol (MCP) is an open protocol that standardizes how applications provide context to Large Language Models (LLMs). DevDb's MCP server exposes your database schema to compatible AI tools.

Supported AI Tools

DevDb's MCP server works with:

  • Cursor - AI-first code editor
  • Windsurf - AI-enhanced IDE
  • Cline - Claude-powered coding assistant
  • Any other MCP-compatible client

Setup Instructions

1. Enable MCP Server

The MCP server is enabled by default. To verify or change:

  1. Open VS Code Settings
  2. Search for "DevDb MCP"
  3. Ensure "Enable MCP Server" is checked

2. Copy MCP Configuration

  1. Open DevDb panel
  2. Click the hammer icon (🔨) in the toolbar
  3. MCP settings are copied to your clipboard

3. Configure Your AI Tool

Paste the copied configuration into your AI tool's MCP settings file:

Cursor

File: .vscode/mcp.json or global settings

json
{
  "mcpServers": {
    "devdb": {
      "command": "node",
      "args": ["/path/to/devdb-mcp-server.js"],
      "env": {
        "DEVDB_CONNECTION_ID": "your-connection-id"
      }
    }
  }
}

Windsurf

File: windsurf/mcp_config.json

json
{
  "servers": {
    "devdb": {
      "command": "node",
      "args": ["/path/to/devdb-mcp-server.js"],
      "env": {
        "DEVDB_CONNECTION_ID": "your-connection-id"
      }
    }
  }
}

Other MCP Clients

Refer to your client's documentation for the MCP configuration file location.

4. Restart Your AI Tool

After adding the configuration:

  1. Save the configuration file
  2. Restart your AI tool
  3. Verify connection in the tool's MCP settings

What the AI Can Access

The MCP server provides:

Database Schema

  • Table names and structures
  • Column names and types
  • Primary keys
  • Foreign key relationships
  • Indexes and constraints

Query Assistance

  • Generate SQL queries based on schema
  • Suggest table joins
  • Validate query syntax
  • Optimize queries

Code Generation

  • Generate ORM models
  • Create migration files
  • Build API endpoints
  • Generate test data

Usage Examples

Example 1: Generate Query

Prompt: "Write a query to get all active users with their orders"

AI Response (with MCP context):

sql
SELECT u.*, o.*
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE u.is_active = true
ORDER BY u.created_at DESC;

The AI knows your exact table and column names from the MCP server.

Example 2: Create Laravel Model

Prompt: "Create a Laravel model for the products table"

AI Response (with MCP context):

php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $fillable = [
        'name',
        'description',
        'price',
        'stock_quantity',
        'category_id',
    ];

    protected $casts = [
        'price' => 'decimal:2',
        'stock_quantity' => 'integer',
    ];

    public function category()
    {
        return $this->belongsTo(Category::class);
    }
}

The AI uses your actual schema to generate accurate code.

Example 3: Database Migration

Prompt: "Create a migration to add a status column to orders"

AI Response (with MCP context):

php
public function up()
{
    Schema::table('orders', function (Blueprint $table) {
        $table->enum('status', ['pending', 'processing', 'completed', 'cancelled'])
              ->default('pending')
              ->after('total_amount');
    });
}

The AI knows your existing orders table structure.

Configuration Options

Connection ID

Each database connection has a unique ID. To find yours:

  1. Open DevDb panel
  2. Look at the connection name in the sidebar
  3. The ID is shown in the MCP configuration

Multiple Databases

For multiple database connections:

  1. Copy MCP config for each connection
  2. Use different server names (e.g., "devdb-main", "devdb-analytics")
  3. AI can access all databases independently

Security Considerations

The MCP server:

  • Read-only access - Cannot modify your database
  • Local only - Runs on your machine
  • Schema only - Doesn't expose data values
  • Per-project - Scoped to your workspace

Troubleshooting

MCP Server Not Detected

If your AI tool doesn't see the MCP server:

  1. Verify MCP is enabled in DevDb settings
  2. Check configuration file path is correct
  3. Restart the AI tool after config changes
  4. Review AI tool logs for connection errors

Incorrect Schema Information

If the AI has outdated schema:

  1. Refresh database connection in DevDb
  2. Restart MCP server (disable/enable in settings)
  3. Clear AI tool cache if available

Connection Errors

If you see connection errors:

  1. Verify database is running
  2. Check DevDb connection is active
  3. Review connection ID in config
  4. Check file paths in MCP config

Advanced Usage

Custom Prompts

With MCP context, you can:

  • "Optimize this query for our schema"
  • "Find all tables related to users"
  • "Generate a factory for this model with real columns"
  • "Write tests for this table structure"

Workflow Integration

Combine MCP with DevDb features:

  1. Browse schema in DevDb
  2. Use AI to generate code with MCP context
  3. Test queries in DevDb
  4. Export data for fixtures

Team Collaboration

Share MCP benefits with your team:

  1. Document MCP setup in project README
  2. Share connection configs (without credentials)
  3. Create consistent prompts that leverage schema
  4. Standardize AI workflows

Next Steps

DevDb Pro - Zero-config database management for VS Code