search_arxiv
Search academic papers from arXiv preprint server using queries, filters, and sorting options to find relevant research.
Instructions
Search academic papers specifically from arXiv preprint server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query string | |
| maxResults | No | Maximum number of results to return | |
| category | No | arXiv category filter (e.g., cs.AI, physics.gen-ph) | |
| author | No | Author name filter | |
| year | No | Year filter (e.g., "2023", "2020-2023") | |
| sortBy | No | Sort results by field | |
| sortOrder | No | Sort order: ascending or descending |
Implementation Reference
- src/mcp/handleToolCall.ts:84-102 (handler)Handler logic for search_arxiv tool: parses arguments, calls arxiv searcher, formats and returns results as JSON text.case 'search_arxiv': { const { query, maxResults, category, author, year, sortBy, sortOrder } = args; const results = await searchers.arxiv.search(query, { maxResults, category, author, year, sortBy, sortOrder }); return jsonTextResponse( `Found ${results.length} arXiv papers.\n\n${JSON.stringify( results.map((paper: Paper) => PaperFactory.toDict(paper)), null, 2 )}` ); }
- src/mcp/schemas.ts:43-53 (schema)Zod schema definition for search_arxiv input validation.export const SearchArxivSchema = z .object({ query: z.string().min(1), maxResults: z.number().int().min(1).max(50).optional().default(10), category: z.string().optional(), author: z.string().optional(), year: z.string().optional(), sortBy: SortBySchema.optional(), sortOrder: SortOrderSchema.optional() }) .strip();
- src/mcp/tools.ts:71-100 (registration)MCP tool registration: defines name, description, and input schema for search_arxiv.{ name: 'search_arxiv', description: 'Search academic papers specifically from arXiv preprint server', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query string' }, maxResults: { type: 'number', minimum: 1, maximum: 50, description: 'Maximum number of results to return' }, category: { type: 'string', description: 'arXiv category filter (e.g., cs.AI, physics.gen-ph)' }, author: { type: 'string', description: 'Author name filter' }, year: { type: 'string', description: 'Year filter (e.g., "2023", "2020-2023")' }, sortBy: { type: 'string', enum: ['relevance', 'date', 'citations'], description: 'Sort results by field' }, sortOrder: { type: 'string', enum: ['asc', 'desc'], description: 'Sort order: ascending or descending' } }, required: ['query'] } },
- Core search implementation in ArxivSearcher class: builds query for arXiv API, fetches XML, parses into Paper objects.async search(query: string, options: SearchOptions = {}): Promise<Paper[]> { try { const searchQuery = this.buildSearchQuery(query, options); const url = `${this.baseUrl}/query`; // Map sortOrder: arXiv API requires 'ascending' or 'descending' const sortOrderMap: Record<string, string> = { 'asc': 'ascending', 'desc': 'descending', 'ascending': 'ascending', 'descending': 'descending' }; const params = { search_query: searchQuery, max_results: options.maxResults || 10, sortBy: this.mapSortField(options.sortBy || 'relevance'), sortOrder: sortOrderMap[options.sortOrder || 'desc'] || 'descending' }; logDebug(`arXiv API Request: GET ${url}`); logDebug('arXiv Request params:', params); const response = await axios.get(url, { params, timeout: TIMEOUTS.DEFAULT, headers: { 'User-Agent': USER_AGENT } }); logDebug(`arXiv API Response: ${response.status} ${response.statusText}, Data length: ${response.data?.length || 0}`); const papers = await this.parseSearchResponse(response.data); logDebug(`arXiv Parsed ${papers.length} papers`); return papers; } catch (error: any) { logDebug('arXiv Search Error:', error.message); this.handleHttpError(error, 'search'); } }
- src/mcp/searchers.ts:42-61 (helper)Instantiation and registration of ArxivSearcher instance in the global searchers object, used by tool handlers.const arxivSearcher = new ArxivSearcher(); const wosSearcher = new WebOfScienceSearcher(process.env.WOS_API_KEY, process.env.WOS_API_VERSION); const pubmedSearcher = new PubMedSearcher(process.env.PUBMED_API_KEY); const biorxivSearcher = new BioRxivSearcher('biorxiv'); const medrxivSearcher = new MedRxivSearcher(); const semanticSearcher = new SemanticScholarSearcher(process.env.SEMANTIC_SCHOLAR_API_KEY); const iacrSearcher = new IACRSearcher(); const googleScholarSearcher = new GoogleScholarSearcher(); const sciHubSearcher = new SciHubSearcher(); const scienceDirectSearcher = new ScienceDirectSearcher(process.env.ELSEVIER_API_KEY); const springerSearcher = new SpringerSearcher( process.env.SPRINGER_API_KEY, process.env.SPRINGER_OPENACCESS_API_KEY ); const wileySearcher = new WileySearcher(process.env.WILEY_TDM_TOKEN); const scopusSearcher = new ScopusSearcher(process.env.ELSEVIER_API_KEY); const crossrefSearcher = new CrossrefSearcher(process.env.CROSSREF_MAILTO); searchers = { arxiv: arxivSearcher,