Skip to main content
Glama

download_article

Download scholarly articles as PDF files from arXiv.org using article titles or arXiv IDs for research and analysis.

Instructions

Download the article as a PDF file. Resolve by arXiv ID or title.

Args: title: Article title. arxiv_id: arXiv ID.

Returns: Success message or structured error JSON.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleNo
arxiv_idNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler for the download_article tool. Resolves the article by title or arXiv ID, downloads the PDF with retries using httpx, saves to local file, returns success JSON with path or error.
    @mcp.tool()
    async def download_article(
        title: Optional[str] = None,
        arxiv_id: Optional[str] = None,
    ) -> str:
        """
        Download the article as a PDF file. Resolve by arXiv ID or title.
    
        Args:
            title: Article title.
            arxiv_id: arXiv ID.
    
        Returns:
            Success message or structured error JSON.
        """
        result = await resolve_article(title=title, arxiv_id=arxiv_id)
        if isinstance(result, str):
            return result
        article_url, resolved_id = result
        headers = {"User-Agent": USER_AGENT, "Accept": "application/pdf"}
        file_path = os.path.join(DOWNLOAD_PATH, f"{resolved_id}.pdf")
        async with httpx.AsyncClient(timeout=DEFAULT_TIMEOUT, limits=HTTP_LIMITS) as client:
            for attempt in range(RETRY_ATTEMPTS):
                try:
                    async with client.stream("GET", article_url, headers=headers) as resp:
                        resp.raise_for_status()
                        with open(file_path, "wb") as f:
                            async for chunk in resp.aiter_bytes():
                                if chunk:
                                    f.write(chunk)
                    return json.dumps({
                        "status": "ok",
                        "message": "Download successful.",
                        "path": file_path,
                    })
                except Exception as e:
                    if attempt < RETRY_ATTEMPTS - 1:
                        await _retry_sleep(attempt)
                        continue
                    return _error("DOWNLOAD_FAILED", f"Unable to retrieve or save the article: {e}")
  • Helper function to resolve article title or arXiv ID to PDF URL and ID. Used by download_article and other tools.
    async def resolve_article(title: Optional[str] = None, arxiv_id: Optional[str] = None) -> Tuple[str, str] | str:
        """
        Resolve to a direct PDF URL and arXiv ID using either a title or an arXiv ID.
        Preference order: arxiv_id > title.
        """
        if arxiv_id:
            m = ARXIV_ID_RE.match(arxiv_id.strip())
            if not m:
                return _error("INVALID_ID", f"Not a valid arXiv ID: {arxiv_id}")
            vid = m.group("id")
            return (f"https://arxiv.org/pdf/{vid}", vid)
        if not title:
            return _error("MISSING_PARAM", "Provide either 'arxiv_id' or 'title'.")
        info = await fetch_information(title)
        if isinstance(info, str):
            return _error("NOT_FOUND", str(info))
        resolved_id = info.id.split("/abs/")[-1]
        direct_pdf_url = f"https://arxiv.org/pdf/{resolved_id}"
        return (direct_pdf_url, resolved_id)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions the download action and resolution methods, but lacks details on permissions, rate limits, file handling (e.g., where the PDF is saved), or error conditions beyond a generic 'structured error JSON.' For a tool with no annotations, this is insufficient to guide safe and effective use.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose, followed by structured sections for args and returns. It's efficient with no wasted sentences, though the 'Args' and 'Returns' labels are slightly redundant since the schema covers this. Overall, it's well-structured and concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 0% schema coverage, but an output schema exists (implied by 'Returns'), the description is moderately complete. It covers the basic purpose and parameters, but lacks behavioral details and doesn't fully leverage the output schema to explain return values. For a download tool with no annotations, it should provide more context on execution and outcomes.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It lists the parameters ('title' and 'arxiv_id') and explains they are used for resolution, but doesn't specify format (e.g., arXiv ID pattern), exclusivity, or how conflicts are handled. This adds some meaning beyond the bare schema, but doesn't fully cover the gaps, resulting in a baseline score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Download') and resource ('article as a PDF file'), specifying the format. It distinguishes from siblings like 'get_article_url' (which likely returns a URL) and 'load_article_to_context' (which might load content without downloading), but could be more explicit about the distinction. The purpose is specific but not fully differentiated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by stating 'Resolve by arXiv ID or title,' suggesting it's for retrieving articles from arXiv. However, it doesn't explicitly say when to use this vs. alternatives like 'search_arxiv' (for finding articles) or 'get_details' (for metadata). No exclusions or clear alternatives are provided, leaving some ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/lecigarevolant/arxiv-mcp-server-gpt'

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