Skip to main content
Glama
andybrandt

mcp-simple-arxiv

by andybrandt

Search arXiv Papers

search_papers
Read-only

Search arXiv papers by title, abstract, author, or category using advanced query syntax to find relevant academic research.

Instructions

Search for papers on arXiv by title and abstract content.

You can use advanced search syntax:

  • Search in title: ti:"search terms"

  • Search in abstract: abs:"search terms"

  • Search by author: au:"author name"

  • Combine terms with: AND, OR, ANDNOT

  • Filter by category: cat:cs.AI (use list_categories tool to see available categories)

Examples:

  • "machine learning" (searches all fields)

  • ti:"neural networks" AND cat:cs.AI (title with category)

  • au:bengio AND ti:"deep learning" (author and title)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
max_resultsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'search_papers' tool. It calls ArxivClient.search, formats the results into a readable string with title, authors, ID, categories, published date, and abstract preview.
        async def search_papers(query: str, max_results: int = 10) -> str:
            """
    Search for papers on arXiv by title and abstract content.
    
    You can use advanced search syntax:
    - Search in title: ti:"search terms"
    - Search in abstract: abs:"search terms"
    - Search by author: au:"author name"
    - Combine terms with: AND, OR, ANDNOT
    - Filter by category: cat:cs.AI (use list_categories tool to see available categories)
    
    Examples:
    - "machine learning"  (searches all fields)
    - ti:"neural networks" AND cat:cs.AI  (title with category)
    - au:bengio AND ti:"deep learning"  (author and title)
            """
            max_results = min(max_results, 50)
            papers = await arxiv_client.search(query, max_results)
            
            # Format results in a readable way
            result = "Search Results:\n\n"
            for i, paper in enumerate(papers, 1):
                result += f"{i}. {paper['title']}\n"
                result += f"   Authors: {', '.join(paper['authors'])}\n"
                result += f"   ID: {paper['id']}\n"
                result += f"   Categories: "
                if paper['primary_category']:
                    result += f"Primary: {paper['primary_category']}"
                if paper['categories']:
                    result += f", Additional: {', '.join(paper['categories'])}"
                result += f"\n   Published: {paper['published']}\n"
                
                # Add first sentence of abstract
                abstract_preview = get_first_sentence(paper['summary'])
                result += f"   Preview: {abstract_preview}\n"
                result += "\n"
            
            return result
  • Registers the search_papers tool with the FastMCP app, providing title and hints for the tool schema.
    @app.tool(
        annotations={
            "title": "Search arXiv Papers",
            "readOnlyHint": True,
            "openWorldHint": True
        }
    )
  • Type annotations and docstring defining input parameters (query: str, max_results: int=10), advanced search syntax, and output format (str).
        async def search_papers(query: str, max_results: int = 10) -> str:
            """
    Search for papers on arXiv by title and abstract content.
    
    You can use advanced search syntax:
    - Search in title: ti:"search terms"
    - Search in abstract: abs:"search terms"
    - Search by author: au:"author name"
    - Combine terms with: AND, OR, ANDNOT
    - Filter by category: cat:cs.AI (use list_categories tool to see available categories)
    
    Examples:
    - "machine learning"  (searches all fields)
    - ti:"neural networks" AND cat:cs.AI  (title with category)
    - au:bengio AND ti:"deep learning"  (author and title)
            """
  • Helper function used to generate abstract previews in search results.
    def get_first_sentence(text: str, max_len: int = 200) -> str:
        """Extract first sentence from text, limiting length."""
        # Look for common sentence endings
        for end in ['. ', '! ', '? ']:
            pos = text.find(end)
            if pos != -1 and pos < max_len:
                return text[:pos + 1]
        # If no sentence ending found, just take first max_len chars
        if len(text) > max_len:
            return text[:max_len].rstrip() + '...'
        return text
  • Core helper method in ArxivClient class that performs the actual arXiv API search, respects rate limits, parses Atom feed response, and returns list of paper dicts used by the tool handler.
    async def search(self, query: str, max_results: int = 10) -> List[Dict[str, Any]]:
        """
        Search arXiv papers.
        
        The query string supports arXiv's advanced search syntax:
        - Search in title: ti:"search terms"
        - Search in abstract: abs:"search terms"
        - Search by author: au:"author name"
        - Combine terms with: AND, OR, ANDNOT
        - Filter by category: cat:cs.AI
        
        Examples:
        - "machine learning"  (searches all fields)
        - ti:"neural networks" AND cat:cs.AI  (title with category)
        - au:bengio AND ti:"deep learning"  (author and title)
        """
        await self._wait_for_rate_limit()
        
        # Ensure max_results is within API limits
        max_results = min(max_results, 2000)  # API limit: 2000 per request
        
        params = {
            "search_query": query,
            "max_results": max_results,
            "sortBy": "submittedDate",  # Default to newest papers first
            "sortOrder": "descending",
        }
        
        async with httpx.AsyncClient(timeout=20.0) as client:
            try:
                response = await client.get(self.base_url, params=params)
                response.raise_for_status() # Raise an exception for bad status codes
                
                # Parse the Atom feed response
                feed = feedparser.parse(response.text)
                
                if not isinstance(feed, dict) or 'entries' not in feed:
                    logger.error("Invalid response from arXiv API")
                    logger.debug(f"Response text: {response.text[:1000]}...")
                    raise ValueError("Invalid response from arXiv API")
                    
                if not feed.get('entries'):
                    # Empty results are ok - return empty list
                    return []
                
                return [self._parse_entry(entry) for entry in feed.entries]
                
            except httpx.HTTPError as e:
                logger.error(f"HTTP error while searching: {e}")
                raise ValueError(f"arXiv API HTTP error: {str(e)}")
            
    async def get_paper(self, paper_id: str) -> Dict[str, Any]:
Behavior4/5

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

Annotations already provide readOnlyHint=true and openWorldHint=true, indicating a safe, read-only operation with open-world data. The description adds valuable behavioral context beyond annotations by detailing advanced search syntax, examples, and the ability to filter by category, which helps the agent understand how to construct effective queries. However, it does not mention rate limits, pagination, or error handling, leaving some behavioral aspects uncovered.

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 well-structured and front-loaded with the core purpose, followed by syntax details and examples. Every sentence earns its place by providing essential information without redundancy, making it efficient and easy to parse for an AI agent.

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

Completeness5/5

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

Given the tool's complexity (search with advanced syntax), low schema coverage (0%), and the presence of an output schema (which handles return values), the description is complete enough. It covers purpose, usage, parameters, and examples, leaving no critical gaps for the agent to operate effectively in context.

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

Parameters5/5

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

The input schema has 0% description coverage, so the description fully compensates by explaining the semantics of the 'query' parameter in detail (e.g., advanced syntax, examples) and implies the use of 'max_results' through examples like limiting results. It adds significant meaning beyond the bare schema, making parameter usage clear and actionable.

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

Purpose5/5

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

The description clearly states the specific action ('Search for papers on arXiv') and resource ('by title and abstract content'), distinguishing it from sibling tools like 'get_paper_data' (likely for retrieving specific papers), 'list_categories' (for listing categories), and 'update_categories' (for updating categories). It provides a verb+resource+scope combination that is precise and differentiated.

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

Usage Guidelines5/5

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

The description explicitly provides usage guidance by naming an alternative tool ('use list_categories tool to see available categories') and includes examples that illustrate when to use specific syntax (e.g., for title, abstract, author, category filtering). It effectively guides the agent on how to apply the tool in different contexts without being misleading.

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

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