Debugging silent Postgres connection pool exhaustion when 15 parallel MCP tool calls fire at once
Had a fun production surprise yesterday. A user asked our assistant to compare metrics across 15 different customer workspaces, so the model emitted 15 parallel MCP tool calls in a single turn.
Each MCP call hit our FastAPI backend, which uses SQLAlchemy with pool_size=5, max_overflow=10. By the time the 16th call arrived (plus a couple of normal web requests), connections started timing out with QueuePool limit of size 5 overflow 10 reached.
Worse: the agent saw the 500 error, assumed it was a transient hiccup, and fired all 15 calls again.
Apart from just cranking up max_overflow until Postgres complains about max_connections, how are people throttling parallel tool fan-out on the MCP server or API side?