search_papers
Search for arXiv papers by query, category, author, title, or abstract. Retrieve results with pagination, sorting by relevance, date, and order. Ideal for precise academic research.
Instructions
Search for papers on arXiv by various criteria
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| abstract | No | Words in the abstract | |
| author | No | Author name | |
| category | No | arXiv category (e.g., cs.AI, physics.optics) | |
| max_results | No | Maximum number of results to return (max 2000) | |
| query | No | General search query across all fields | |
| sort_by | No | Sort by: relevance, lastUpdatedDate, submittedDate | |
| sort_order | No | Sort order: ascending or descending | |
| start | No | Starting index for pagination (0-based) | |
| title | No | Words in the title |
Implementation Reference
- src/index.ts:270-329 (handler)The main handler function for the 'search_papers' tool. It constructs arXiv API search parameters from input args, calls queryArxiv, and returns the processed results as JSON.public async searchPapers(args: SearchPapersArgs) { const searchParams: SearchParams = {}; // Build search query const searchTerms: string[] = []; if (args.query) { searchTerms.push(`all:${args.query}`); } if (args.category) { searchTerms.push(`cat:${args.category}`); } if (args.author) { searchTerms.push(`au:${args.author}`); } if (args.title) { searchTerms.push(`ti:${args.title}`); } if (args.abstract) { searchTerms.push(`abs:${args.abstract}`); } if (searchTerms.length > 0) { searchParams.search_query = searchTerms.join('+AND+'); } // Add pagination if (args.start !== undefined) { searchParams.start = args.start; } if (args.max_results !== undefined) { searchParams.max_results = Math.min(args.max_results, 2000); // API limit } else { searchParams.max_results = 10; // Default } // Add sorting if (args.sort_by) { searchParams.sortBy = args.sort_by; } if (args.sort_order) { searchParams.sortOrder = args.sort_order; } const response = await this.queryArxiv(searchParams); return { content: [ { type: 'text', text: JSON.stringify(response, null, 2), }, ], }; }
- src/index.ts:108-154 (registration)Registration of the 'search_papers' tool in the ListToolsRequestSchema handler, including name, description, and detailed JSON input schema.{ name: 'search_papers', description: 'Search for papers on arXiv by various criteria', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'General search query across all fields', }, category: { type: 'string', description: 'arXiv category (e.g., cs.AI, physics.optics)', }, author: { type: 'string', description: 'Author name', }, title: { type: 'string', description: 'Words in the title', }, abstract: { type: 'string', description: 'Words in the abstract', }, start: { type: 'number', description: 'Starting index for pagination (0-based)', }, max_results: { type: 'number', description: 'Maximum number of results to return (max 2000)', }, sort_by: { type: 'string', description: 'Sort by: relevance, lastUpdatedDate, submittedDate', enum: ['relevance', 'lastUpdatedDate', 'submittedDate'], }, sort_order: { type: 'string', description: 'Sort order: ascending or descending', enum: ['ascending', 'descending'], }, }, }, },
- src/index.ts:32-42 (schema)TypeScript interface defining the input parameters for the search_papers handler function.interface SearchPapersArgs { query?: string; category?: string; author?: string; title?: string; abstract?: string; start?: number; max_results?: number; sort_by?: string; sort_order?: string; }
- src/index.ts:221-222 (registration)Tool dispatcher case in the CallToolRequestSchema handler that invokes the searchPapers method.case 'search_papers': return await this.searchPapers(request.params.arguments as unknown as SearchPapersArgs);
- src/index.ts:383-398 (helper)Helper method called by searchPapers to query the arXiv API and process the response.private async queryArxiv(params: SearchParams) { try { const response = await axios.get(ARXIV_API_BASE_URL, { params }); // Parse the XML response const xmlData = response.data; // Extract and process the data // For simplicity, we're returning the raw XML data // In a production environment, you would parse this XML into a more usable format return this.processArxivResponse(xmlData); } catch (error) { console.error('Error querying arXiv API:', error); throw error; } }