get_citation_context
Extract the specific context in which one academic paper cites another, providing detailed citation information for analysis or referencing purposes.
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
| Name | Required | Description | Default |
|---|---|---|---|
| citing_paper_id | Yes | ||
| paper_id | Yes |
Input Schema (JSON Schema)
{
"properties": {
"citing_paper_id": {
"title": "Citing Paper Id",
"type": "string"
},
"paper_id": {
"title": "Paper Id",
"type": "string"
}
},
"required": [
"paper_id",
"citing_paper_id"
],
"title": "get_citation_contextArguments",
"type": "object"
}
Implementation Reference
- The main handler function for the 'get_citation_context' tool. It is registered via the @mcp.tool() decorator and implements the logic to retrieve citation contexts from the Semantic Scholar API by making an HTTP request to the appropriate endpoint and formatting the response.@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