Skip to main content
Glama

search_google_scholar

Search academic papers on Google Scholar by query, author, or publication year to find relevant research publications.

Instructions

Search Google Scholar for academic papers using web scraping

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query string
maxResultsNoMaximum number of results to return
yearLowNoEarliest publication year
yearHighNoLatest publication year
authorNoAuthor name filter

Implementation Reference

  • Core implementation of the search_google_scholar tool: the search() method in GoogleScholarSearcher class that performs web scraping on Google Scholar using axios and cheerio, parses results, handles pagination, anti-detection (random delays, user agents), extracts metadata like title, authors, year, citations, etc.
    async search(query: string, options: GoogleScholarOptions = {}): Promise<Paper[]> { logDebug(`Google Scholar Search: query="${query}"`); try { const papers: Paper[] = []; let start = 0; const resultsPerPage = 10; const maxResults = options.maxResults || 10; while (papers.length < maxResults) { // 添加随机延迟避免检测 await this.randomDelay(); const params = this.buildSearchParams(query, start, options); const response = await this.makeScholarRequest(params); if (response.status !== 200) { logDebug(`Google Scholar HTTP Error: ${response.status}`); break; } const $ = cheerio.load(response.data); const results = $('.gs_ri'); // 搜索结果容器 if (results.length === 0) { logDebug('Google Scholar: No more results found'); break; } logDebug(`Google Scholar: Found ${results.length} results on page`); // 解析每个结果 results.each((index, element) => { if (papers.length >= maxResults) return false; // 停止遍历 const paper = this.parseScholarResult($, $(element)); if (paper) { papers.push(paper); } }); start += resultsPerPage; } logDebug(`Google Scholar Results: Found ${papers.length} papers`); return papers; } catch (error) { this.handleHttpError(error, 'search'); } }
  • MCP tool call handler: switch case that parses args, calls searchers.googlescholar.search(), converts results to JSON dicts, and returns formatted text response.
    case 'search_google_scholar': { const { query, maxResults, yearLow, yearHigh, author } = args; const results = await searchers.googlescholar.search(query, { maxResults, yearLow, yearHigh, author } as any); return jsonTextResponse( `Found ${results.length} Google Scholar papers.\n\n${JSON.stringify( results.map((paper: Paper) => PaperFactory.toDict(paper)), null, 2 )}` ); }
  • Zod schema for validating input arguments to search_google_scholar tool.
    export const SearchGoogleScholarSchema = z .object({ query: z.string().min(1), maxResults: z.number().int().min(1).max(20).optional().default(10), yearLow: z.number().int().optional(), yearHigh: z.number().int().optional(), author: z.string().optional() }) .strip();
  • MCP tool registration: definition of the tool including name, description, and inputSchema exported in TOOLS array.
    name: 'search_google_scholar', description: 'Search Google Scholar for academic papers using web scraping', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query string' }, maxResults: { type: 'number', minimum: 1, maximum: 20, description: 'Maximum number of results to return' }, yearLow: { type: 'number', description: 'Earliest publication year' }, yearHigh: { type: 'number', description: 'Latest publication year' }, author: { type: 'string', description: 'Author name filter' } }, required: ['query'] }
  • Instantiation of GoogleScholarSearcher as searchers.googlescholar (also aliased as scholar).
    const googleScholarSearcher = new GoogleScholarSearcher();

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/Dianel555/paper-search-mcp-nodejs'

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