MCP server by vgodwinamz
PostgreSQL Performance Insights MCP Server
A streamlined MCP server implementation that provides PostgreSQL performance analysis tools using the StreamableHTTP protocol.
Features
- Uses StreamableHTTP protocol instead of SSE
- Integrates with PostgreSQL Performance Insights
- Standalone implementation with no external MCP server dependencies
- Compatible with the MCP client protocol
Installation
- Install dependencies:
pip install -r requirements.txt
Usage
Start the server:
python server.py --port 8000 --host 0.0.0.0
Command-line options
--port
: Port to run the server on (default: 8000)--host
: Host to bind the server to (default: 0.0.0.0)--request-timeout
: Request timeout in seconds (default: 300)
Available Tools
The server provides tools for Aurora Performance Insights:
aurora_performance_insights
: Get Aurora Performance Insights dataaurora_slow_queries
: Get slow queries from Aurora Performance Insightshealth_check
: Check if the server is running properly
API Endpoints
/mcp
: Main endpoint for MCP communication (POST)/health
: Health check endpoint (GET)/sessions
: Show active sessions (GET)
StreamableHTTP Protocol
The StreamableHTTP protocol is a bidirectional communication protocol that uses HTTP requests for both client-to-server and server-to-client communication. Unlike SSE, which requires a persistent connection, StreamableHTTP uses standard HTTP requests and responses.
Client-to-Server Communication
Clients send JSON-RPC requests to the /mcp
endpoint:
{
"jsonrpc": "2.0",
"id": "request-id",
"method": "tool-name",
"params": {
"param1": "value1",
"param2": "value2"
}
}
Server-to-Client Communication
The server responds with JSON-RPC responses:
{
"jsonrpc": "2.0",
"id": "request-id",
"result": "result data"
}
Or error responses:
{
"jsonrpc": "2.0",
"id": "request-id",
"error": {
"code": -32603,
"message": "Internal error"
}
}
Session Management
Sessions are managed using the X-MCP-Session-ID
header. If not provided, a new session ID is generated. The session ID is returned in the response headers and should be included in subsequent requests to maintain the session.