Neon数据库
让你能够使用 Claude Desktop 或任何 MCP 客户端,通过自然语言来使用 [Neon](https://neon.tech/) 完成任务。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"Neon": {
"args": [
"-y",
"mcp-remote",
"https://mcp.neon.tech/mcp"
],
"command": "npx"
},
"neon": {
"args": [
"npx",
"-y",
"@neondatabase/mcp-server-neon",
"start",
"\u003cYOUR_NEON_API_KEY\u003e"
],
"command": "wsl"
}
}
}
该服务需要配置环境变量:NEON_API_KEY
服务介绍
Neon MCP 服务器
模型上下文协议 (MCP) 是一种 新的标准化协议,用于管理大型语言模型 (LLMs) 与外部系统之间的上下文。在这个仓库中,我们提供了一个安装程序以及一个适用于 Neon 的 MCP 服务器。
这使您可以使用 Claude Desktop 或任何其他 MCP 客户端通过自然语言来完成 Neon 中的任务,例如:
让我们创建一个新的 Postgres 数据库,并将其命名为 "my-database"。然后创建一个名为 users 的表,包含以下列:id, name, email 和 password。我想在我的项目 "my-project" 上运行一个迁移,修改 users 表以添加一个名为 "created_at" 的新列。你能给我总结一下我所有的 Neon 项目以及每个项目中的数据吗?
Claude 设置
通过 Smithery 安装
要通过 Smithery 自动为 Claude Desktop 安装 Neon MCP 服务器:
npx -y @smithery/cli install neon --client claude
要求
如何本地使用
- 运行
npx @neondatabase/mcp-server-neon init $NEON_API_KEY - 重启 Claude Desktop
- 现在你应该能够尝试一些简单的命令,比如
列出我所有的 Neon 项目
指南
- Neon MCP 服务器指南
- 将 MCP 客户端连接到 Neon
- 使用 Neon MCP 服务器的 Cursor
- 使用 Neon MCP 服务器的 Claude Desktop
- 使用 Neon MCP 服务器的 Cline
- 使用 Neon MCP 服务器的 Windsurf
功能
支持的工具
-
list_projects -
describe_project -
create_project -
delete_project -
create_branch -
delete_branch -
describe_branch -
get_connection_string -
run_sql -
run_sql_transaction -
get_database_tables -
describe_table_schema -
prepare_database_migration -
complete_database_migration -
provision_neon_auth
迁移
迁移是一种随着时间推移管理数据库模式更改的方法。通过 Neon MCP 服务器,LLMs 可以安全地进行迁移,具有单独的“开始”和“提交”命令。
"Start" 命令接受一个迁移并在一个新的临时分支中运行它。返回时,该命令提示 LLM 应该在这个分支上测试迁移。然后,LLM 可以运行 "Commit" 命令将迁移应用到原始分支。
开发
使用 MCP CLI 客户端进行开发
使用 mcp-client/ 是迭代 MCP 服务器最简单的方法。更多详情请参阅 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
使用 Claude 桌面版进行开发
npm install
npm run build
npm run watch # You can keep this open.
node dist/index.js init $NEON_API_KEY
然后,每次想要测试更改时都需要重启 Claude。
测试
要运行测试,你需要根据 .env.example 文件设置 .env 文件。
npm run test