Skip to content

Use the public-metadata API for papers outside the catalog - #28

Merged
NielsRogge merged 1 commit into
mainfrom
claude/mcp-public-metadata
Oct 14, 2026
Merged

NielsRogge merged 1 commit into
mainfrom
claude/mcp-public-metadata

Conversation

@NielsRogge

Copy link
Copy Markdown
Collaborator

Do not merge yet. This depends on huggingface/paperswithcode#508 (GET /api/v1/papers/{identifier}/public-metadata), which is not live in production yet (curl https://paperswithcode.co/api/v1/papers/2610.18869/public-metadata → 404 as of 2026-10-14). If this ships first, uncatalogued papers fall back to the plain not-found error. This is the production chat's tool server, so merging or deploying needs explicit approval.

Why

PR #27 added client-side HF Papers / arXiv / Crossref lookups (external.py) for papers the catalog does not hold. The backend now serves the same data from one endpoint, which also returns labelled available_at links. This PR makes the MCP and the CLI use that endpoint. There is now one implementation, and both the agent and CLI users are told clearly that the paper is not indexed and where to read it.

MCP (pwc-mcp 0.2.7)

  • get_paper_info, read_paper, get_related_papers: same in_catalog=false outputs as before (data=None, the abstract as Markdown for reads, a search fallback plus note for related papers). New: an available_at list (label, url, kind). The note now tells the agent to link to those sources, not a PwC page.
  • If the endpoint maps the reference to a catalog paper (in_catalog=true), the tool retries with its arxiv_id, then catalog_id. If that still fails, the tool returns the original error rather than calling a catalogued paper "not indexed".
  • Identifiers are sent in the path with slashes kept, as the backend route expects ({identifier:path}). 400 (titles) and 404 are cached for 1 h as misses. 429/503 are not cached and fall back to the original error.
  • external.py and test_external.py are removed.
  • ⚠️ Behaviour change: the endpoint does not accept titles, so a title the catalog does not hold now returns the plain not-found error. Before, the MCP looked it up on HF/arXiv. arXiv IDs/URLs, HF URLs and DOIs work as before.

CLI (pwc-cli 0.4.6)

pwc paper info / pwc paper read on a 404 (or "Paper title not found") now print this to stderr, before the unchanged error:

Not indexed on Papers With Code — available at:
- arXiv abstract: https://arxiv.org/abs/2610.18869
- arXiv PDF: https://arxiv.org/pdf/2610.18869

title: What Matters in Quality-Aware VLA Pretraining: A Benchmark and Empirical Study
published: 2026-10-13
authors: …
metadata_source: arxiv

## Abstract
…

pwc: API request failed (404): {"detail":"Paper not found","code":"paper_not_in_catalog"}

Stdout stays empty and the exit codes are unchanged (3 for a 404, 4 for an unknown title), so scripts behave exactly as before. An arXiv or HF URL that the API maps to a catalog paper is now read from the catalog. The fallback lives in main(), so embedders that call the handlers (the MCP, via queries.query) never trigger it (covered by a test).

Before / after for arXiv 2610.18869

The "after" run used the real response from #508's service code (f80bc013) against live arXiv, passed to this branch's MCP. Production catalog calls were live.

