Neon MCP server

Manage Neon's serverless Postgres databases.
Back to servers
Setup instructions
Provider
Neon
Release date
Nov 29, 2024
Language
TypeScript
Stats
528 stars

Neon MCP Server provides a natural language interface to your Neon Postgres databases, allowing you to manage your databases with conversational commands instead of SQL or API calls. This server implements the Model Context Protocol (MCP), acting as a bridge between language models and Neon's database infrastructure.

Installation Options

Option 1: Remote Hosted MCP Server (Preview)

This is the easiest setup method, requiring no local installation and using OAuth for authentication.

  1. Add the following configuration to your MCP client's configuration file:
{
  "mcpServers": {
    "Neon": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://mcp.neon.tech/mcp"]
    }
  }
}
  1. Restart or refresh your MCP client
  2. Complete the OAuth flow in your browser to authorize access to your Neon account

When using OAuth authentication, the server will operate on projects under your personal account by default. To access projects under an organization, you must specify either the org_id or project_id in your prompts.

Quick Setup with API Key

You can use the neonctl utility to automatically configure the MCP server:

npx neonctl@latest init

This command works with Cursor, VS Code (GitHub Copilot), and Claude Code, handling OAuth authentication, API key creation, and editor configuration automatically.

Manual API Key Setup

For other IDEs or manual configuration, create a Neon API key through the Neon Console and use this configuration:

{
  "mcpServers": {
    "Neon": {
      "url": "https://mcp.neon.tech/mcp",
      "headers": {
        "Authorization": "Bearer <$NEON_API_KEY>"
      }
    }
  }
}

For read-only mode (preventing modifications), add the x-read-only header:

{
  "mcpServers": {
    "Neon": {
      "url": "https://mcp.neon.tech/mcp",
      "headers": {
        "Authorization": "Bearer <$NEON_API_KEY>",
        "x-read-only": "true"
      }
    }
  }
}

Option 2: Local MCP Server

Run the MCP server locally with your Neon API key:

  1. First, ensure you have:

    • Node.js (v18.0.0+) and npm
    • A Neon account
    • A Neon API key
  2. Add this configuration to your client's MCP configuration file:

{
  "mcpServers": {
    "neon": {
      "command": "npx",
      "args": [
        "-y",
        "@neondatabase/mcp-server-neon",
        "start",
        "<YOUR_NEON_API_KEY>"
      ]
    }
  }
}

Troubleshooting

If your client doesn't use JSON configuration, you can use this command when prompted:

npx -y @neondatabase/mcp-server-neon start <YOUR_NEON_API_KEY>

Windows-Specific Troubleshooting

For Windows users experiencing issues, try using Command Prompt:

{
  "mcpServers": {
    "neon": {
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "@neondatabase/mcp-server-neon",
        "start",
        "<YOUR_NEON_API_KEY>"
      ]
    }
  }
}

Or Windows Subsystem for Linux:

{
  "mcpServers": {
    "neon": {
      "command": "wsl",
      "args": [
        "npx",
        "-y",
        "@neondatabase/mcp-server-neon",
        "start",
        "<YOUR_NEON_API_KEY>"
      ]
    }
  }
}

Features and Usage

Project Management

  • List your Neon projects: "Show me all my Neon projects"
  • Get project details: "Describe my project called 'my-app'"
  • Create a new project: "Create a new Neon project named 'analytics-db'"
  • Delete a project: "Delete the project 'test-project'"
  • List organizations: "Show me all organizations I have access to"

Branch Management

  • Create a branch: "Create a new branch called 'dev' in my 'production-app' project"
  • Delete a branch: "Delete the 'test' branch from my project"
  • Get branch details: "Tell me about the 'staging' branch in my project"
  • List compute endpoints: "List all compute resources for my project"
  • Compare schemas: "Compare the schema between my 'dev' branch and its parent"

SQL Query Execution

  • Get connection string: "What's the connection string for my database?"
  • Run SQL queries: "Run 'SELECT * FROM users LIMIT 10' on my database"
  • Execute transactions: "Run a transaction that inserts data into both the customers and orders tables"
  • List tables: "What tables exist in my 'analytics' database?"
  • Describe table structure: "Show me the schema for the 'users' table"

Database Migrations

  • Prepare a migration: "I need to add a 'last_login' timestamp column to my users table"
  • Complete a migration: "Apply the migration we just prepared to the main branch"

Query Optimization

  • Find slow queries: "Show me the slowest queries in my database"
  • Explain query plans: "Explain the execution plan for 'SELECT * FROM users WHERE email LIKE '%gmail.com'"
  • Optimize queries: "Help me optimize my query that's running slowly"

Security Considerations

Always review actions before execution, as the MCP server can perform powerful operations that could lead to data loss if misused. The Neon MCP Server is intended for development and IDE integrations, not production environments.

For more detailed information, visit Neon's MCP Server Guide.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "Neon" '{"command":"npx","args":["-y","mcp-remote","https://mcp.neon.tech/sse"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "Neon": {
            "command": "npx",
            "args": [
                "-y",
                "mcp-remote",
                "https://mcp.neon.tech/sse"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "Neon": {
            "command": "npx",
            "args": [
                "-y",
                "mcp-remote",
                "https://mcp.neon.tech/sse"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later