PostgreSQL MCP 服务器基于 Model Context Protocol (MCP) 构建,为 PostgreSQL 数据库提供专业的管理功能。它能够深入分析现有 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"
}
npm install
npm run build
{
"mcpServers": {
"postgresql-mcp": {
"command": "node",
"args": ["/path/to/postgresql-mcp-server/build/index.js"],
"disabled": false,
"alwaysAllow": []
}
}
}
// 数据库分析示例
{
"connectionString": "postgresql://user:password@localhost:5432/dbname",
"analysisType": "performance"
}
// 安装说明示例
{
"platform": "linux",
"version": "15",
"useCase": "production"
}
// 数据库调试示例
{
"connectionString": "postgresql://user:password@localhost:5432/dbname",
"issue": "performance",
"logLevel": "debug"
}
npm run dev
:启动开发服务器并带有热重载功能。npm run lint
:运行 ESLint 进行代码检查。npm test
:运行测试。服务器实现了全面的错误处理机制,可应对以下情况:
本项目根据 AGPLv3 许可证发布 - 有关详细信息,请参阅 LICENSE 文件。