Setup Guide

npx neonctl@latest init: Set Up Neon Serverless Postgres with MCP Integration

Verified May 29, 2026Official Neon docs checkedMCP safety notes updated

npx neonctl@latest init is the fastest way to connect your project to Neon — a serverless Postgres database with instant branching, autoscaling to zero, and built-in MCP Server support for AI coding assistants. This guide was refreshed against Neon's current docs so the assistant support matrix, config paths, and security guidance do not rely on stale 2025 assumptions.

Table of Contents

  1. 1. What Is Neon and neonctl
  2. 2. How to Run npx neonctl@latest init
  3. 3. MCP Server Configuration
  4. 4. Client Support Matrix
  5. 5. Safety Checklist
  6. 6. Database Branching Workflow
  7. 7. Worked Examples
  8. 8. Troubleshooting
  9. 9. FAQ
  10. 10. Related Resources

Official Sources Checked

May 29, 2026 Answer Summary

Official init behavior

Neon documents init as an OAuth-based project-root setup command that creates an API key, configures compatible MCP clients, and installs project-level agent skills.

Current agent coverage

The March 2026 changelog expands one-command setup beyond Cursor, VS Code, and Claude Code to add-mcp-supported agents including Codex, OpenCode, Gemini CLI, Cline, Zed, Goose, and more.

Security posture

Neon recommends MCP for development and testing workflows, with human review before database-changing actions and no production or PII exposure by default.

May 29 source-aware setup checks

Command authority

Start from Neon docs for init behavior, then use add-mcp output only to confirm the local client list.

Credential scope

Review generated Neon API keys after repeated init attempts and remove keys that no longer map to a real workspace.

Client handoff

Record whether the setup landed in Cursor, VS Code, Claude Code, or another add-mcp client before asking the agent to act.

Database action boundary

Allow schema inspection and branch creation first; require human approval for SQL writes, deletes, and production-like data access.

Read-only smoke test

After restart, verify tool discovery with list_projects or schema/table inspection before any branch, migration, or SQL mutation task.

What Is Neon and neonctl

Neon is an open-source serverless Postgres platform that separates storage and compute. This architecture enables three features that traditional Postgres hosting cannot match: instant database branching (copy-on-write, under 1 second), autoscaling to zero (no charges when idle), and built-in connection pooling (up to 10,000 pooled connections per project via PgBouncer).

neonctl is Neon's official CLI tool. It provides terminal access to the same operations available in the Neon dashboard and API: managing projects, creating branches, provisioning databases, and configuring roles. The init subcommand is a guided setup wizard that handles authentication, project selection, and optionally configures MCP Server integration for AI assistants.

The important 2026 change is that Neon now treats AI coding assistants as a first-class onboarding surface. The init command does more than install a CLI helper: it can connect supported editors to the Neon MCP Server and install Neon agent skills so the assistant has database-specific setup guidance.

How to Run npx neonctl@latest init

Run this command from your project root directory. The init wizard is interactive and walks you through each step. Here is the complete sequence:

Prerequisites

  • Node.js 18+ installed
  • A Neon account (free tier works — sign up at neon.tech)
  • A project directory where you want to add Neon

Step-by-Step Setup

# Step 1: Run the init command
npx neonctl@latest init

# The wizard will:
# 1. Open your browser for OAuth authentication
# 2. Create a Neon API key for MCP/API-key auth
# 3. Let you choose which supported editor or assistant to configure
# 4. Install the Neon extension for Cursor or VS Code where applicable
# 5. Configure Claude Code in ~/.claude.json when selected
# 6. Install Neon agent skills at the project level

# Step 2: Verify your connection
npx neonctl@latest connection-string

# Step 3: Test with psql (optional)
psql "$(npx neonctl@latest connection-string --pooled)"

# Step 4: Check project status
npx neonctl@latest projects list --output json

The --pooled flag returns the connection string with PgBouncer pooling enabled (port 5432 with the -pooler hostname suffix). Use pooled connections for serverless applications (Next.js API routes, Vercel functions, Cloudflare Workers) and direct connections for long-running processes like migration scripts.

MCP Server Configuration for AI Assistants

One of neonctl init's most useful features is automatic MCP (Model Context Protocol) Server setup. This lets AI coding assistants directly query, create branches, and manage your Neon database through natural language. Neon's current docs describe this as a development and testing workflow, so database writes should stay behind human review until your team has its own approval policy.

Claude Code

For Claude Code, the init wizard configures the Neon MCP server in ~/.claude.json. After configuration, Claude Code can create database branches, run SQL queries, and manage schemas directly from the conversation, subject to your approval of tool actions.

// ~/.claude.json (manual API-key shape)
{
  "mcpServers": {
    "Neon": {
      "type": "http",
      "url": "https://mcp.neon.tech/mcp",
      "headers": {
        "Authorization": "Bearer <NEON_API_KEY>"
      }
    }
  }
}

