Neon MCP — Serverless Postgres via AI Agents
MCP server for Neon serverless Postgres. Create projects, branch databases, run SQL, optimize queries via natural language. Safe migration workflow with branching. MIT, 574+ stars.
What it is
Neon MCP is a Model Context Protocol server that connects AI agents like Claude Code to Neon's serverless PostgreSQL platform. Through natural language, you can create database projects, branch databases for safe migrations, run SQL queries, and get query optimization suggestions. The MCP server handles authentication and API calls to Neon behind the scenes.
Neon MCP is designed for developers using AI coding agents who want database operations integrated into their AI workflow without switching to a database GUI.
How it saves time or tokens
Database operations typically require switching between your code editor, a database client, and the Neon console. Neon MCP brings all of that into your AI agent's context. Ask Claude Code to 'create a branch, apply the migration, and verify the schema' and it executes the entire workflow through the MCP server. Database branching is particularly powerful: you can test migrations on a branch without risking your production data, all from natural language commands.
How to use
- Add the Neon MCP server to your
.mcp.json(Claude Code) or MCP client config:
{
"mcpServers": {
"Neon": {
"type": "http",
"url": "https://mcp.neon.tech/mcp"
}
}
}
- Restart Claude Code. Authenticate when prompted.
- Ask natural language database questions:
'Create a new Neon database called analytics'
'Branch the production database for testing my migration'
'Run SELECT count(*) FROM users WHERE created_at > now() - interval 7 days'
Example
A typical database migration workflow using Neon MCP:
You: Create a branch from production called 'add-orders-table'
Agent: Created branch 'add-orders-table' from production.
You: On the branch, create a table:
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
user_id INT REFERENCES users(id),
total DECIMAL(10,2),
created_at TIMESTAMPTZ DEFAULT now()
);
Agent: Table 'orders' created on branch 'add-orders-table'.
You: Verify the schema looks correct
Agent: Schema verified. The orders table has 4 columns...
You: Merge the branch to production
Agent: Branch merged. The orders table is now in production.
Related on TokRepo
- Database tools — Browse database management tools
- MCP Postgres integration — Explore PostgreSQL MCP servers
Common pitfalls
- Running destructive queries on the main branch instead of a test branch. Always create a branch before running DDL changes or data modifications. Branches are cheap and instant in Neon.
- Not setting up proper authentication. The Neon MCP server requires an API key. Follow the authentication flow on first use.
- Expecting the MCP server to handle complex multi-statement transactions. For complex migrations, write a SQL file and ask the agent to execute it, rather than sending individual statements.
Frequently Asked Questions
Neon branching creates an instant copy-on-write clone of your database. The branch shares storage with the parent until data diverges, making it free to create. This lets you test migrations, run analytics, or create dev environments without copying data.
Yes. Neon MCP uses the Model Context Protocol, which Claude Code supports natively. Add the MCP server configuration to your .mcp.json file and restart Claude Code to connect.
The MCP server itself is open source and free. Neon's serverless Postgres has a free tier that includes one project with branching. Paid tiers offer more compute, storage, and projects.
You can, but exercise caution. Always use branches for testing changes before applying them to production. The MCP server gives your AI agent direct database access, so review any destructive operations before confirming.
Neon MCP supports all standard PostgreSQL operations: DDL (CREATE, ALTER, DROP), DML (SELECT, INSERT, UPDATE, DELETE), and Neon-specific operations like branching, project management, and query optimization suggestions.
Citations (3)
- Neon MCP— Neon MCP server for serverless Postgres
- Neon Documentation— Neon serverless Postgres with branching
- MCP Specification— Model Context Protocol specification
Related on TokRepo
Source & Thanks
Created by Neon Database. Licensed under MIT.
mcp-server-neon — ⭐ 574+
Thanks to the Neon team for making serverless Postgres accessible to AI agents.