get_citation_context
Retrieve the specific context where one academic paper cites another to understand citation relationships and scholarly discussions.
Instructions
Get the context in which one paper cites another.
Args:
paper_id: ID of the paper being cited
citing_paper_id: ID of the paper doing the citing
Returns:
Citation context information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paper_id | Yes | ||
| citing_paper_id | Yes |
Implementation Reference
- The handler function for the 'get_citation_context' tool, decorated with @mcp.tool() which also serves as its registration in the FastMCP server. It fetches citation context from the Semantic Scholar API endpoint /paper/{paper_id}/citations/{citing_paper_id}, extracts contexts, paper titles, and formats a response string with the citation snippets.@mcp.tool() async def get_citation_context(paper_id: str, citing_paper_id: str) -> str: """ Get the context in which one paper cites another. Args: paper_id: ID of the paper being cited citing_paper_id: ID of the paper doing the citing Returns: Citation context information """ encoded_paper_id = quote(paper_id, safe="") encoded_citing_id = quote(citing_paper_id, safe="") result = await make_api_request( f"paper/{encoded_paper_id}/citations/{encoded_citing_id}" ) if result is None: return "Error: Failed to fetch citation context" if "error" in result: return f"Error: {result['error']}" contexts = result.get("contexts", []) citing_paper = result.get("citingPaper", {}) cited_paper = result.get("citedPaper", {}) if not contexts: return "No citation context found." result_text = "Citation context:\n\n" result_text += f"Cited paper: {cited_paper.get('title', 'Unknown')}\n" result_text += f"Citing paper: {citing_paper.get('title', 'Unknown')}\n\n" for i, context in enumerate(contexts, 1): result_text += f"{i}. {context}\n" return result_text