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:
- Open VS Code Settings
- Search for "DevDb MCP"
- Ensure "Enable MCP Server" is checked
2. Copy MCP Configuration
- Open DevDb panel
- Click the hammer icon (🔨) in the toolbar
- 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
{
"mcpServers": {
"devdb": {
"command": "node",
"args": ["/path/to/devdb-mcp-server.js"],
"env": {
"DEVDB_CONNECTION_ID": "your-connection-id"
}
}
}
}Windsurf
File: windsurf/mcp_config.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:
- Save the configuration file
- Restart your AI tool
- 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):
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
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):
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:
- Open DevDb panel
- Look at the connection name in the sidebar
- The ID is shown in the MCP configuration
Multiple Databases
For multiple database connections:
- Copy MCP config for each connection
- Use different server names (e.g., "devdb-main", "devdb-analytics")
- 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:
- Verify MCP is enabled in DevDb settings
- Check configuration file path is correct
- Restart the AI tool after config changes
- Review AI tool logs for connection errors
Incorrect Schema Information
If the AI has outdated schema:
- Refresh database connection in DevDb
- Restart MCP server (disable/enable in settings)
- Clear AI tool cache if available
Connection Errors
If you see connection errors:
- Verify database is running
- Check DevDb connection is active
- Review connection ID in config
- 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:
- Browse schema in DevDb
- Use AI to generate code with MCP context
- Test queries in DevDb
- Export data for fixtures
Team Collaboration
Share MCP benefits with your team:
- Document MCP setup in project README
- Share connection configs (without credentials)
- Create consistent prompts that leverage schema
- Standardize AI workflows
Next Steps
- Database Client - Explore the interface
- Laravel Integration - Framework features
- Configuration - Database setup