download_citeseerx
Download academic paper PDFs from CiteSeerX by providing the paper identifier, saving files to your specified directory for research access.
Instructions
Download PDF for a paper from CiteSeerX.
Args: paper_id: CiteSeerX paper identifier. save_path: Directory to save the PDF (default: './downloads'). Returns: str: Path to downloaded PDF or error message.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paper_id | Yes | ||
| save_path | No | ./downloads |
Implementation Reference
- paper_search_mcp/server.py:1120-1130 (handler)The 'download_citeseerx' tool handler in the MCP server, which wraps the platform-specific implementation.
@mcp.tool() async def download_citeseerx(paper_id: str, save_path: str = "./downloads") -> str: """Download PDF for a paper from CiteSeerX. Args: paper_id: CiteSeerX paper identifier. save_path: Directory to save the PDF (default: './downloads'). Returns: str: Path to downloaded PDF or error message. """ return citeseerx_searcher.download_pdf(paper_id, save_path) - The actual implementation of the PDF download logic for CiteSeerX papers.
def download_pdf(self, paper_id: str, save_path: str) -> str: """ Download PDF for a CiteSeerX paper. Args: paper_id: CiteSeerX paper identifier save_path: Directory to save the PDF Returns: Path to the saved PDF file Raises: Exception: If download fails or no PDF available """ # First get paper details to find PDF URL paper = self.get_paper_details(paper_id) if not paper or not paper.pdf_url: raise Exception(f"No PDF available for paper {paper_id}") try: # Download PDF response = self._get(paper.pdf_url, stream=True) response.raise_for_status() # Create save directory if it doesn't exist os.makedirs(save_path, exist_ok=True) # Generate filename filename = f"{paper_id.replace('/', '_')}.pdf" if paper.doi: filename = f"{paper.doi.replace('/', '_')}.pdf" filepath = os.path.join(save_path, filename) # Save PDF with open(filepath, 'wb') as f: for chunk in response.iter_content(chunk_size=8192): f.write(chunk) logger.info(f"Downloaded PDF to {filepath}") return filepath except requests.RequestException as e: logger.error(f"Error downloading PDF: {e}") raise Exception(f"Failed to download PDF: {e}") except Exception as e: logger.error(f"Unexpected error downloading PDF: {e}") raise def read_paper(self, paper_id: str, save_path: str = "./downloads") -> str: """