@mcp.tool()
async def get_paper_references(
paper_id: str, limit: int = 10, offset: int = 0, fields: Optional[str] = None
) -> str:
"""
Get papers referenced by a specific paper.
Args:
paper_id: Paper ID to get references for
limit: Maximum number of results (default: 10, max: 1000)
offset: Number of results to skip (default: 0)
fields: Comma-separated list of fields to return
Returns:
List of referenced papers
"""
params: Dict[str, Any] = {"limit": min(limit, 1000), "offset": offset}
if fields:
params["fields"] = fields
else:
params["fields"] = "paperId,title,authors,year,venue,citationCount"
encoded_id = quote(paper_id, safe="")
result = await make_api_request(f"paper/{encoded_id}/references", params)
if result is None:
return "Error: Failed to fetch references"
if "error" in result:
return f"Error: {result['error']}"
references = result.get("data", [])
total = result.get("total", 0)
if not references:
return "No references found for this paper."
formatted_references = []
for i, reference in enumerate(references, 1):
cited_paper = reference.get("citedPaper", {})
if cited_paper:
formatted_references.append(f"{i}. {format_paper(cited_paper)}")
result_text = (
f"Found {total} total references (showing {len(formatted_references)}):\n\n"
)
result_text += "\n\n".join(formatted_references)
return result_text