Skip to main content
Glama
emi-dm

ArxivSearcher MCP Server

by emi-dm

search_papers

Search arXiv for academic papers using natural language queries, filter by date and category, and sort results by relevance or submission date.

Instructions

Search for papers on arXiv. It can parse natural language queries, extracting keywords and years for filtering.

:param query: The base search query. Can be natural language. :param max_results: The maximum number of results to return. :param start_date: The start date for the search period (YYYY-MM-DD or YYYY). Overrides years in query. :param end_date: The end date for the search period (YYYY-MM-DD or YYYY). Overrides years in query. :param sort_by_relevance: If True, sorts by relevance. If False, sorts by submission date. :param category: The arXiv category to search in (e.g., 'cs.AI', 'cs.CL', 'cs.SE').

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
max_resultsNo
start_dateNo
end_dateNo
sort_by_relevanceNo
categoryNocs.SE

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Primary synchronous implementation of the 'search_papers' MCP tool handler. Parses natural language queries, extracts keywords and dates, builds advanced arXiv search queries with category and date filters, performs the search, and returns structured results.
    @mcp.tool
    def search_papers(
        query: str,
        max_results: int = 10,
        start_date: str | None = None,
        end_date: str | None = None,
        sort_by_relevance: bool = True,
        category: str = "cs.SE",
    ) -> dict:
        """
        Search for papers on arXiv.
        It can parse natural language queries, extracting keywords and years for filtering.
    
        :param query: The base search query. Can be natural language.
        :param max_results: The maximum number of results to return.
        :param start_date: The start date for the search period (YYYY-MM-DD or YYYY). Overrides years in query.
        :param end_date: The end date for the search period (YYYY-MM-DD or YYYY). Overrides years in query.
        :param sort_by_relevance: If True, sorts by relevance. If False, sorts by submission date.
        :param category: The arXiv category to search in (e.g., 'cs.AI', 'cs.CL', 'cs.SE').
        """
        STOP_WORDS = {
            "a",
            "an",
            "and",
            "the",
            "of",
            "in",
            "for",
            "to",
            "with",
            "on",
            "is",
            "are",
            "was",
            "were",
            "it",
        }
    
        # Extract years from query to use as date filters if not provided explicitly
        years_in_query = re.findall(r"\b(20\d{2})\b", query)
        query_text = re.sub(r"\b(20\d{2})\b", "", query).strip()
    
        # Use provided dates or fall back to dates from query
        effective_start_date = start_date
        if not effective_start_date and years_in_query:
            effective_start_date = min(years_in_query)
    
        effective_end_date = end_date
        if not effective_end_date and years_in_query:
            effective_end_date = max(years_in_query)
    
        # Process keywords from the query text
        keywords = [
            word
            for word in query_text.split()
            if word.lower() not in STOP_WORDS and len(word) > 2
        ]
    
        if keywords:
            # Build a structured query from keywords, joining with OR for broader results
            keyword_query = " OR ".join([f'(ti:"{kw}" OR abs:"{kw}")' for kw in keywords])
            query_parts = [f"({keyword_query})"]
        else:
            # Fallback to using the original query text if no keywords are left
            query_parts = [f'(ti:"{query_text}" OR abs:"{query_text}")']
    
        if category:
            query_parts.append(f"cat:{category}")
    
        # Add date range to the query
        if effective_start_date or effective_end_date:
            start = "19910814"
            if effective_start_date:
                try:
                    dt = datetime.strptime(effective_start_date, "%Y-%m-%d")
                except ValueError:
                    dt = datetime.strptime(effective_start_date, "%Y")
                start = dt.strftime("%Y%m%d")
    
            end = datetime.now().strftime("%Y%m%d")
            if effective_end_date:
                try:
                    dt = datetime.strptime(effective_end_date, "%Y-%m-%d")
                except ValueError:
                    dt = datetime.strptime(effective_end_date, "%Y")
                    dt = dt.replace(month=12, day=31)
                end = dt.strftime("%Y%m%d")
    
            query_parts.append(f"submittedDate:[{start} TO {end}]")
    
        final_query = " AND ".join(query_parts)
        print(f"[arxiv-search] Query sent: {final_query}")
    
        sort_criterion = (
            arxiv.SortCriterion.Relevance
            if sort_by_relevance
            else arxiv.SortCriterion.SubmittedDate
        )
    
        search = arxiv.Search(
            query=final_query,
            max_results=max_results,
            sort_by=sort_criterion,
            sort_order=arxiv.SortOrder.Descending,
        )
        results = []
        for r in search.results():
            results.append(
                {
                    "title": r.title,
                    "authors": [a.name for a in r.authors],
                    "summary": r.summary,
                    "pdf_url": r.pdf_url,
                    "published_date": r.published.strftime("%Y-%m-%d"),
                }
            )
        return {"query_used": final_query, "results": results}
  • Asynchronous variant of the 'search_papers' MCP tool handler for remote deployment. Identical logic to the synchronous version but defined as async.
    @mcp.tool
    async def search_papers(
        query: str,
        max_results: int = 10,
        start_date: str | None = None,
        end_date: str | None = None,
        sort_by_relevance: bool = True,
        category: str = "cs.SE",
    ) -> dict:
        """
        Search for papers on arXiv.
        It can parse natural language queries, extracting keywords and years for filtering.
    
        :param query: The base search query. Can be natural language.
        :param max_results: The maximum number of results to return.
        :param start_date: The start date for the search period (YYYY-MM-DD or YYYY). Overrides years in query.
        :param end_date: The end date for the search period (YYYY-MM-DD or YYYY). Overrides years in query.
        :param sort_by_relevance: If True, sorts by relevance. If False, sorts by submission date.
        :param category: The arXiv category to search in (e.g., 'cs.AI', 'cs.CL', 'cs.SE').
        """
        STOP_WORDS = {
            "a",
            "an",
            "and",
            "the",
            "of",
            "in",
            "for",
            "to",
            "with",
            "on",
            "is",
            "are",
            "was",
            "were",
            "it",
        }
    
        # Extract years from query to use as date filters if not provided explicitly
        years_in_query = re.findall(r"\b(20\d{2})\b", query)
        query_text = re.sub(r"\b(20\d{2})\b", "", query).strip()
    
        # Use provided dates or fall back to dates from query
        effective_start_date = start_date
        if not effective_start_date and years_in_query:
            effective_start_date = min(years_in_query)
    
        effective_end_date = end_date
        if not effective_end_date and years_in_query:
            effective_end_date = max(years_in_query)
    
        # Process keywords from the query text
        keywords = [
            word
            for word in query_text.split()
            if word.lower() not in STOP_WORDS and len(word) > 2
        ]
    
        if keywords:
            # Build a structured query from keywords, joining with OR for broader results
            keyword_query = " OR ".join([f'(ti:"{kw}" OR abs:"{kw}")' for kw in keywords])
            query_parts = [f"({keyword_query})"]
        else:
            # Fallback to using the original query text if no keywords are left
            query_parts = [f'(ti:"{query_text}" OR abs:"{query_text}")']
    
        if category:
            query_parts.append(f"cat:{category}")
    
        # Add date range to the query
        if effective_start_date or effective_end_date:
            start = "19910814"
            if effective_start_date:
                try:
                    dt = datetime.strptime(effective_start_date, "%Y-%m-%d")
                except ValueError:
                    dt = datetime.strptime(effective_start_date, "%Y")
                start = dt.strftime("%Y%m%d")
    
            end = datetime.now().strftime("%Y%m%d")
            if effective_end_date:
                try:
                    dt = datetime.strptime(effective_end_date, "%Y-%m-%d")
                except ValueError:
                    dt = datetime.strptime(effective_end_date, "%Y")
                    dt = dt.replace(month=12, day=31)
                end = dt.strftime("%Y%m%d")
    
            query_parts.append(f"submittedDate:[{start} TO {end}]")
    
        final_query = " AND ".join(query_parts)
        print(f"[arxiv-search] Query sent: {final_query}")
    
        sort_criterion = (
            arxiv.SortCriterion.Relevance
            if sort_by_relevance
            else arxiv.SortCriterion.SubmittedDate
        )
    
        search = arxiv.Search(
            query=final_query,
            max_results=max_results,
            sort_by=sort_criterion,
            sort_order=arxiv.SortOrder.Descending,
        )
        results = []
        for r in search.results():
            results.append(
                {
                    "title": r.title,
                    "authors": [a.name for a in r.authors],
                    "summary": r.summary,
                    "pdf_url": r.pdf_url,
                    "published_date": r.published.strftime("%Y-%m-%d"),
                }
            )
        return {"query_used": final_query, "results": results}
  • Input schema and parameters documentation for the search_papers tool, including descriptions of all arguments and their usage.
    """
    Search for papers on arXiv.
    It can parse natural language queries, extracting keywords and years for filtering.
    
    :param query: The base search query. Can be natural language.
    :param max_results: The maximum number of results to return.
    :param start_date: The start date for the search period (YYYY-MM-DD or YYYY). Overrides years in query.
    :param end_date: The end date for the search period (YYYY-MM-DD or YYYY). Overrides years in query.
    :param sort_by_relevance: If True, sorts by relevance. If False, sorts by submission date.
    :param category: The arXiv category to search in (e.g., 'cs.AI', 'cs.CL', 'cs.SE').
    """
  • FastMCP tool registration decorator for search_papers in the main implementation file.
    @mcp.tool
  • Documentation in search_tips resource explaining usage of search_papers tool parameters.
    **4. Date Syntax:**
    - The `search_papers` tool handles dates with the `start_date` and `end_date` parameters.
    - It is preferable to use these parameters instead of including dates directly in the `query` for greater precision.
    """
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds some context: it mentions natural language query parsing and date/year overriding behavior, which are useful beyond basic search functionality. However, it doesn't cover important aspects like rate limits, authentication needs, error handling, or pagination behavior, leaving gaps for a tool with 6 parameters.

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 appropriately sized and front-loaded with the core purpose. The parameter explanations are organized clearly with :param notation, though this format is more technical than natural language. Every sentence adds value, with no wasted words.

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 complexity (6 parameters, no annotations, but with output schema), the description is reasonably complete. It explains all parameters thoroughly and mentions natural language processing capabilities. The output schema existence means return values don't need explanation, but behavioral aspects like rate limits or errors could be more detailed.

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?

Schema description coverage is 0%, so the description must fully compensate. It provides detailed semantic explanations for all 6 parameters, including query parsing behavior, date format options, sorting logic, and category examples. This adds significant value beyond the bare schema, making parameter purposes clear.

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's purpose: 'Search for papers on arXiv.' It specifies the resource (papers) and the platform (arXiv), but doesn't explicitly differentiate it from sibling tools like 'search_by_author' or 'find_related_papers' in terms of search scope or methodology.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'search_by_author' or 'find_related_papers.' It mentions natural language query parsing, which hints at usage context, but lacks explicit when/when-not instructions or comparisons to sibling tools.

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/emi-dm/Arxiv-MCP'

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