Cursor

For Cursor, the init flow installs the Neon Local Connect extension where applicable and configures MCP support. Restart Cursor after the setup, then ask the assistant to get started with Neon.

VS Code with GitHub Copilot

For VS Code, the init flow expects GitHub Copilot and Copilot Chat to be available and installs the Neon Local Connect extension where applicable. Copilot can then use the Neon MCP server for database-aware setup and operational prompts after the editor restarts.

Client Support Matrix

Neon's support surface expanded in 2026 through add-mcp. Use this matrix as the practical current routing guide, and run npx add-mcp list-agents when you need the live list for a machine.

ClientWhat init doesAfter setup
CursorInstalls the Neon Local Connect extension where applicable and configures MCP support.Restart Cursor, open the workspace, and ask the assistant to "Get started with Neon".
VS Code + GitHub CopilotInstalls the Neon Local Connect extension where applicable and configures MCP support.Confirm GitHub Copilot and Copilot Chat are installed before testing the MCP tools.
Claude CodeWrites the Neon MCP configuration to ~/.claude.json when Claude Code is selected.Restart Claude Code and verify the Neon MCP entry before running database-changing prompts.
Other add-mcp agentsUses add-mcp for compatible assistants such as Codex, OpenCode, Cline, Gemini CLI, Goose, Zed, and others.Run npx add-mcp list-agents to confirm the live support list for your installed version.

Safety Checklist Before You Let an Agent Touch a Database

The Neon MCP Server exposes powerful project, branch, and SQL operations. Treat it like any other database admin surface: useful in development, risky without review in production.

Permission levelExamples
Safe to let an assistant inspectList projects, show table schemas, describe branches, fetch connection guidance, and explain read-only query results.
Approve one action at a timeCreate a branch, run a migration on a non-production branch, add test data, or compare database schemas.
Keep human-ownedProduction writes, branch deletion, API-key rotation, access-control changes, PII exports, and irreversible SQL.
  • Run init from the project root so agent skills and lockfiles land in the expected workspace.
  • Review and revoke duplicate Neon API keys if you run init more than once.
  • Treat the Neon MCP Server as a development and testing tool unless your team has explicit review gates.
  • Review every LLM-requested database action before execution, especially schema changes, branch deletion, and SQL writes.
  • Keep connection strings and API keys in environment variables or your secret manager, never in committed docs.

Database Branching Workflow

Neon branching is the feature that separates it from every other managed Postgres service. A branch is an instant, copy-on-write clone of your database — it shares storage with the parent until data diverges. Creating a branch takes under 1 second regardless of database size.

Common Branching Commands

# Create a branch for your PR
npx neonctl@latest branches create --name "feature/user-auth"

# List all branches
npx neonctl@latest branches list --output table

# Get connection string for a specific branch
npx neonctl@latest connection-string --branch "feature/user-auth"

# Delete a branch when PR is merged
npx neonctl@latest branches delete "feature/user-auth"

# Reset a branch to parent state
npx neonctl@latest branches reset "feature/user-auth" --parent

Per-PR Branch Strategy

The most powerful pattern is creating a database branch for every pull request. Each PR gets its own isolated Postgres instance with real data (copied from main). Developers can run migrations, test schema changes, and seed test data without affecting other branches. When the PR merges, delete the branch.

# GitHub Actions: Create branch on PR open
- name: Create Neon branch
  run: |
    npx neonctl@latest branches create \
      --name "pr-${GITHUB_PR_NUMBER}" \
      --api-key ${NEON_API_KEY}

# GitHub Actions: Delete branch on PR close
- name: Cleanup Neon branch
  run: |
    npx neonctl@latest branches delete "pr-${GITHUB_PR_NUMBER}" \
      --api-key ${NEON_API_KEY}

Worked Examples

Example 1: Next.js App with Prisma + Neon

You have a Next.js project and want serverless Postgres. Run npx neonctl@latest init from the project root, complete the MCP setup, then retrieve the connection string and store it in your app environment. For Prisma, keep a pooled URL for application traffic and a direct URL for migrations:

# .env.local (store these through your normal secret workflow)
DATABASE_URL="postgresql://user:pass@ep-cool-name-123.us-east-2.aws.neon.tech/neondb?sslmode=require"

# For Prisma, add the pooled URL for serverless
DATABASE_URL_UNPOOLED="postgresql://user:pass@ep-cool-name-123.us-east-2.aws.neon.tech/neondb?sslmode=require"
DATABASE_URL="postgresql://user:pass@ep-cool-name-123-pooler.us-east-2.aws.neon.tech/neondb?sslmode=require"

