apaper_download_iacr_paper
Download the PDF of any IACR ePrint paper by providing its paper ID, with option to specify a save directory.
Instructions
Download PDF of an IACR ePrint paper
Args: paper_id: IACR paper ID (e.g., '2009/101') save_path: Directory to save the PDF (default: './downloads')
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paper_id | Yes | ||
| save_path | No | ./downloads |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/apaper/server.py:103-120 (handler)The MCP tool handler function 'download_iacr_paper' that serves as the entry point for the 'apaper_download_iacr_paper' tool. It takes paper_id and save_path parameters, calls iacr_searcher.download_pdf(), and returns a result string.
@mcp.tool() def download_iacr_paper(paper_id: str, save_path: str = "./downloads") -> str: """ Download PDF of an IACR ePrint paper Args: paper_id: IACR paper ID (e.g., '2009/101') save_path: Directory to save the PDF (default: './downloads') """ try: result = iacr_searcher.download_pdf(paper_id, save_path) if result.startswith(("Error", "Failed")): return f"Download failed: {result}" else: return f"PDF downloaded successfully to: {result}" except Exception as e: return f"Error downloading IACR paper: {str(e)}" - src/apaper/server.py:103-103 (registration)Registration of the tool via the @mcp.tool() decorator on the download_iacr_paper function. FastMCP framework registers this as an MCP tool named 'download_iacr_paper'.
@mcp.tool() - src/apaper/platforms/iacr.py:207-234 (helper)The IACRSearcher.download_pdf() method that does the actual PDF download logic. Constructs the PDF URL from the paper_id, makes a GET request, saves to disk, and returns the file path.
def download_pdf(self, paper_id: str, save_path: str) -> str: """ Download PDF from IACR ePrint Archive Args: paper_id: IACR paper ID (e.g., "2025/1014") save_path: Path to save the PDF Returns: str: Path to downloaded file or error message """ try: os.makedirs(save_path, exist_ok=True) pdf_url = f"{self.IACR_BASE_URL}/{paper_id}.pdf" response = self.session.get(pdf_url) if response.status_code == 200: filename = f"{save_path}/iacr_{paper_id.replace('/', '_')}.pdf" with open(filename, "wb") as f: f.write(response.content) return filename else: return f"Failed to download PDF: HTTP {response.status_code}" except Exception as e: logger.error(f"PDF download error: {e}") return f"Error downloading PDF: {e}" - src/apaper/server.py:105-111 (schema)The docstring and function signature define the schema: paper_id (str, required) and save_path (str, optional, default './downloads').
""" Download PDF of an IACR ePrint paper Args: paper_id: IACR paper ID (e.g., '2009/101') save_path: Directory to save the PDF (default: './downloads') """ - src/apaper/platforms/base.py:15-18 (helper)Abstract base method in PaperSource that defines the interface contract for download_pdf.
@abstractmethod def download_pdf(self, paper_id: str, save_path: str) -> str: """Download PDF of a paper""" raise NotImplementedError