Get started with Claude Desktop and Neon MCP Server (original) (raw)

Imagine managing your database with natural language. Instead of complex SQL, you can simply ask your AI assistant to "create a new table for customer orders" or "show me last quarter's sales figures." This is the power of the Model Context Protocol (MCP), an open standard for AI interaction with external systems.

This guide will introduce you to Neon's MCP server, which allows you to use Large Language Models (LLMs) for intuitive database management. At its core, Neon MCP server allows tools like Claude to easily communicate with the Neon API.

With Neon's MCP server and an LLM like Claude, you can simplify workflows, improve productivity, and manage your Postgres databases more naturally. Let’s explore how this approach can make database management easier and more efficient.

The Model Context Protocol (MCP) is a standard that helps LLMs communicate with external tools, like databases and APIs. It's like a translator, making it easier to connect LLMs to services and data. For the Neon MCP server, it's the protocol that lets Claude (and other LLMs) understand and control your Neon databases through the Neon API.

MCP follows a client-server architecture, where a host application can connect to multiple servers. The key components include:

Traditionally, connecting AI models to different data sources required developers to create custom code for each integration. This fragmented approach led to increased development time, maintenance burdens, and limited interoperability between AI models and tools. MCP tackles this challenge by providing a standardized protocol that simplifies integration, accelerates development, and enhances the capabilities of AI assistants.

Neon's MCP server is an open-source tool that lets LLMs like Claude manage your Neon databases using natural language by interacting with the Neon API. It translates your simple English instructions into Neon API calls.

Examples of natural language commands that are converted to Neon API actions:

Neon MCP server, combined with Neon, offers:

warning

The Neon MCP server's ability to execute arbitrary commands from natural language requests requires careful attention to security. Always review and approve actions before they are committed. Grant access only to authorized users and applications.

The Neon MCP Server provides the following actions, which are exposed as "tools" to MCP Clients. You can use these tools to interact with your Neon projects and databases using natural language commands.

Project management:

Branch management:

SQL query execution:

Database migrations (schema changes):

Query performance tuning:

Neon Auth:

These actions enable any MCP Host to interact with various functionalities of the Neon platform via the Neon API. Certain tools, especially database migration ones, are tailored for AI agent and LLM usage, leveraging Neon’s branching for safe preview and commit.

We'll use Claude Desktop to interact with Neon MCP server. Here's how to set it up:

You have two options for connecting Claude to the Neon MCP Server:

  1. Remote MCP Server (Preview): Connect to Neon's managed MCP server using OAuth for authentication. This method is more convenient as it eliminates the need to manage API keys in Claude. Additionally, you will automatically receive the latest features and improvements as soon as they are released.
  2. Local MCP Server: Run the Neon MCP server locally on your machine, authenticating with a Neon API key.
  3. Open Claude desktop and navigate to Settings.Claude settings
  4. Under the Developer tab, click Edit Config (On Windows, it's under File -> Settings -> Developer -> Edit Config) to open the location of configuration file (claude_desktop_config.json).Claude config
  5. Open the claude_desktop_config.json file in a text editor of your choice.
  6. Add the "Neon" server entry within the mcpServers object:
{  
  "mcpServers": {  
    "Neon": {  
      "command": "npx",  
      "args": ["-y", "mcp-remote", "https://mcp.neon.tech/sse"]  
    }  
  }  
}  
  1. Save the configuration file and restart Claude Desktop.
  2. An OAuth window will open in your browser. Follow the prompts to authorize Claude to access your Neon account.Neon OAuth window
  3. After authorization, you can start using the Neon MCP server with Claude.

note

The remote hosted MCP server is in preview due to the new OAuth MCP specification, expect potential changes as we continue to refine the OAuth integration.

This method runs the Neon MCP server locally on your machine, using a Neon API key for authentication.

  1. Open your terminal.
  2. Run the following command to install the Neon MCP server. This command uses the @smithery/cli package to install the Neon MCP server and configure it for use with Claude.
npx -y @smithery/cli@latest install neon --client claude  

You will be prompted to enter your Neon API key during the installation process. You can enter the API key which you obtained from the prerequisites section. You should see output similar to this:

npx -y @smithery/cli@latest install neon --client claude  
✔ Successfully resolved neon  
Installing remote server. Please ensure you trust the server author, especially when sharing sensitive data.  
For information on Smithery's data policy, please visit: https://smithery.ai/docs/data-policy  
? The API key for accessing the Neon. You can generate one through the Neon  
console. (required)  
*********************************************************************  
neon successfully installed for claude  
  1. Restart Claude Desktop. You can do so by quitting the Claude Desktop and opening it again.

You can verify that the connection to the Neon MCP server either remote or local is successful by following these steps:

  1. In Claude hover over the 🔨 icon to see the available tools.Claude available tools
  2. Click on the icon to see the list of available tools in detail. You should see the Neon MCP server's tools listed.Claude list available tools
  3. Claude is now connected to Neon's remote MCP server.

Ask Claude "List my Neon projects". If it works, you'll see your projects listed by Claude, fetched using the Neon API. For example, you might see output similar to this:

Claude output

Neon MCP server lets you manage Neon via Neon API calls

Imagine you want to add a column to a table in your Neon project. Instead of writing SQL migrations and directly calling the Neon API, with Neon MCP server and Claude, you can say: "In my social network Neon project, edit the posts table and add a deleted_at column."

Using Neon MCP server, Claude will:

  1. Confirm project: Check which project you are referring to.
  2. Check schema: Look at the posts table structure.
  3. Make migration: Create the SQL to add the column
  4. Preview changes: Show you the changes in a safe, temporary branch leveraging Neon's branching feature.
  5. Apply changes: After you approve, apply the change to your database.
  6. Confirm success: Tell you the column is added and prompt you to commit the migration.

This shows how Neon MCP server simplifies and makes database management safer with natural language, all powered by the Neon API under the hood.

Neon MCP server can be used in various scenarios. Here are just a few possibilities:

When Claude uses the Neon MCP tool, you'll see an authorization prompt: "Allow tool from "neon"?"

Claude output

For your security, review the tool's purpose before permitting the operation to proceed. Remember that LLMs can sometimes produce unexpected results, so careful monitoring is always recommended.

Neon MCP server makes database management conversational and easier by enabling natural language interaction with the Neon API. It simplifies tasks, automates processes, and opens new ways to use AI with databases.

Join our Discord Server to ask questions or see what others are doing with Neon. Users on paid plans can open a support ticket from the console. For more details, see Getting Support.