Skip to main content
Glama

get_paper

Retrieve full text or specific sections of arXiv papers by paper ID for research and analysis.

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
NameRequiredDescriptionDefault
paper_idYes
sectionNoall

Implementation Reference

  • The main handler function for the 'get_paper' tool. It is decorated with @mcp.tool() for registration. Handles caching via storage, searching/downloading PDF if needed, text extraction, and section extraction.
    @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)
  • The @mcp.tool() decorator registers the get_paper function as an MCP tool.
    @mcp.tool()
  • The docstring provides the input schema (parameters) and output description for the tool.
    """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) """
  • Helper method used by get_paper for retrieving cached text.
    def get_text(self, paper_id: str) -> str | None: text_path = self.get_text_path(paper_id) if text_path.exists(): return text_path.read_text() return None
Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AnnaSuSu/arxiv-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server