Skip to main content
Glama
yzfly

ArXiv Paper MCP

by yzfly

search_arxiv

Search for research papers on arXiv using keywords to find scientific literature and access PDFs through the Model Context Protocol.

Instructions

搜索 arXiv 论文

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes搜索英文关键词
maxResultsNo最大结果数量

Implementation Reference

  • The core handler function for the 'search_arxiv' tool. It uses ArXivClient to search for papers based on a query and returns formatted results including title, summary, authors, etc.
    async function searchArxivPapers(query: string, maxResults: number = 5): Promise<{totalResults: number, papers: any[]}> { try { const results = await arxivClient.search({ start: 0, searchQuery: { include: [ { field: "all", value: query } ] }, maxResults: maxResults }); const papers = results.entries.map(entry => { const urlParts = entry.url.split('/'); const arxivId = urlParts[urlParts.length - 1]; return { id: arxivId, url: entry.url, title: entry.title.replace(/\s+/g, ' ').trim(), summary: entry.summary.replace(/\s+/g, ' ').trim(), published: entry.published, authors: entry.authors || [] }; }); return { totalResults: results.totalResults, papers: papers }; } catch (error) { console.error("搜索 arXiv 论文时出错:", error); throw new Error(`搜索失败: ${error instanceof Error ? error.message : String(error)}`); } }
  • Input schema for the 'search_arxiv' tool, defining parameters query (required string) and maxResults (optional number, default 5).
    inputSchema: { type: "object", properties: { query: { type: "string", description: "搜索英文关键词" }, maxResults: { type: "number", description: "最大结果数量", default: 5 } }, required: ["query"] }
  • src/index.ts:324-342 (registration)
    Registration of the 'search_arxiv' tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    { name: "search_arxiv", description: "搜索 arXiv 论文", inputSchema: { type: "object", properties: { query: { type: "string", description: "搜索英文关键词" }, maxResults: { type: "number", description: "最大结果数量", default: 5 } }, required: ["query"] } },
  • Execution handler in the CallToolRequestSchema switch statement that calls searchArxivPapers and formats the response for MCP.
    case "search_arxiv": { const { query, maxResults = 5 } = args as { query: string; maxResults?: number }; const results = await searchArxivPapers(query, maxResults); return { content: [{ type: "text", text: `找到 ${results.papers.length} 篇相关论文(总计 ${results.totalResults} 篇):\n\n${results.papers.map((paper, index) => `${index + 1}. **${paper.title}**\n ID: ${paper.id}\n 发布日期: ${paper.published}\n 作者: ${paper.authors.map((author: any) => author.name || author).join(', ')}\n 摘要: ${paper.summary.substring(0, 300)}...\n URL: ${paper.url}\n` ).join('\n')}` }] }; }

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/yzfly/Arxiv-Paper-MCP'

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