semantic_scholar

Related papers (similar, references, citations) from Semantic Scholar.

arXiv itself has no similarity or citation data, so arxiv_related_papers asks the Semantic Scholar API, which indexes arXiv papers by their arXiv ID.

exception arxiv_query_mcp.semantic_scholar.PaperNotIndexedError[source]

Bases: Exception

Semantic Scholar has no record of the requested arXiv paper.

Fetch papers related to an arXiv paper from Semantic Scholar.

Parameters:
  • arxiv_id (str) – Version-less arXiv ID, e.g. '1706.03762'.

  • relation (Relation) – Which relation to fetch.

  • limit (int) – Maximum number of papers to return.

  • offset (int) – Pagination offset (references and citations only).

  • cfg (Config) – Server configuration (API URL, key, base URLs).

  • client (httpx.AsyncClient) – Shared async HTTP client.

  • cache (TwoTierCache | None) – Optional cache; results are cached like arXiv responses.

  • limiter (RateLimiter | None) – Optional Semantic Scholar rate limiter.

Returns:

(next_offset, papers). next_offset is None when there are no further pages.

Raises:
  • PaperNotIndexedError – Semantic Scholar does not know the paper.

  • httpx.HTTPStatusError – Semantic Scholar returned another error.

Return type:

tuple[int | None, list[dict[str, Any]]]

arxiv_query_mcp.semantic_scholar.related_error_message(exc, arxiv_id)[source]

Return a helpful message for a Semantic Scholar failure, if it is one.

Parameters:
  • exc (Exception) – The exception raised while fetching related papers.

  • arxiv_id (str) – The arXiv ID that was looked up.

Returns:

A message for the tool error, or None when exc is not specific to Semantic Scholar (the generic handler applies then).

Return type:

str | None

Render related papers as Markdown.

Parameters:
  • papers (list[dict[str, Any]]) – Records produced by _paper_record().

  • arxiv_id (str) – The paper the results relate to.

  • relation (Relation) – The relation that was fetched.

  • start (int) – Offset of the first result.

  • next_start (int | None) – Offset of the next page, or None.

Returns:

A Markdown list with one section per paper and a pagination hint.

Return type:

str