PostgreSQL MCP 服务器是一个基于 Model Context Protocol (MCP) 的服务器,它提供了强大的 PostgreSQL 数据库管理功能。该服务器能够分析现有的 PostgreSQL 设置,为用户提供实现指导,还能对数据库问题进行调试,极大地提升了数据库管理的效率和便捷性。
PostgreSQL MCP 服务器提供了一系列强大的功能,帮助你更好地管理和维护 PostgreSQL 数据库。在使用之前,请确保满足相应的先决条件,并按照安装步骤进行操作。
analyze_database
)该功能可对 PostgreSQL 数据库的配置和性能指标进行全面分析,具体包括:
// 示例用法
{
"connectionString": "postgresql://user:password@localhost:5432/dbname",
"analysisType": "performance" // 可选: "configuration" | "performance" | "security"
}
get_setup_instructions
)提供 PostgreSQL 安装和配置的详细分步指导,涵盖:
// 示例用法
{
"platform": "linux", // 必填: "linux" | "macos" | "windows"
"version": "15", // 可选:PostgreSQL 版本
"useCase": "production" // 可选: "development" | "production"
}
debug_database
)用于调试常见的 PostgreSQL 问题,如:
// 示例用法
{
"connectionString": "postgresql://user:password@localhost:5432/dbname",
"issue": "performance", // 必填: "connection" | "performance" | "locks" | "replication"
"logLevel": "debug" // 可选: "info" | "debug" | "trace"
}
要通过 Smithery 自动安装,可执行以下命令:
npm install -g @nahmanmate/postgresql-mcp-server
克隆仓库并运行以下命令:
git clone https://github.com/nahmanmate/postgresql-mcp-server.git
cd postgresql-mcp-server
npm install
npm start
try {
const result = await postgresqlMCPService.analyzeDatabase({
connectionString: "postgresql://user:password@localhost:5432/dbname",
analysisType: "performance"
});
console.log(result);
} catch (error) {
console.error("发生错误:", error.message);
}
在开发环境中使用:
git clone https://github.com/nahmanmate/postgresql-mcp-server.git
cd postgresql-mcp-server
npm install
npm run dev
MIT License
Copyright (c) 2024 nahmanmate
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
如果你想为该项目贡献代码,请先 fork 仓库,然后在主分支上提交你的更改。