What is this?
The Prisma Postgres MCP Server is an advanced server package that brings AI-powered database management to PostgreSQL through the Modular Connector Protocol. Built and maintained by Prisma, it integrates seamlessly with Prisma ORM to automate schema migrations, execute live queries, manage connection pooling, and handle backup and restore workflows. With built-in audit logging and role-based access control, it provides a secure interface for AI agents and DevOps teams to interact with Postgres databases.
By implementing the MCP protocol over HTTP and WebSocket, this server exposes a unified set of tools and resources—such as migrateSchema, runQuery, and listBackups—that LLM-based agents can invoke via simple prompts. Whether you’re automating migrations, scheduling backups to S3, or running real-time analytics queries, the Prisma Postgres MCP Server streamlines your Postgres operations and fits directly into CI/CD pipelines, dashboards, and AI workflows.
Quick Start
Install the server using npm:
npm install @prisma/mcp-server-postgres
Then add it to your MCP client configuration:
{
"mcpServers": {
"prisma-postgres-mcp-server": {
"command": "npx",
"args": ["-y", "@prisma/mcp-server-postgres"],
"env": {
"API_KEY": "your-api-key-here"
}
}
}
}
Key Features
Automatic Schema Migrations: Generates and applies Prisma schema migrations automatically, reducing manual intervention and migration drift.
Live Querying & Connection Pooling: Executes parameterized SQL or Prisma Client queries in real time with a configurable connection pool for high-concurrency workloads.
Backup & Restore Management: Schedules full and incremental backups to S3 or local storage, lists existing snapshots, and restores on demand with integrity checks.
Example Usage
Imagine a chatbot agent needs to add a new User table. It can call the migrateSchema tool with a Prisma schema diff to generate and apply the migration automatically.
// Example code
const result = await client.callTool({
name: "migrateSchema",
arguments: {
database: "main-db",
prismaSchemaDiff: "model User { id Int @id @default(autoincrement()) email String @unique createdAt DateTime @default(now()) }"
}
});
This code invokes migrateSchema, and the server responds with a success status, migration name, and timestamp of application.
Configuration
The server accepts the following environment variables:
API_KEY – Your Prisma API key or token for authenticating MCP requests.
PROTOCOLS (optional) – Comma-separated list of protocols to enable (e.g., http,ws).
Available Tools/Resources
migrateSchema: Generate and apply Prisma schema migrations.
runQuery: Execute parameterized SQL or Prisma Client queries over MCP.
Who Should Use This?
This server is perfect for:
DevOps Engineers: Automate database migrations, backups, and monitoring in CI/CD pipelines.
Data Teams: Run AI-driven analytics queries and maintain database health with minimal manual effort.
AI Agent Developers: Integrate Postgres operations into conversational or automated agent workflows via MCP.
Conclusion
The Prisma Postgres MCP Server empowers teams to bring AI automation and robust database management to Postgres with ease. Give it a try to streamline migrations, querying, backups, and auditing in your applications and agent workflows.
Check out the GitHub repository for more information and to contribute.