Neon MCP Server
Neon MCP servers enable AI models to interact with serverless PostgreSQL databases, providing capabilities for structured data operations, SQL queries, database branching, and automatic scaling in a fully managed environment.
Overview
The MCP Neon Server bridges AI and serverless databases by letting language models (LLMs) work directly with Neon's serverless PostgreSQL platform. Neon provides instant database provisioning, automatic scaling, and database branching capabilities that make it ideal for modern development workflows.
Created by:
Developed by Neon
Key Features
Serverless PostgreSQL
Instant provisioning with automatic scaling and zero operational overhead
Database Branching
Create instant database branches for development, testing, and migrations
Project Management
Manage projects, branches, and compute resources programmatically
Advanced Operations
Schema migrations, query tuning, and performance optimization workflows
Available Tools
Quick Reference
| Tool | Purpose | Category |
|---|---|---|
list_projects | List all Neon projects | Project Mgmt |
create_project | Create new project | Project Mgmt |
describe_project | Get project details | Project Mgmt |
delete_project | Remove project | Project Mgmt |
create_branch | Create database branch | Branch Mgmt |
delete_branch | Remove branch | Branch Mgmt |
describe_branch | Get branch details | Branch Mgmt |
list_branch_computes | List compute endpoints | Branch Mgmt |
run_sql | Execute SQL query | Query |
run_sql_transaction | Execute transaction | Query |
get_database_tables | List tables | Schema |
describe_table_schema | Get table structure | Schema |
get_connection_string | Get connection URL | Connection |
list_slow_queries | Analyze performance | Performance |
explain_sql_statement | Query execution plan | Performance |
prepare_database_migration | Start migration workflow | Migration |
complete_database_migration | Finish migration | Migration |
prepare_query_tuning | Start query optimization | Performance |
complete_query_tuning | Apply optimizations | Performance |
provision_neon_auth | Setup Neon Auth | Auth |
Detailed Usage
list_projects▶
Retrieve a list of your Neon projects with summary information.
use_mcp_tool({
server_name: "neon",
tool_name: "list_projects",
arguments: {
limit: 10 // Optional: default 10
}
});
Returns project IDs, names, regions, and creation timestamps.
create_project▶
Create a new Neon project with custom configuration.
use_mcp_tool({
server_name: "neon",
tool_name: "create_project",
arguments: {
name: "production-db",
region_id: "aws-us-east-2"
}
});
Creates project with default database and compute endpoint.
create_branch▶
Create a new database branch for development or testing.
use_mcp_tool({
server_name: "neon",
tool_name: "create_branch",
arguments: {
project_id: "project-id-123",
parent_branch: "main",
name: "feature-new-schema"
}
});
Instantly creates a copy-on-write branch from parent.
run_sql▶
Execute SQL queries with optional parameterization.
use_mcp_tool({
server_name: "neon",
tool_name: "run_sql",
arguments: {
project_id: "project-id-123",
branch_id: "branch-id-456",
database: "neondb",
sql: "SELECT * FROM users WHERE id = $1",
params: [42]
}
});
Supports both read and write operations with parameters.
run_sql_transaction▶
Execute multiple SQL statements as an atomic transaction.
use_mcp_tool({
server_name: "neon",
tool_name: "run_sql_transaction",
arguments: {
project_id: "project-id-123",
branch_id: "branch-id-456",
database: "neondb",
queries: [
"INSERT INTO accounts (name, balance) VALUES ('Alice', 1000)",
"INSERT INTO accounts (name, balance) VALUES ('Bob', 500)",
"UPDATE stats SET total_accounts = total_accounts + 2"
]
}
});
All queries succeed or fail together.
get_database_tables▶
List all tables in a database with optional schema filtering.
// List all tables in public schema
use_mcp_tool({
server_name: "neon",
tool_name: "get_database_tables",
arguments: {
project_id: "project-id-123",
branch_id: "branch-id-456",
database: "neondb",
schema: "public" // Optional, defaults to 'public'
}
});
Returns table names and metadata.
describe_table_schema▶
Get detailed schema information for a specific table.
use_mcp_tool({
server_name: "neon",
tool_name: "describe_table_schema",
arguments: {
project_id: "project-id-123",
branch_id: "branch-id-456",
database: "neondb",
table: "users",
schema: "public"
}
});
Returns columns, data types, constraints, and indexes.
prepare_database_migration▶
Initiate a safe migration workflow using database branching.
use_mcp_tool({
server_name: "neon",
tool_name: "prepare_database_migration",
arguments: {
project_id: "project-id-123",
branch_id: "main",
migration_sql: "ALTER TABLE users ADD COLUMN email_verified BOOLEAN DEFAULT false"
}
});
Creates temporary branch and tests migration safely.
list_slow_queries▶
Identify performance bottlenecks by analyzing slow queries.
use_mcp_tool({
server_name: "neon",
tool_name: "list_slow_queries",
arguments: {
project_id: "project-id-123",
branch_id: "branch-id-456",
database: "neondb",
min_duration_ms: 1000, // Queries slower than 1s
limit: 10
}
});
Requires pg_stat_statements extension enabled.
explain_sql_statement▶
Analyze query execution plans for optimization.
use_mcp_tool({
server_name: "neon",
tool_name: "explain_sql_statement",
arguments: {
project_id: "project-id-123",
branch_id: "branch-id-456",
database: "neondb",
sql: "SELECT * FROM orders WHERE user_id = 123 AND created_at > NOW() - INTERVAL '30 days'"
}
});
Returns detailed execution plan with cost estimates.
provision_neon_auth▶
Setup Neon Auth integration with Stack Auth.
use_mcp_tool({
server_name: "neon",
tool_name: "provision_neon_auth",
arguments: {
project_id: "project-id-123"
}
});
Configures authentication infrastructure automatically.
Installation
{
"mcpServers": {
"neon": {
"command": "npx",
"args": [
"-y",
"@neondatabase/mcp-server-neon",
"start",
"<YOUR_NEON_API_KEY>"
]
}
}
}
API Key Required:
You need to create a Neon API key from the Neon Console under Account Settings → API Keys.
Setup Guide
1. Create Neon Account
- Sign up at Neon Console
- Create your first project (or use existing one)
- Note your project ID from the project dashboard
2. Generate API Key
- Go to Account Settings → API Keys
- Click "Create API Key"
- Give it a descriptive name (e.g., "MCP Integration")
- Copy the API key immediately (shown only once)
- Store it securely
3. Configure MCP Server
Add the API key to your MCP configuration as shown in the Installation section above.
Project Selection:
The server can work with multiple projects. Specify the project_id in each tool call to target different projects.
Common Use Cases
1. Development Branch Workflow
Create isolated database branches for feature development:
// Create feature branch
use_mcp_tool({
server_name: "neon",
tool_name: "create_branch",
arguments: {
project_id: "my-project",
parent_branch: "main",
name: "feature-user-profiles"
}
});
// Run migrations on feature branch
use_mcp_tool({
server_name: "neon",
tool_name: "run_sql",
arguments: {
project_id: "my-project",
branch_id: "feature-user-profiles",
database: "neondb",
sql: `
CREATE TABLE user_profiles (
id SERIAL PRIMARY KEY,
user_id INTEGER REFERENCES users(id),
bio TEXT,
avatar_url TEXT,
created_at TIMESTAMPTZ DEFAULT NOW()
)
`
}
});
// Test the changes, then delete branch when done
use_mcp_tool({
server_name: "neon",
tool_name: "delete_branch",
arguments: {
project_id: "my-project",
branch_id: "feature-user-profiles"
}
});
2. Safe Schema Migrations
Use the migration workflow for production changes:
// Prepare migration (creates test branch)
use_mcp_tool({
server_name: "neon",
tool_name: "prepare_database_migration",
arguments: {
project_id: "my-project",
branch_id: "main",
migration_sql: `
ALTER TABLE orders
ADD COLUMN tracking_number VARCHAR(100),
ADD COLUMN shipped_at TIMESTAMPTZ
`
}
});
// Test migration on temporary branch...
// If successful, complete the migration
use_mcp_tool({
server_name: "neon",
tool_name: "complete_database_migration",
arguments: {
project_id: "my-project",
migration_id: "migration-xyz"
}
});
3. Query Performance Analysis
Identify and optimize slow queries:
// Find slow queries
use_mcp_tool({
server_name: "neon",
tool_name: "list_slow_queries",
arguments: {
project_id: "my-project",
branch_id: "main",
database: "neondb",
min_duration_ms: 500,
limit: 10
}
});
// Analyze specific query
use_mcp_tool({
server_name: "neon",
tool_name: "explain_sql_statement",
arguments: {
project_id: "my-project",
branch_id: "main",
database: "neondb",
sql: "SELECT * FROM orders WHERE status = 'pending' ORDER BY created_at DESC"
}
});
// Optimize using query tuning workflow
use_mcp_tool({
server_name: "neon",
tool_name: "prepare_query_tuning",
arguments: {
project_id: "my-project",
branch_id: "main",
query: "SELECT * FROM orders WHERE status = 'pending' ORDER BY created_at DESC"
}
});
4. Multi-Environment Management
Manage development, staging, and production databases:
// List all projects
use_mcp_tool({
server_name: "neon",
tool_name: "list_projects",
arguments: { limit: 20 }
});
// Get details for production project
use_mcp_tool({
server_name: "neon",
tool_name: "describe_project",
arguments: {
project_id: "prod-project-id"
}
});
// List compute endpoints for scaling info
use_mcp_tool({
server_name: "neon",
tool_name: "list_branch_computes",
arguments: {
project_id: "prod-project-id",
branch_id: "main"
}
});
5. Database Inspection and Schema Discovery
Explore database structure programmatically:
// List all tables
use_mcp_tool({
server_name: "neon",
tool_name: "get_database_tables",
arguments: {
project_id: "my-project",
branch_id: "main",
database: "neondb",
schema: "public"
}
});
// Get detailed schema for specific table
use_mcp_tool({
server_name: "neon",
tool_name: "describe_table_schema",
arguments: {
project_id: "my-project",
branch_id: "main",
database: "neondb",
table: "users",
schema: "public"
}
});
Neon-Specific Features
Database Branching
Neon's branching is a game-changer for database workflows:
- Instant copies: Create database branches in seconds using copy-on-write
- Cost-effective: Only changed data consumes additional storage
- Safe testing: Test migrations and schema changes without affecting production
- CI/CD integration: Create ephemeral databases for each pull request
Autoscaling
Neon automatically scales compute resources:
- Scale to zero: Compute automatically suspends during inactivity
- Auto-resume: Instantly resumes when queries arrive
- Cost optimization: Pay only for actual usage, not idle time
Connection Pooling
Built-in connection pooling for better performance:
- Managed connection pool included
- Reduces connection overhead
- Better resource utilization
Best Practices
- Use branches for development: Never test schema changes on production branches
- Enable pg_stat_statements: Required for query performance analysis
- Monitor slow queries: Regularly check for performance bottlenecks
- Use transactions: Ensure data consistency with
run_sql_transaction - Leverage autoscaling: Design apps to handle compute suspension gracefully
- Clean up branches: Delete unused branches to optimize storage costs
Sources
Related Articles
Datadog MCP Server
Datadog MCP servers enable AI models to interact with Datadog observability: metrics, logs, traces, monitors, dashboards, incidents, and infrastructure insights.
YouTube Research MCP Server
YouTube Research MCP servers enable AI models to interact with YouTube content, providing capabilities for video information retrieval, transcript management, channel analysis, and playlist management.
Sentry MCP Server
Sentry MCP servers enable AI models to interact with Sentry's error monitoring and performance tracking platform, providing capabilities for analyzing errors, tracking performance, and assisting in debugging applications.