Skip to main content
Glama

search

Search arXiv scientific papers by title, keywords, or arXiv ID to find relevant research papers with details like authors and abstracts.

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

Implementation Reference

  • The @mcp.tool()-decorated 'search' function that registers and implements the MCP 'search' tool handler. It calls the search_papers helper, formats the results, and returns a markdown-formatted string.
    @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 converting results to 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 schema defining the structure of a Paper object returned by the search functionality.
    @dataclass class Paper: """Represents an arXiv paper.""" id: str title: str authors: list[str] abstract: str published: str pdf_url: str categories: list[str]

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