postgresql mcp server
Facilitates management and optimization of PostgreSQL databases, offering analysis, setup guidance, and debugging, while ensuring secure and efficient database operations.
Facilitates management and optimization of PostgreSQL databases, offering analysis, setup guidance, and debugging, while ensuring secure and efficient database operations.
A Model Context Protocol (MCP) server that provides PostgreSQL database management capabilities. This server assists with analyzing existing PostgreSQL setups, providing implementation guidance, and debugging database issues.
analyze_database
)Analyzes PostgreSQL database configuration and performance metrics: - Configuration analysis - Performance metrics - Security assessment - Recommendations for optimization
// Example usage
{
"connectionString": "postgresql://user:password@localhost:5432/dbname",
"analysisType": "performance" // Optional: "configuration" | "performance" | "security"
}
get_setup_instructions
)Provides step-by-step PostgreSQL installation and configuration guidance: - Platform-specific installation steps - Configuration recommendations - Security best practices - Post-installation tasks
// Example usage
{
"platform": "linux", // Required: "linux" | "macos" | "windows"
"version": "15", // Optional: PostgreSQL version
"useCase": "production" // Optional: "development" | "production"
}
debug_database
)Debug common PostgreSQL issues: - Connection problems - Performance bottlenecks - Lock conflicts - Replication status
// Example usage
{
"connectionString": "postgresql://user:password@localhost:5432/dbname",
"issue": "performance", // Required: "connection" | "performance" | "locks" | "replication"
"logLevel": "debug" // Optional: "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": []
}
}
}
npm run dev
- Start development server with hot reloadnpm run lint
- Run ESLintnpm test
- Run testsSupports SSL/TLS connections
Query Safety
Logs all operations
Authentication
The server implements comprehensive error handling: - Connection failures - Query timeouts - Authentication errors - Permission issues - Resource constraints
This project is licensed under the AGPLv3 License - see LICENSE file for details.
[
{
"description": "Analyze PostgreSQL database configuration and performance",
"inputSchema": {
"properties": {
"analysisType": {
"description": "Type of analysis to perform",
"enum": [
"configuration",
"performance",
"security"
],
"type": "string"
},
"connectionString": {
"description": "PostgreSQL connection string",
"type": "string"
}
},
"required": [
"connectionString"
],
"type": "object"
},
"name": "analyze_database"
},
{
"description": "Get step-by-step PostgreSQL setup instructions",
"inputSchema": {
"properties": {
"platform": {
"description": "Operating system platform",
"enum": [
"linux",
"macos",
"windows"
],
"type": "string"
},
"useCase": {
"description": "Intended use case",
"enum": [
"development",
"production"
],
"type": "string"
},
"version": {
"description": "PostgreSQL version to install",
"type": "string"
}
},
"required": [
"platform"
],
"type": "object"
},
"name": "get_setup_instructions"
},
{
"description": "Debug common PostgreSQL issues",
"inputSchema": {
"properties": {
"connectionString": {
"description": "PostgreSQL connection string",
"type": "string"
},
"issue": {
"description": "Type of issue to debug",
"enum": [
"connection",
"performance",
"locks",
"replication"
],
"type": "string"
},
"logLevel": {
"default": "info",
"description": "Logging detail level",
"enum": [
"info",
"debug",
"trace"
],
"type": "string"
}
},
"required": [
"connectionString",
"issue"
],
"type": "object"
},
"name": "debug_database"
}
]