-
Notifications
You must be signed in to change notification settings - Fork 168
Open
Description
postgres-mcp doesn't properly manage database connection pools when using SSE (Server-Sent Events) transport.
Here's what happens:
- New pool per connection: Each time an MCP client connects via SSE, postgres-mcp creates a new database connection pool (pool-1, pool-2, pool-47, etc.)
- Pools get closed: After handling a request, the pool is closed but the reference remains
- Stale pool references: Subsequent requests try to use these closed pools, resulting in the error "the pool 'pool-47' is closed"
- No pool reuse: Instead of reusing a single connection pool across all SSE sessions, it creates new ones and doesn't clean up properly
This is a design flaw in how postgres-mcp handles SSE connections. The SSE transport is meant for long-lived connections, but postgres-mcp treats each request as isolated, creating this pool management issue.
Evidence from the logs:
ERROR Error executing query: Connection server.py:401
attempt failed: the pool 'pool-49' is
closed
ERROR Error executing query: Connection server.py:401
attempt failed: the pool 'pool-55' is
closed
The incrementing pool numbers (pool-49, pool-55, pool-67) show that new pools keep being created instead of reusing existing ones.
fathiraz, 0x7o, adamma1024, ChristophorusReyhan, matt-zaqa-ai and 1 more
Metadata
Metadata
Assignees
Labels
No labels