get_paper
Retrieve arXiv paper text by ID, with options to get full content or specific sections like abstract, introduction, method, or conclusion.
Instructions
Get the full text of an arXiv paper.
Args:
paper_id: arXiv paper ID (e.g., "2401.12345")
section: Which section to return: "all", "abstract", "introduction", "method", "conclusion"
Returns:
The paper text (full or specified section)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paper_id | Yes | ||
| section | No | all |
Implementation Reference
- src/arxiv_mcp_server/server.py:52-96 (handler)The @mcp.tool()-decorated function that implements the 'get_paper' tool. It retrieves paper text from cache if available, otherwise searches, downloads the PDF, extracts text using pdf_parser, caches it, and returns the full text or a specific section.@mcp.tool() def get_paper(paper_id: str, section: str = "all") -> str: """Get the full text of an arXiv paper. Args: paper_id: arXiv paper ID (e.g., "2401.12345") section: Which section to return: "all", "abstract", "introduction", "method", "conclusion" Returns: The paper text (full or specified section) """ # Check cache first cached_text = storage.get_text(paper_id) if cached_text: if section == "all": return cached_text return extract_section(cached_text, section) # Search for the paper papers = search_papers(paper_id, max_results=1) if not papers: return f"Paper {paper_id} not found." paper = papers[0] # Download PDF pdf_path = storage.get_pdf_path(paper_id) try: download_pdf(paper, str(pdf_path)) except Exception as e: return f"Failed to download paper: {e}" # Extract text try: full_text = extract_text(str(pdf_path)) except Exception as e: return f"Failed to extract text from PDF: {e}" # Cache results storage.save_paper_metadata(paper) storage.save_text(paper_id, full_text) if section == "all": return full_text return extract_section(full_text, section)
- src/arxiv_mcp_server/server.py:52-52 (registration)The @mcp.tool() decorator registers the get_paper function as an MCP tool.@mcp.tool()
- src/arxiv_mcp_server/server.py:53-62 (schema)Function signature and docstring defining input parameters (paper_id, section) and return type, used by FastMCP for tool schema.def get_paper(paper_id: str, section: str = "all") -> str: """Get the full text of an arXiv paper. Args: paper_id: arXiv paper ID (e.g., "2401.12345") section: Which section to return: "all", "abstract", "introduction", "method", "conclusion" Returns: The paper text (full or specified section) """