Skip to main content
Glama

search_arxiv

Search academic papers from arXiv using keywords to find relevant research articles and access paper content for academic purposes.

Instructions

搜索 arXiv 论文

Input Schema

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

Implementation Reference

  • Core handler function that performs the arXiv paper search using ArXivClient and processes the results into a structured format.
    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)}`); } }
  • MCP CallToolRequestSchema dispatch case for 'search_arxiv' that invokes the core search function and formats the tool response.
    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')}` }] }; }
  • src/index.ts:324-341 (registration)
    Tool registration definition returned by ListToolsRequestSchema handler, specifying name, description, and input schema for 'search_arxiv'.
    { name: "search_arxiv", description: "搜索 arXiv 论文", inputSchema: { type: "object", properties: { query: { type: "string", description: "搜索英文关键词" }, maxResults: { type: "number", description: "最大结果数量", default: 5 } }, required: ["query"] }
  • Input schema definition 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"] }

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/BACH-AI-Tools/bach-Arxiv-Paper-MCP'

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