Skip to main content
Glama
openags

Paper Search MCP

by openags

download_hal

Download PDF documents from HAL repository using paper identifiers to access academic research papers for local storage and reference.

Instructions

Download PDF for a paper from HAL.

Args: paper_id: HAL paper identifier. save_path: Directory to save the PDF (default: './downloads'). Returns: str: Path to downloaded PDF.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paper_idYes
save_pathNo./downloads

Implementation Reference

  • The entry-point MCP tool `download_hal` which delegates to the `HALSearcher` instance.
    async def download_hal(paper_id: str, save_path: str = "./downloads") -> str:
        """Download PDF for a paper from HAL.
    
        Args:
            paper_id: HAL paper identifier.
            save_path: Directory to save the PDF (default: './downloads').
        Returns:
            str: Path to downloaded PDF.
        """
        return hal_searcher.download_pdf(paper_id, save_path)
  • The actual `download_pdf` method within `HALSearcher` that performs the file download logic for HAL papers.
    def download_pdf(self, paper_id: str, save_path: str = "./downloads") -> str:
        """Download an open-access PDF from HAL.
    
        Args:
            paper_id: HAL identifier (e.g. ``hal-01234567``) or the value
                returned in ``paper.paper_id`` (``hal:<id>``).
            save_path: Directory to save the downloaded PDF.
    
        Returns:
            Absolute path to saved PDF or an error message string.
        """
        import os
    
        hal_id = self._normalise_id(paper_id)
        pdf_url = self._resolve_pdf_url(hal_id)
        if not pdf_url:
            return (
                f"No open-access PDF found on HAL for {hal_id}. "
                "The document may be metadata-only or under embargo."
            )
    
        os.makedirs(save_path, exist_ok=True)
        safe_name = re.sub(r"[^a-zA-Z0-9._-]+", "_", hal_id) or hal_id
        output_path = os.path.join(save_path, f"hal_{safe_name}.pdf")
    
        try:
            dl_response = self.session.get(pdf_url, stream=True, timeout=60)
            dl_response.raise_for_status()
            with open(output_path, "wb") as fh:
                for chunk in dl_response.iter_content(chunk_size=8192):
                    fh.write(chunk)
            return output_path
        except Exception as exc:
            return f"Failed to download HAL PDF from {pdf_url}: {exc}"
  • Registration of the `download_pdf` method in the tool mapping.
    "hal": hal_searcher.download_pdf,

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/openags/paper-search-mcp'

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