Add request timeouts + error handling, and the first tests - #1
Conversation
|
this got an approval a while back - anything else needed before it can go in? |
|
Thank you |
|
Thanks for the re-approval. Is anything blocking the merge on your side, or is it waiting for a window? Happy to rebase if it has gone stale. |
|
@mkzung , millonbigs-cpu goes around approving PRs for repositories he is not a contributor to. In some instances he would even delete replies and re-post them. I warned him several times about this behavior, and finally blocked him from fluentmigrator/fluentmigrator. His approving your PR means absolutely nothing to this repo, nor does mine. Only the maintainer does. |
|
Thanks, I had taken that approval at face value. Noted. The repo looks quiet since February, so I will leave this sitting rather than keep nudging. Still happy to rebase whenever a maintainer has a window. |
Problem
Every one of the 20 API calls in
mcp_server.pyusesrequests.get/post(...)with notimeoutand returnsres.json()with no status or JSON check, andcheck_apikey()raises a non-ToolErrorexception. In a stdio MCP server this means:auto_trace_address, whose own docstring says it may take up to 5 minutes); andToolErrorexceptions), so it never learns it was a bad key, a rate limit, or a bad address.Fix
_request()helper (with_get/_postwrappers) that always sets a timeout and raisesToolErrorwith an actionable message on timeout, transport error, non-JSON body, or an error status (the HTTP code, or the API's{"status": ..., "err_msg": ...}envelope). All 20 tools route through it;auto_trace_addressgets a longer read timeout.check_apikey()now raisesToolErrortoo, naming how to supply the key.hash(a parameter name) as a blockchain protocol, and drop the now-unused exception imports.No API or behavior change on the success path;
pytestis green.