霓虹Mcp服务器
概览
什么是 MCP Server Neon?
MCP Server Neon 是一个强大的服务器,旨在与 Neon 管理 API 进行交互并管理数据库。它为开发人员提供了一种无缝连接、管理和操作存储在 Neon 数据库中的数据的方法。这个服务器特别适用于需要强大数据库管理功能的应用程序,允许高效的数据处理和检索。
MCP Server Neon 的特点
- API 集成:MCP Server Neon 提供与 Neon 管理 API 的轻松集成,使开发人员能够轻松执行各种数据库操作。
- 数据库管理:它提供管理数据库的工具,包括创建、更新和删除记录。
- 用户友好的界面:该服务器配备了用户友好的界面,简化了数据库交互,使新手和经验丰富的开发人员都能轻松使用。
- 开源:作为一个开源项目,MCP Server Neon 允许开发人员为其开发做出贡献,并根据自己的需求进行定制。
- 活跃的社区支持:该项目得到了一个活跃社区的支持,确保用户能够轻松找到帮助和资源。
如何使用 MCP Server Neon
- 安装:首先从 GitHub 克隆 MCP Server Neon 仓库。您可以使用以下命令进行操作:
git clone https://github.com/neondatabase-labs/mcp-server-neon.git
- 配置:克隆后,根据您的数据库需求配置服务器设置。这可能涉及设置环境变量或配置文件。
- 运行服务器:使用以下命令启动服务器:
确保所有依赖项已安装,并且服务器已正确配置。npm start
- 与 API 交互:使用提供的 API 端点与您的 Neon 数据库进行交互。您可以执行 CRUD 操作并有效管理您的数据。
- 社区贡献:如果您希望为该项目做出贡献,请遵循仓库中提供的贡献指南。
常见问题解答
Q1: MCP Server Neon 是免费使用的吗?
A1: 是的,MCP Server Neon 是一个开源项目,可以免费使用。
Q2: 我可以为 MCP Server Neon 项目做贡献吗?
A2: 当然可以!欢迎贡献。您可以在 GitHub 仓库中提交问题、功能请求或拉取请求。
Q3: MCP Server Neon 使用了哪些编程语言?
A3: 该服务器主要使用 JavaScript 和 Node.js 构建,使其对网页开发人员友好。
Q4: 我该如何报告问题或错误?
A4: 您可以通过在 GitHub 仓库中打开一个问题来报告问题。请确保提供有关问题的详细信息。
Q5: 我在哪里可以找到 MCP Server Neon 的文档?
A5: 文档通常在仓库的 README 文件或专门的 docs 文件夹中提供。请查看仓库以获取更多详细信息。
详情
Neon MCP Server
Neon MCP Server is an open-source tool that lets you interact with your Neon Postgres databases in natural language.
The Model Context Protocol (MCP) is a new, standardized protocol designed to manage context between large language models (LLMs) and external systems. This repository offers an installer and an MCP Server for Neon.
Neon's MCP server acts as a bridge between natural language requests and the Neon API. Built upon MCP, it translates your requests into the necessary API calls, enabling you to manage tasks such as creating projects and branches, running queries, and performing database migrations seamlessly.
Some of the key features of the Neon MCP server include:
- Natural language interaction: Manage Neon databases using intuitive, conversational commands.
- Simplified database management: Perform complex actions without writing SQL or directly using the Neon API.
- Accessibility for non-developers: Empower users with varying technical backgrounds to interact with Neon databases.
- Database migration support: Leverage Neon's branching capabilities for database schema changes initiated via natural language.
For example, in Claude Desktop, or any MCP Client, you can use natural language to accomplish things with Neon, such as:
Let's create a new Postgres database, and call it "my-database". Let's then create a table called users with the following columns: id, name, email, and password.
I want to run a migration on my project called "my-project" that alters the users table to add a new column called "created_at".
Can you give me a summary of all of my Neon projects and what data is in each one?
[!NOTE]
The Neon MCP server grants powerful database management capabilities through natural language requests. Always review and authorize actions requested by the LLM before execution. Ensure that only authorized users and applications have access to the Neon MCP server and Neon API keys.
Setting up Neon MCP Server
You have two options for connecting your MCP client to Neon:
-
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. Additionally, you will automatically receive the latest features and improvements as soon as they are released.
-
Local MCP Server: Run the Neon MCP server locally on your machine, authenticating with a Neon API key.
Prerequisites
- An MCP Client application.
- A Neon account.
- Node.js (>= v18.0.0) and npm: Download from nodejs.org.
For Local MCP Server setup, you also need a Neon API key. See Neon API Keys documentation for instructions on generating one.
Option 1. Remote Hosted MCP Server (Preview)
Connect to Neon's managed MCP server using OAuth for authentication. This is the easiest setup, requires no local installation of this server, and doesn't need a Neon API key configured in the client.
-
Add the following "Neon" entry to your client's MCP server configuration file (e.g.,
mcp.json
,mcp_config.json
):{ "mcpServers": { "Neon": { "command": "npx", "args": ["-y", "mcp-remote", "https://mcp.neon.tech/sse"] } } }
-
Save the configuration file.
-
Restart or refresh your MCP client.
-
An OAuth window will open in your browser. Follow the prompts to authorize your MCP client to access your Neon account.
Option 2. Local MCP Server
Run the Neon MCP server on your local machine.
Setup via Smithery:
npx -y @smithery/cli@latest install neon --client <client_name>
You will be prompted to enter your Neon API key. Enter the API key which you obtained from the prerequisites section
Replace <client_name>
with the name of your MCP client application. Supported client names include:
claude
for Claude Desktopcursor
for Cursor (Installing viasmithery
makes the MCP server a global MCP server in Cursor)windsurf
for Windsurf Editorroo-cline
for Roo Cline VS Code extensionwitsy
for Witsyenconvo
for Enconvovscode
for Visual Studio Code
Restart your MCP client after installation.
Setup via npm
If your MCP client is not listed here, you can manually add the Neon MCP Server details to your client's mcp_config
file.
Add the following JSON configuration within the mcpServers
section of your client's mcp_config
file, replacing <YOUR_NEON_API_KEY>
with your actual Neon API key:
{
"mcpServers": {
"neon": {
"command": "npx",
"args": [
"-y",
"@neondatabase/mcp-server-neon",
"start",
"<YOUR_NEON_API_KEY>"
]
}
}
}
Troubleshooting
If your client does not use JSON
for configuration of MCP servers (such as older versions of Cursor), you can use the following command when prompted:
npx -y @neondatabase/mcp-server-neon start <YOUR_NEON_API_KEY>
Troubleshooting on Windows
If you are using Windows and encounter issues while adding the MCP server, you might need to use the Command Prompt (cmd
) or Windows Subsystem for Linux (wsl
) to run the necessary commands. Your configuration setup may resemble the following:
{
"mcpServers": {
"neon": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"@neondatabase/mcp-server-neon",
"start",
"<YOUR_NEON_API_KEY>"
]
}
}
}
{
"mcpServers": {
"neon": {
"command": "wsl",
"args": [
"npx",
"-y",
"@neondatabase/mcp-server-neon",
"start",
"<YOUR_NEON_API_KEY>"
]
}
}
}
Guides
- Neon MCP Server Guide
- Connect MCP Clients to Neon
- Cursor with Neon MCP Server
- Claude Desktop with Neon MCP Server
- Cline with Neon MCP Server
- Windsurf with Neon MCP Server
- Zed with Neon MCP Server
Features
Supported Tools
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:
list_projects
: Lists the first 10 Neon projects in your account, providing a summary of each project. If you can't find a specific project, increase the limit by passing a higher value to thelimit
parameter.describe_project
: Fetches detailed information about a specific Neon project, including its ID, name, and associated branches and databases.create_project
: Creates a new Neon project in your Neon account. A project acts as a container for branches, databases, roles, and computes.delete_project
: Deletes an existing Neon project and all its associated resources.
Branch Management:
create_branch
: Creates a new branch within a specified Neon project. Leverages Neon's branching feature for development, testing, or migrations.delete_branch
: Deletes an existing branch from a Neon project.describe_branch
: Retrieves details about a specific branch, such as its name, ID, and parent branch.list_branch_computes
: Lists compute endpoints for a project or specific branch, including compute ID, type, size, and autoscaling information.
SQL Query Execution:
get_connection_string
: Returns your database connection string.run_sql
: Executes a single SQL query against a specified Neon database. Supports both read and write operations.run_sql_transaction
: Executes a series of SQL queries within a single transaction against a Neon database.get_database_tables
: Lists all tables within a specified Neon database.describe_table_schema
: Retrieves the schema definition of a specific table, detailing columns, data types, and constraints.list_slow_queries
: Identifies performance bottlenecks by finding the slowest queries in a database. Requires the pg_stat_statements extension.
Database Migrations (Schema Changes):
prepare_database_migration
: Initiates a database migration process. Critically, it creates a temporary branch to apply and test the migration safely before affecting the main branch.complete_database_migration
: Finalizes and applies a prepared database migration to the main branch. This action merges changes from the temporary migration branch and cleans up temporary resources.
Query Performance Optimization:
explain_sql_statement
: Provides detailed execution plans for SQL queries to help identify performance bottlenecks.prepare_query_tuning
: Analyzes query performance and suggests optimizations like index creation. Creates a temporary branch for safely testing these optimizations.complete_query_tuning
: Applies or discards query optimizations after testing. Can merge changes from the temporary branch to the main branch.list_slow_queries
: Identifies and analyzes slow-performing queries in your database. Requires thepg_stat_statements
extension.
Compute Management:
list_branch_computes
: Lists compute endpoints for a project or specific branch, showing details like compute ID, type, size, and last active time.
Neon Auth:
-
provision_neon_auth
: Provisions Neon Auth for a Neon project. It allows developers to easily set up authentication infrastructure by creating an integration with Stack Auth (@stackframe/stack
).Query Performance Tuning:
-
explain_sql_statement
: Analyzes a SQL query and returns detailed execution plan information to help understand query performance. -
prepare_query_tuning
: Identifies potential performance issues in a SQL query and suggests optimizations. Creates a temporary branch for testing improvements. -
complete_query_tuning
: Finalizes and applies query optimizations after testing. Merges changes from the temporary tuning branch to the main branch.
Neon Auth:
provision_neon_auth
: Action to provision Neon Auth for a Neon project. It allows developers to easily setup authentication infrastructure by creating a integration with Stack Auth (@stackframe/stack
).
Migrations
Migrations are a way to manage changes to your database schema over time. With the Neon MCP server, LLMs are empowered to do migrations safely with separate "Start" (prepare_database_migration
) and "Commit" (complete_database_migration
) commands.
The "Start" command accepts a migration and runs it in a new temporary branch. Upon returning, this command hints to the LLM that it should test the migration on this branch. The LLM can then run the "Commit" command to apply the migration to the original branch.
Development
Development with MCP CLI Client
The easiest way to iterate on the MCP Server is using the mcp-client/
. Learn more in mcp-client/README.md
.
npm install
npm run build
npm run watch # You can keep this open.
cd mcp-client/ && NEON_API_KEY=... npm run start:mcp-server-neon
Development with Claude Desktop (Local MCP Server)
npm install
npm run build
npm run watch # You can keep this open.
node dist/index.js init $NEON_API_KEY
Then, restart Claude each time you want to test changes.
Testing
To run the tests you need to setup the .env
file according to the .env.example
file.
npm run test
Server配置
{
"mcpServers": {
"mcp-server-neon": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/metorial/mcp-container--neondatabase--mcp-server-neon--mcp-server-neon",
"bun run start {{NEON_API_KEY}}"
],
"env": {}
}
}
}