The pooled URL goes through PgBouncer and handles connection limits for serverless functions. The unpooled URL is for migrations (prisma migrate deploy) which need direct connections.

Example 2: CI Pipeline with Ephemeral Branches

Your team runs integration tests against a real database. Instead of a shared staging DB, each CI run creates a Neon branch, runs migrations and tests, then deletes the branch:

# CI script
BRANCH_NAME="ci-run-$GITHUB_RUN_ID"

# Create isolated branch (instant, ~1 second)
npx neonctl@latest branches create --name "$BRANCH_NAME"

# Get connection string
export DATABASE_URL=$(npx neonctl@latest connection-string --branch "$BRANCH_NAME" --pooled)

# Run migrations and tests
npm run db:migrate
npm test

# Cleanup
npx neonctl@latest branches delete "$BRANCH_NAME"

Example 3: MCP-Powered Database Management

After configuring MCP via init, you can ask your assistant to propose database operations. Review the requested action before approving anything that changes schema, data, branches, or access:

  • “Create a new branch called staging-v2 from main”
  • “Run this SQL on the staging branch: ALTER TABLE users ADD COLUMN avatar_url TEXT”
  • “Show me the schema of the orders table”
  • “Delete all branches older than 7 days”

The MCP server translates natural language requests into Neon API and database operations, making routine tasks easier without forcing you to leave the editor. The convenience is the reason to use it; the review step is the reason it remains safe.

Troubleshooting

SymptomLikely CauseFix
OAuth browser window does not openRunning in headless/SSH environmentUse neon auth --api-key YOUR_KEY for non-interactive auth
Init passes locally, fails in CIMissing NEON_API_KEY env var in CI secretsAdd API key to GitHub Actions secrets or CI environment
Connection timeout after initUsing direct URL in serverless environmentSwitch to pooled connection string (--pooled flag)
Branch creation failsFree tier branch limit reached (10 branches)Delete unused branches: neonctl branches list then delete stale ones
MCP server not responding in Claude CodeAPI key expired, duplicate config exists, or Claude Code has not reloaded ~/.claude.jsonRestart Claude Code, inspect the Neon MCP entry, and revoke duplicate keys before rerunning init
Unexpected duplicate Neon API keysinit was run multiple times while testing editor setupOpen Neon Console API key settings and revoke stale keys named like neonctl-init-*

Frequently Asked Questions

What does npx neonctl@latest init actually do?

It runs Neon's current one-command setup flow for AI-assisted development. The command authenticates via OAuth, creates a Neon API key, configures the Neon MCP Server, installs the Neon Local Connect extension for Cursor or VS Code where applicable, configures Claude Code in ~/.claude.json when selected, and installs Neon agent skills at the project level.

Do I need to install neonctl globally first?

No. Using npx neonctl@latest downloads and runs the latest version on demand. This is the right onboarding path. For production CI, use a tested pinned version or a committed package manager lockfile instead of relying on @latest.

Which AI assistants does neonctl init support for MCP?

Neon docs now describe Cursor, VS Code with GitHub Copilot, Claude Code, and additional add-mcp-supported assistants. Neon's March 2026 changelog also lists Claude Desktop, Codex, OpenCode, Antigravity, Cline, Cline CLI, Gemini CLI, GitHub Copilot CLI, Goose, MCPorter, and Zed. Run npx add-mcp list-agents for the live list from your installed version.

What is Neon database branching and why does it matter?

Neon branching creates instant copy-on-write Postgres instances. Each branch gets its own connection string without duplicating data. This lets you have per-PR database branches, isolated test environments, and safe schema migration previews — all in under a second.

How do I connect to my Neon database after init?

Use the Neon extension, your assistant's Neon onboarding flow, or npx neonctl@latest connection-string to retrieve a connection string. Store it in your app environment yourself, and use pooled connections for serverless request handlers while keeping direct connections for migrations and long-running database tasks.

Is Neon free to use?

Neon has a Free plan, but limits and paid pricing can change. Treat the pricing page as the source of truth before committing a production architecture or writing a public pricing comparison.

Can I use neonctl in CI/CD pipelines?

Yes. Use neon auth --api-key $NEON_API_KEY for non-interactive authentication, then run any neonctl command. Common CI patterns include creating ephemeral branches per PR (neon branches create), running migrations, and deleting branches on PR close.

AE
AgentSkillsHub Editorial TeamAI Agent Infrastructure Reviewers

The AgentSkillsHub editorial team evaluates MCP servers, Claude skills, and AI agent integrations for security, reliability, and practical deployment readiness. Every listing undergoes permission audit, README analysis, and operational risk triage before publication.

  • Reviewed 450+ MCP server repositories
  • Developed security grading methodology (A-F)
  • Published agent deployment safety guidelines
Updated: 2026-05-29github