before (0.2.6, client-side) after (0.2.7, endpoint)
in_catalog false false
note "This paper is not in the Papers With Code catalog; metadata comes from public arxiv records, so it has no catalog tasks, methods, evaluations, or curated code." "This paper is not indexed on Papers With Code, so there is no Papers With Code page, catalog tasks, methods, evaluations, or curated code for it; metadata comes from public arXiv records. Link to where it is available instead: arXiv abstract: https://arxiv.org/abs/2610.18869; arXiv PDF: https://arxiv.org/pdf/2610.18869."
available_at — [{label: "arXiv abstract", kind: "abstract", …}, {label: "arXiv PDF", kind: "pdf", …}]
read_paper markdown header + **Paper:**/**PDF:** lines + abstract header + ## Available at link list + abstract
get_related_papers same 2 search results + note same 2 search results + note pointing at available_at + available_at

Tests

  • uv run --project mcp_server pytest mcp_server/tests: 69 passed (endpoint client: path encoding and cached misses vs. transient errors; tool outputs with available_at; in-catalog retry; in-catalog-but-unreadable keeps the error)
  • uv run --project standalone_cli --with pytest pytest standalone_cli/tests: 99 passed (stderr block for info/read × text/json, title miss exit 4, unknown everywhere unchanged, URL→catalog retry, embedded queries skip the endpoint)
  • standalone_cli/scripts/check_contract.py ok; ruff shows no new findings vs. main

Before merging

  • #508 deployed. curl https://paperswithcode.co/api/v1/papers/2610.18869/public-metadata returns 200 with in_catalog: false
  • Re-run the live tool check against production
  • Explicit approval to release pwc-mcp 0.2.7 / pwc-cli 0.4.6

🤖 Generated with Claude Code

pwc-mcp's paper tools and pwc paper info/read now ask the Papers With Code
API's GET /papers/{identifier}/public-metadata endpoint (huggingface/
paperswithcode f80bc013) about a reference the catalog does not hold, so the
lookup has one implementation and both surfaces say where the paper lives.

MCP (0.2.7):
- get_paper_info, read_paper, and get_related_papers keep their
  in_catalog=false outputs (data=None, abstract-as-Markdown read, related
  search note) and add available_at: the endpoint's labelled links. The
  note now says the paper is not indexed on Papers With Code, has no PwC
  page, and lists the links to cite instead.
- A reference the endpoint maps to a catalog paper (an arXiv URL the
  catalog lookup missed, say) is retried by arXiv ID, then catalog ID; one
  that still misses keeps the original error instead of being shown as
  outside the catalog.
- Identifiers go in the path with slashes kept (DOIs, URLs); 400 (titles)
  and 404 are cached for an hour as misses, 429/503 are not cached.
- external.py (client-side HF Papers/arXiv/Crossref lookups) and its tests
  are removed. The endpoint does not take titles, so a title the catalog
  does not hold now keeps its plain not-found error.

CLI (0.4.6):
- On a 404 or "Paper title not found" from pwc paper info/read, stderr
  shows "Not indexed on Papers With Code — available at:" with the links,
  title, date, authors, source, and abstract before the unchanged error.
  Stdout and exit statuses (3 for 404, 4 for titles) are unchanged for
  scripts. An arXiv/HF URL the API maps to a catalog paper is read from
  the catalog. Embedders calling the handlers (the MCP) are unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NielsRogge

Copy link
Copy Markdown
Collaborator Author

Live check against production (2026-10-14). huggingface/paperswithcode#508 is deployed (b39aebba).

Endpoint:

  • /papers/2610.18869/public-metadata → 200, in_catalog: false, source arxiv, available_at = arXiv abstract + arXiv PDF
  • /papers/https://arxiv.org/abs/1706.03762v7/public-metadata → 200, in_catalog: true, catalog_id 755
  • 2610.99999 → 404 paper_not_found; a title → 400 invalid_paper_identifier

MCP (this branch, in-process, against production) for 2610.18869:

  • get_paper_info → in_catalog: false, new note, available_at [arXiv abstract, arXiv PDF]
  • read_paper → abstract Markdown with an "Available at" list
  • get_related_papers → search fallback, with note + available_at

The output is identical to the "after" column in the description.

CLI (this branch):

  • pwc paper info 2610.18869 and pwc paper read 2610.18869 --json: stdout empty, exit 3, "Not indexed on Papers With Code — available at: …" block, then the original 404 on stderr
  • pwc paper info https://arxiv.org/abs/1706.03762v7: exit 0 with the catalog record. Before this PR it failed as "Paper title not found".
  • pwc paper info 2610.99999: unchanged plain 404, exit 3

Still needed before merge: explicit approval to merge and release pwc-mcp 0.2.7 / pwc-cli 0.4.6.

@NielsRogge
NielsRogge merged commit a2fc9d0 into main Oct 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant