Skip to main content
Glama

search_by_category

Find academic papers in specific arXiv categories using category codes like cs.AI or physics.optics. Filter results by date, relevance, and sort order to locate research efficiently.

Instructions

Search for papers in a specific arXiv category

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYesarXiv category (e.g., cs.AI, physics.optics)
startNoStarting index for pagination (0-based)
max_resultsNoMaximum number of results to return (max 2000)
sort_byNoSort by: relevance, lastUpdatedDate, submittedDate
sort_orderNoSort order: ascending or descending

Implementation Reference

  • The primary handler function that implements the search_by_category tool logic. It builds arXiv API search parameters using the provided category prefixed with 'cat:', applies optional pagination and sorting, queries the arXiv API via queryArxiv, processes the response, and returns formatted results.
    private async searchByCategory(args: SearchByCategoryArgs) { const searchParams: SearchParams = { search_query: `cat:${args.category}`, }; // 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:169-200 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining the tool name, description, and input schema for validation.
    { name: 'search_by_category', description: 'Search for papers in a specific arXiv category', inputSchema: { type: 'object', properties: { category: { type: 'string', description: 'arXiv category (e.g., cs.AI, physics.optics)', }, 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'], }, }, required: ['category'], }, },
  • TypeScript interface defining the input arguments for the searchByCategory handler, used for type safety.
    interface SearchByCategoryArgs { category: string; start?: number; max_results?: number; sort_by?: string; sort_order?: string; }
  • Dispatch handler in the CallToolRequestSchema that validates input and invokes the searchByCategory method.
    case 'search_by_category': if (!request.params.arguments || typeof request.params.arguments.category !== 'string') { throw new McpError( ErrorCode.InvalidParams, 'Missing or invalid category parameter' ); } return await this.searchByCategory(request.params.arguments as unknown as SearchByCategoryArgs);
  • src/index.ts:97-97 (registration)
    Exposes the handler method for testing via _testMethods.
    searchByCategory: this.searchByCategory.bind(this),

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/Mnehmos/mnehmos.arxiv.mcp'

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