Prisma is a next-generation ORM that provides a comprehensive database toolkit including type-safe query builder, declarative migrations, and GUI database management.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Model Context Protocol server for AI development tools integration, providing structured access to Prisma operations through standardized AI-native interfaces.
Start Prisma MCP server to provide AI development tools with structured access to Prisma CLI operations.
/**
* Start Prisma MCP server for AI development tools
* Provides structured interface for AI agents to interact with Prisma
*/
prisma mcp [options]
Options:
--early-access Enable early access MCP features
--help/-h Show MCP command helpUsage Examples:
# Start MCP server with default configuration
prisma mcp
# Start MCP server with early access features
prisma mcp --early-accessThe Prisma MCP server exposes standardized tools that AI development environments can invoke for database operations.
/**
* MCP Tools provided by Prisma server
* Each tool provides structured input/output for AI agent interaction
*/
interface McpTools {
'migrate-status': MigrateStatusTool;
'migrate-dev': MigrateDevTool;
'migrate-reset': MigrateResetTool;
'Prisma-Studio': PrismaStudioTool;
}
interface MigrateStatusTool {
name: 'migrate-status';
description: 'Check database migration status and history';
inputSchema: {
type: 'object';
properties: {
schema?: { type: 'string'; description: 'Path to schema file' };
};
};
}
interface MigrateDevTool {
name: 'migrate-dev';
description: 'Create and apply development migrations';
inputSchema: {
type: 'object';
properties: {
name?: { type: 'string'; description: 'Migration name' };
createOnly?: { type: 'boolean'; description: 'Create migration without applying' };
skipGenerate?: { type: 'boolean'; description: 'Skip client generation' };
schema?: { type: 'string'; description: 'Path to schema file' };
};
};
}
interface MigrateResetTool {
name: 'migrate-reset';
description: 'Reset database and reapply all migrations';
inputSchema: {
type: 'object';
properties: {
force?: { type: 'boolean'; description: 'Skip confirmation prompt' };
skipGenerate?: { type: 'boolean'; description: 'Skip client generation' };
skipSeed?: { type: 'boolean'; description: 'Skip database seeding' };
schema?: { type: 'string'; description: 'Path to schema file' };
};
};
}
interface PrismaStudioTool {
name: 'Prisma-Studio';
description: 'Launch Prisma Studio database interface';
inputSchema: {
type: 'object';
properties: {
port?: { type: 'number'; description: 'Custom port number' };
browser?: { type: 'string'; description: 'Browser selection' };
hostname?: { type: 'string'; description: 'Hostname binding' };
schema?: { type: 'string'; description: 'Path to schema file' };
};
};
}Check migration status and history through MCP interface with structured output for AI agents.
{
"tool": "migrate-status",
"arguments": {
"schema": "./prisma/schema.prisma"
}
}Response Format:
{
"isSuccessful": true,
"content": [
{
"type": "text",
"text": "Migration Status:\n✓ Database schema is up to date\n\nApplied migrations:\n- 20240101120000_init\n- 20240102130000_add_user_profile\n\nNo pending migrations."
}
]
}Create and apply development migrations through MCP with validation and error handling.
{
"tool": "migrate-dev",
"arguments": {
"name": "add-user-posts",
"createOnly": false,
"skipGenerate": false
}
}Response Format:
{
"isSuccessful": true,
"content": [
{
"type": "text",
"text": "Migration created and applied successfully:\n- Created migration: 20240103140000_add_user_posts\n- Applied to database\n- Generated Prisma Client\n- Database synchronized"
}
]
}Reset database through MCP interface with safety confirmation and structured feedback.
{
"tool": "migrate-reset",
"arguments": {
"force": true,
"skipGenerate": false,
"skipSeed": true
}
}Response Format:
{
"isSuccessful": true,
"content": [
{
"type": "text",
"text": "Database reset completed:\n- Dropped all data\n- Reapplied all migrations\n- Generated Prisma Client\n- Ready for development"
}
]
}Launch Studio interface through MCP with configuration options and status reporting.
{
"tool": "Prisma-Studio",
"arguments": {
"port": 5555,
"hostname": "localhost",
"browser": "chrome"
}
}Response Format:
{
"isSuccessful": true,
"content": [
{
"type": "text",
"text": "Prisma Studio launched successfully:\n- URL: http://localhost:5555\n- Browser: chrome\n- Status: Running\n- Ready for database management"
}
]
}AI development tools can use the MCP server to perform database operations:
// AI agent workflow example
const mcpClient = new McpClient('prisma-mcp-server');
// 1. Check current migration status
const status = await mcpClient.callTool('migrate-status', {});
// 2. Create migration based on schema changes
const migration = await mcpClient.callTool('migrate-dev', {
name: 'ai-suggested-changes',
createOnly: true // Review before applying
});
// 3. Launch Studio for verification
const studio = await mcpClient.callTool('Prisma-Studio', {
port: 5555
});# Start MCP server for development environment
prisma mcp &
# AI development tool connects to MCP server
# Provides structured database operations to AI agents// CI/CD pipeline using MCP interface
const mcpOperations = {
checkMigrations: () => mcpClient.callTool('migrate-status', {}),
applyMigrations: () => mcpClient.callTool('migrate-dev', {
skipGenerate: false
}),
resetTestDb: () => mcpClient.callTool('migrate-reset', {
force: true,
skipSeed: false
})
};interface McpServerConfig {
earlyAccess?: boolean; // Enable early access features
schemaPath?: string; // Default schema file path
port?: number; // MCP server port (not Studio port)
logLevel?: 'debug' | 'info' | 'warn' | 'error';
timeout?: number; // Tool execution timeout
}# MCP server environment configuration
DATABASE_URL="postgresql://user:pass@localhost:5432/db"
PRISMA_SCHEMA_PATH="./prisma/schema.prisma"
MCP_LOG_LEVEL="info"
MCP_TIMEOUT="30000"// MCP server security features
interface McpSecurity {
toolWhitelist: string[]; // Allowed tools for security
schemaValidation: boolean; // Validate schema before operations
confirmationRequired: boolean; // Require confirmation for destructive ops
auditLogging: boolean; // Log all MCP operations
}interface McpSuccessResponse {
isSuccessful: true;
content: Array<{
type: 'text' | 'image' | 'resource';
text?: string;
data?: string;
uri?: string;
}>;
}interface McpErrorResponse {
isSuccessful: false;
content: Array<{
type: 'text';
text: string;
}>;
error?: {
code: string;
message: string;
details?: any;
};
}# Enable early access MCP features
prisma mcp --early-accessEarly access features may include:
// Framework for custom MCP tool development
interface CustomMcpTool {
name: string;
description: string;
inputSchema: JSONSchema;
handler: (args: any) => Promise<McpResponse>;
}// MCP server monitoring capabilities
interface McpMetrics {
toolInvocations: Record<string, number>;
averageExecutionTime: Record<string, number>;
errorRates: Record<string, number>;
activeConnections: number;
}Common MCP server errors:
// VS Code extension using Prisma MCP
const mcpProvider = new PrismaMcpProvider();
// Add database operations to command palette
vscode.commands.registerCommand('prisma.checkMigrations', async () => {
const result = await mcpProvider.callTool('migrate-status', {});
vscode.window.showInformationMessage(result.content[0].text);
});// AI assistant using Prisma MCP for database operations
class DatabaseAssistant {
constructor(private mcpClient: McpClient) {}
async handleDatabaseQuery(userQuery: string) {
// Analyze user intent
const intent = this.analyzeIntent(userQuery);
// Execute appropriate MCP tool
switch (intent.operation) {
case 'check-status':
return await this.mcpClient.callTool('migrate-status', {});
case 'create-migration':
return await this.mcpClient.callTool('migrate-dev', {
name: intent.migrationName
});
case 'open-studio':
return await this.mcpClient.callTool('Prisma-Studio', {});
}
}
}Install with Tessl CLI
npx tessl i tessl/npm-prisma