download_arxiv
Download PDFs of arXiv research papers by providing the paper ID, with options to specify the save directory for organized storage.
Instructions
Download PDF of an arXiv paper.
Args: paper_id: arXiv paper ID (e.g., '2106.12345'). save_path: Directory to save the PDF (default: './downloads'). Returns: Path to the downloaded PDF file.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paper_id | Yes | ||
| save_path | No | ./downloads |
Implementation Reference
- paper_search_mcp/server.py:452-462 (handler)The 'download_arxiv' tool handler in the MCP server, which delegates the download task to the 'arxiv_searcher' instance.
@mcp.tool() async def download_arxiv(paper_id: str, save_path: str = "./downloads") -> str: """Download PDF of an arXiv paper. Args: paper_id: arXiv paper ID (e.g., '2106.12345'). save_path: Directory to save the PDF (default: './downloads'). Returns: Path to the downloaded PDF file. """ return await asyncio.to_thread(arxiv_searcher.download_pdf, paper_id, save_path) - The implementation of 'download_pdf' method in ArxivSearcher, which performs the actual HTTP request to download the PDF.
def download_pdf(self, paper_id: str, save_path: str) -> str: pdf_url = f"https://arxiv.org/pdf/{paper_id}.pdf" response = requests.get(pdf_url) os.makedirs(save_path, exist_ok=True) output_file = f"{save_path}/{paper_id}.pdf" with open(output_file, 'wb') as f: f.write(response.content) return output_file