fix(mcp): add retry + separated timeouts to FastAPI MCP _api_get (BUY-60518) - #16
Open
BuyWhere wants to merge 3 commits into
Open
fix(mcp): add retry + separated timeouts to FastAPI MCP _api_get (BUY-60518)#16BuyWhere wants to merge 3 commits into
BuyWhere wants to merge 3 commits into
Conversation
…-60518) The MCP HTTP endpoint's _api_get used a bare timeout=10.0 with no retry. When the 154M-row products table hits statement_timeout contention, the single-attempt HTTP call fails immediately. Changes: - 3-attempt retry with exponential backoff on timeout/transport errors - Separated httpx.Timeout: connect scales with attempt, read=25s (configurable), write=10s, pool=5s - BUYWHERE_API_TIMEOUT env var (default 25s) for read timeout tuning - BUYWHERE_API_URL env var for base URL (consistent with mcp_server.py) - aligns with the retry pattern already in mcp_server.py Also includes the country_code passthrough for get_deals tool.
…518)" This reverts commit 143d00c.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The MCP HTTP endpoint's in used a bare with no retry logic. When the 154M-row products table hits contention, the single-attempt HTTP call fails immediately, surfacing as -32603 errors in MCP tool calls.
Changes
Why 25s read timeout?
Backend DB queries carry (8s). A 25s HTTP read timeout gives the backend query + connection overhead ample room while still failing fast enough for MCP UX. The retry mechanism handles transient contention pulses.
Testing
Deployment
Merge → CI deploys to Cloud Run. Set env var on the service if not already inherited.