Built by Metorial, the integration platform for agentic AI.

Learn More

    Server Summary

    • Manage Postgres databases

    • Execute SQL queries

    • Perform schema migrations

    • Optimize query performance

Neon MCP Server

A comprehensive Model Context Protocol (MCP) server for managing Neon serverless Postgres databases. This server provides AI assistants with complete control over Neon projects, enabling database creation, schema migrations, query optimization, authentication provisioning, and more—all through natural language interactions.

The Neon MCP server transforms complex database operations into simple conversational commands. Whether you're setting up a new project, tuning slow queries, or managing database migrations with confidence, this server acts as an intelligent database administrator that understands context and helps you make informed decisions.

Features

Project and Organization Management

Manage your entire Neon infrastructure with ease. The server provides comprehensive tools for discovering and organizing your database projects:

  • List and search projects across your account with intelligent filtering by name or ID
  • Browse organizations to understand your team structure and access permissions
  • View shared projects to see databases where you have collaborative access
  • Create new projects instantly, with optional organization assignment
  • Inspect project details to understand configuration and status
  • Clean up resources by deleting projects when they're no longer needed

Database Operations

Execute SQL with confidence using intelligent query execution tools:

  • Single statement execution for quick queries and data retrieval
  • Transaction support for running multiple statements atomically
  • Schema inspection to understand table structures and relationships
  • Database exploration to list all tables and objects in your database
  • Connection string generation with automatic configuration of branches, roles, and compute endpoints

Safe Schema Migrations

The server implements a sophisticated migration workflow that eliminates the risk of breaking production databases:

Prepare migrations by describing changes in natural language. The system automatically generates DDL statements, creates a temporary branch, and applies changes there first. You can request operations like:

  • Adding new columns or tables
  • Modifying column types
  • Creating indexes and constraints
  • Renaming database objects
  • Dropping unnecessary elements

Verify changes on the temporary branch before they touch production. The server encourages testing and provides detailed feedback about what will change.

Complete migrations by applying verified changes to your main branch or discarding them if something isn't right. The temporary branch is automatically cleaned up.

The migration process includes automatic retry logic and comprehensive error handling to ensure your database remains stable.

Intelligent Query Performance Tuning

Transform slow queries into fast ones with AI-powered optimization:

The query tuning workflow analyzes your SQL statements, identifies performance bottlenecks, and suggests concrete improvements. The server:

  • Creates a safe testing environment in a temporary branch
  • Extracts query execution plans to understand current performance
  • Analyzes all referenced tables and their schemas
  • Suggests optimizations like index creation or query restructuring
  • Applies changes to the test branch for validation
  • Compares before and after performance metrics
  • Applies approved changes to production or discards unsuccessful experiments

The system provides detailed cost analysis and execution time comparisons, helping you make data-driven decisions about query optimization.

Branch Management

Leverage Neon's powerful branching capabilities for development workflows:

  • Create branches instantly from any point in time
  • Describe branch contents to see the complete object hierarchy
  • Reset branches to match their parent state, with optional preservation of current changes
  • Delete branches when they're no longer needed
  • List compute endpoints to understand available resources

Branches enable zero-downtime migrations, isolated development environments, and safe experimentation with database changes.

Authentication Provisioning

Set up complete authentication infrastructure with a single command:

The provision_neon_auth tool integrates Stack Auth with your Neon database, creating:

  • A dedicated authentication schema
  • User tables synchronized with Stack Auth
  • Client and server credentials for your application

The server provides detailed guidance for integrating Stack Auth with Next.js applications, including setup commands, component usage patterns, and security best practices.

Advanced Capabilities

Slow Query Monitoring: Query the pg_stat_statements extension to identify queries consuming the most execution time. Filter by minimum duration and limit results to focus on the biggest problems.

Query Plan Analysis: Run EXPLAIN ANALYZE on any query to understand execution behavior, index usage, and performance characteristics.

Multiple Database Support: Work across different databases within your projects, with automatic fallback to default databases.

Role-Based Access: Execute queries with specific database roles for fine-grained permission control.

Available Tools

Project Management

list_projects - Retrieves up to 400 projects with pagination support. Filter by organization or search by name/ID using partial matches.

list_organizations - Shows all organizations accessible to the current user with optional search filtering.

list_shared_projects - Displays projects shared with you by other users, with pagination and search capabilities.

create_project - Provisions a new Neon project with optional name and organization assignment.

delete_project - Removes a project and all its resources permanently. Requires project ID.

describe_project - Provides detailed information about a specific project including configuration and status.

Query Execution

run_sql - Executes a single SQL statement against a specified database. Supports branch selection and custom database names.

run_sql_transaction - Runs multiple SQL statements in a single transaction for atomic operations.

explain_sql_statement - Generates query execution plans with optional ANALYZE for performance insights.

list_slow_queries - Identifies queries exceeding a specified execution time threshold, sorted by duration.

Schema Operations

describe_table_schema - Returns complete column information for a table including data types, constraints, and defaults.

get_database_tables - Lists all tables in a database across all schemas.

describe_branch - Provides a tree view of all objects in a branch: databases, schemas, tables, views, and functions.

Migration Management

prepare_database_migration - Initiates a safe migration workflow by creating a temporary branch and applying changes there. Accepts natural language descriptions of schema modifications.

complete_database_migration - Finalizes a migration by applying verified changes to the main branch or discarding them. Requires migration ID from preparation step.

Query Optimization

prepare_query_tuning - Analyzes a slow query, suggests performance improvements, and creates a testing environment for validation.

complete_query_tuning - Applies approved optimization changes to production or cleans up the testing branch. Requires tuning ID and suggested SQL statements.

Branch Operations

create_branch - Creates a new branch from the current state of a project with optional naming.

describe_branch - Explores the complete object hierarchy within a branch.

delete_branch - Removes a branch permanently. Requires project and branch IDs.

reset_from_parent - Resets a branch to match its parent's current state, with optional preservation of changes under a new name.

list_branch_computes - Shows compute endpoints associated with a project or specific branch.

Connection Management

get_connection_string - Generates a properly formatted PostgreSQL connection string with automatic parameter resolution for branches, roles, computes, and databases.

Authentication

provision_neon_auth - Sets up Stack Auth integration with your Neon database, creating authentication schemas and returning credentials for application integration.

Use Cases

This MCP server excels at:

  • Rapid prototyping where you need databases created and configured quickly
  • Safe production changes through the migration workflow with temporary branches
  • Performance troubleshooting by identifying and fixing slow queries
  • Development workflows using branches for isolation and testing
  • Multi-project management for teams working across multiple databases
  • Application setup with integrated authentication provisioning
  • Database exploration to understand existing schema and data structures

The conversational interface makes complex database operations accessible to developers at all skill levels while maintaining the safety and precision required for production systems.