Skip to main content
Glama

search

Search arXiv papers by title, keywords, or arXiv ID to find relevant scientific literature and research papers.

Instructions

Search arXiv papers by title, keywords, or arXiv ID.

Args:
    query: Search query (title, keywords, or arXiv ID like 2401.12345)
    max_results: Maximum number of results to return (default: 10)

Returns:
    List of matching papers with ID, title, authors, and abstract

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
max_resultsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'search' tool, decorated with @mcp.tool() to register it with the MCP server. It formats search results from search_papers into a string response.
    @mcp.tool()
    def search(query: str, max_results: int = 10) -> str:
        """Search arXiv papers by title, keywords, or arXiv ID.
    
        Args:
            query: Search query (title, keywords, or arXiv ID like 2401.12345)
            max_results: Maximum number of results to return (default: 10)
    
        Returns:
            List of matching papers with ID, title, authors, and abstract
        """
        papers = search_papers(query, max_results)
    
        if not papers:
            return "No papers found."
    
        results = []
        for p in papers:
            authors = ", ".join(p.authors[:3])
            if len(p.authors) > 3:
                authors += " et al."
    
            results.append(
                f"**{p.id}**: {p.title}\n"
                f"Authors: {authors}\n"
                f"Published: {p.published}\n"
                f"Abstract: {p.abstract[:300]}...\n"
            )
    
        return "\n---\n".join(results)
  • Core helper function that performs the actual arXiv paper search using the arxiv library, handling both ID lookups and keyword searches, and returns a list of Paper objects.
    def search_papers(query: str, max_results: int = 10) -> list[Paper]:
        """Search arXiv papers by query or ID."""
        arxiv_id = extract_arxiv_id(query)
    
        if arxiv_id:
            # Direct ID lookup
            client = arxiv.Client()
            search = arxiv.Search(id_list=[arxiv_id])
            results = list(client.results(search))
        else:
            # Keyword search
            client = arxiv.Client()
            search = arxiv.Search(
                query=query,
                max_results=max_results,
                sort_by=arxiv.SortCriterion.Relevance,
            )
            results = list(client.results(search))
    
        papers = []
        for result in results:
            paper = Paper(
                id=result.entry_id.split("/")[-1],
                title=result.title,
                authors=[author.name for author in result.authors],
                abstract=result.summary,
                published=result.published.strftime("%Y-%m-%d"),
                pdf_url=result.pdf_url,
                categories=result.categories,
            )
            papers.append(paper)
    
        return papers
  • Dataclass defining the structure of a Paper object used in search results.
    @dataclass
    class Paper:
        """Represents an arXiv paper."""
        id: str
        title: str
        authors: list[str]
        abstract: str
        published: str
        pdf_url: str
        categories: list[str]
  • Helper function to extract arXiv ID from the search query for direct lookups.
    def extract_arxiv_id(query: str) -> str | None:
        """Extract arXiv ID from query if present."""
        # Patterns: 2401.12345, arXiv:2401.12345, etc.
        patterns = [
            r"(\d{4}\.\d{4,5})",  # 2401.12345
            r"arxiv[:\s]*(\d{4}\.\d{4,5})",  # arXiv:2401.12345
        ]
        for pattern in patterns:
            match = re.search(pattern, query, re.IGNORECASE)
            if match:
                return match.group(1)
        return None
  • The @mcp.tool() decorator that registers the search function as an MCP tool.
    @mcp.tool()
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 tool returns a list of matching papers with specific fields, which is helpful, but doesn't disclose behavioral traits such as rate limits, authentication needs, error handling, or whether it accesses live data versus cached results. The description adds some context but leaves significant gaps for a search tool.

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

Conciseness5/5

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

The description is appropriately sized and front-loaded, starting with the core purpose, followed by clear sections for Args and Returns. Every sentence earns its place, with no redundant information, making it efficient and easy to parse.

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

Completeness4/5

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

Given the tool's moderate complexity, no annotations, and an output schema (implied by the Returns section), the description is fairly complete. It covers purpose, parameters, and return values, but lacks details on behavioral aspects like performance or limitations, which would enhance completeness for a search operation.

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

Parameters4/5

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

With 0% schema description coverage, the description compensates well by explaining both parameters: 'query' as a search query for title, keywords, or arXiv ID, and 'max_results' with its default value. It adds meaning beyond the bare schema, though it doesn't detail format constraints (e.g., arXiv ID syntax) or validation rules.

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 tool searches arXiv papers by title, keywords, or arXiv ID, providing a specific verb ('search') and resource ('arXiv papers'). It distinguishes from sibling tools like 'get_paper' (likely retrieves a specific paper) and 'list_downloaded_papers' (likely lists locally stored papers) by focusing on search functionality, though it doesn't explicitly name these alternatives.

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 for searching arXiv papers, but doesn't explicitly state when to use this tool versus alternatives like 'get_paper' or 'list_downloaded_papers'. It provides context on what can be searched (title, keywords, arXiv ID), but lacks explicit guidance on exclusions or comparative scenarios.

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/AnnaSuSu/arxiv-mcp'

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