search_papers_by_author
Find academic papers by a specific author. Search results can be sorted by publication year or citation count, with pagination support for research.
Instructions
Search papers published by a specific author
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| author | Yes | Author name | |
| page | No | Page number, starting from 0 | |
| size | No | Number of papers per page, maximum 10 | |
| order | No | Sort order: year (by publication year) or n_citation (by citation count) |
Implementation Reference
- src/index.ts:125-149 (handler)MCP tool handler that executes the search_papers_by_author logic by calling AminerClient.searchByAuthor, formatting results, and returning as text content or error.async ({ author, page, size, order }) => { try { const result = await aminerClient.searchByAuthor(author, page, size, order); const formattedResult = aminerClient.formatSearchResults(result); return { content: [{ type: "text", text: JSON.stringify(formattedResult, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: "Search failed", message: error instanceof Error ? error.message : 'Unknown error' }, null, 2) }], isError: true }; } } );
- src/index.ts:118-123 (schema)Input schema using Zod for validating tool parameters: author (required string), page, size, order.inputSchema: { author: z.string().describe("Author name"), page: z.number().min(0).default(0).describe("Page number, starting from 0"), size: z.number().min(1).max(10).default(10).describe("Number of papers per page, maximum 10"), order: z.enum(["year", "n_citation"]).optional().describe("Sort order: year (by publication year) or n_citation (by citation count)") }
- src/index.ts:113-149 (registration)Registration of the search_papers_by_author tool on the MCP server, including name, metadata, schema, and handler reference.server.registerTool( "search_papers_by_author", { title: "Search Papers by Author", description: "Search papers published by a specific author", inputSchema: { author: z.string().describe("Author name"), page: z.number().min(0).default(0).describe("Page number, starting from 0"), size: z.number().min(1).max(10).default(10).describe("Number of papers per page, maximum 10"), order: z.enum(["year", "n_citation"]).optional().describe("Sort order: year (by publication year) or n_citation (by citation count)") } }, async ({ author, page, size, order }) => { try { const result = await aminerClient.searchByAuthor(author, page, size, order); const formattedResult = aminerClient.formatSearchResults(result); return { content: [{ type: "text", text: JSON.stringify(formattedResult, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: "Search failed", message: error instanceof Error ? error.message : 'Unknown error' }, null, 2) }], isError: true }; } } );
- src/aminer-client.ts:110-115 (helper)AminerClient method searchByAuthor that wraps searchPapers with the author parameter./** * Search papers by author */ async searchByAuthor(author: string, page = 0, size = 10, order?: 'year' | 'n_citation'): Promise<SearchResult> { return this.searchPapers({ author, page, size, order }); }
- src/aminer-client.ts:27-94 (helper)Core searchPapers helper in AminerClient performing the actual API call to search papers by author (or other params) via HTTP GET with auth.async searchPapers(params: SearchParams): Promise<SearchResult> { // Validate required parameters if (!params.keyword && !params.venue && !params.author) { throw new Error('At least one of keyword, venue, or author must be provided'); } if (params.size > 10) { throw new Error('Size parameter cannot exceed 10'); } // Build query parameters const searchParams = new URLSearchParams(); if (params.keyword) searchParams.append('keyword', params.keyword); if (params.venue) searchParams.append('venue', params.venue); if (params.author) searchParams.append('author', params.author); searchParams.append('page', params.page.toString()); searchParams.append('size', params.size.toString()); if (params.order) searchParams.append('order', params.order); const url = `${this.config.baseUrl}?${searchParams.toString()}`; try { const response = await fetch(url, { method: 'GET', headers: { 'Authorization': this.config.apiKey, 'Content-Type': 'application/json', }, }); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } const data = await response.json() as AminerSearchResponse; // Add detailed response data check if (!data) { throw new Error('API returned empty response'); } if (!data.success) { throw new Error(`API Error (${data.code}): ${data.msg}`); } // Check the completeness of the response data if (typeof data.total !== 'number') { console.warn('API response missing or invalid total field, defaulting to 0'); } // Ensure data.data is not null, if it is null, use an empty array const papers = data.data || []; const total = data.total || 0; return { papers, total, page: params.page, size: params.size, hasMore: (params.page + 1) * params.size < total, }; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to search papers: ${error.message}`); } throw new Error('Unknown error occurred while searching papers'); } }