Make MCP tool errors actionable and tolerate common agent arguments - #18
Merged
Merged
Conversation
A 48-hour audit of Papers With Code chat traffic showed the MCP tools failing in ways the model could not act on: - Every title lookup for a paper missing from the catalog surfaced as "upstream_error: the catalog request failed" because _rows treated an empty results list as a missing list ([] or ... is falsy). Empty search results now resolve to "not_found: Paper title not found". - DOI, publisher, and venue URLs paged through empty searches before failing; they now fail fast as "not_found: Paper URL not supported". - Numeric catalog IDs returned by list tools were passed to the Markdown route, which only knows arXiv papers by arXiv ID, so read_paper failed for 51 of 63 calls. Numeric IDs of arXiv papers now canonicalise to the arXiv ID, and a 404 for a paper that does not exist reports "Paper not found" instead of "no_markdown". - Read timeouts escaped the CLI transport as a bare TimeoutError, which the MCP server treated as an unexpected exception. Timeouts and socket errors are TransportErrors and map to upstream_timeout. - 400/422 upstream responses map to invalid_argument with the API's own bounded detail; 429 maps to rate_limited; the remaining generic path logs the exception class name (never the reference or query). - list_benchmarks accepted order_by=trending without task and area with search or task filters, both rejected by the CLI (25 failures). The tool now falls back (name ordering; filtered flat listing) and says so in its text summary. Grouped listings no longer forward page or limit. - get_benchmark rejected AP for mAP, top1 for Accuracy, AUROC for AUC (13 failures). Metric names resolve case-insensitively, by normalised spelling, and through a small alias table before the unknown-metric error, in the CLI and therefore also the MCP. - Not-found hints for tasks, benchmarks, and other entities rank the closest results by shared words instead of raw search order. - The read_paper identity check names the failure instead of the generic message. Bump pwc-cli to 0.4.2 and pwc-mcp to 0.2.2; regenerate the CLI SKILL.md, which had drifted from the parser. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Why
A 48-hour audit of Papers With Code production chat (2026-09-16 to 09-18) showed the MCP tools failing in ways the model could not act on, and burning its 12-call tool budget on retries. Per-tool failure rates:
read_paper51 of 63 calls,get_paper_info74 errors (48 of them generic),list_benchmarks25 argument rejections,get_benchmark13 metric-name rejections.Replaying the failing production inputs through
build_server(CatalogClient())in-process pinned each cause.Fixes
Catalog client (
pwc_mcp/catalog.py)_rowsusedpayload.get("results") or payload.get("items"), so an emptyresultslist read as a missing list and every title not in the catalog becameupstream_error: the Papers With Code catalog request failed. Empty results now resolve tonot_found: Paper title not found: ….not_found: Paper URL not supported …instead of paging through empty searches.papers/{id}call, because the Markdown route stores arXiv papers under the arXiv ID only. External papers keep their numeric ID.not_found: Paper not found: …instead ofno_markdown.Transport (
pwc_cli/transport.py)TimeoutErrorand other socket failures asOSError, which the MCP server treated as unexpected exceptions. Both areTransportErrornow; timeouts map toupstream_timeout.Server (
pwc_mcp/server.py)invalid_argument: <bounded, control-char-stripped API detail>; 429 →rate_limited; "timed out" recognised alongside "timeout". The remaining generic path logs only the exception class name.list_benchmarks:order_by=trendingwithouttaskfalls back to name ordering;areacombined with task/search/ordering filters is dropped in favour of the filtered flat listing; grouped listings no longer forwardpage/limit. Each fallback is stated in the text summary. Descriptions updated.read_paperidentity mismatch says "paper changed; restart reading from the beginning" instead of the generic message.CLI (
pwc_cli/cli.py)--sort,--min,--max,--require-metrics, and--paretoresolve case-insensitively, by normalised spelling (Top-1 Accuracy=Top 1 Accuracy), and through a small alias table (AP↔mAP,top1↔Accuracy,AUROC↔AUC,F1↔F1 score, …) before the unknown-metric error. The MCP inherits this.Versions: pwc-cli 0.4.1 → 0.4.2, pwc-mcp 0.2.1 → 0.2.2.
standalone_cli/SKILL.mdregenerated; it had drifted from the parser (page-size flag names, two--searchflags).Verification
Replay of the production inputs against the live API after the change: DOI/ACL URLs →
not_found;2308.10195→not_foundfor both info and read;read_paper("86122")resolves to2505.18132;get_benchmark("coco-val2017", sort_metric="AP:desc")and("kinetics-400", "top1:desc")succeed;list_benchmarks(order_by="trending")and(area, search)succeed with notes.Not fixed here (backend follow-up)
GET /api/v1/research/papers/2505.18132/readreturns 200, but the same route with?offset=0&limit=65536returns 404: chunk mode requires a_content/manifests/…file that older Markdown uploads never received.read_paperwill keep reportingno_markdownfor those papers until the backend either backfills manifests or lets chunk mode fall back to the plain object. Tracked in the paperswithcode repo.Release
sudo pwc-deploy staging <sha> --component mcp, exercise the four tools from a staging chat, thensudo pwc-deploy production <sha> --component mcp --confirm DEPLOY_PRODUCTION.🤖 Generated with Claude Code