Skip to main content
Glama

extract_scholar

Read-only

Extract research results from Google Scholar search URLs to get titles, authors, publication years, and snippets with timestamps for data freshness awareness.

Instructions

Extract research results from a Google Scholar search URL. Returns titles, authors, publication years, and snippets — all timestamped.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesGoogle Scholar search URL e.g. https://scholar.google.com/scholar?q=...
max_lengthNo

Implementation Reference

  • The core logic for extracting research results from Google Scholar using Playwright.
    export async function scholarAdapter(options: ExtractOptions): Promise<AdapterResult> {
      const safeUrl = validateUrl(options.url, "scholar");
      options = { ...options, url: safeUrl };
    
      const browser = await chromium.launch({ headless: true });
      const page = await browser.newPage();
    
      await page.setExtraHTTPHeaders({
        "User-Agent":
          "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
      });
    
      await page.goto(options.url, { waitUntil: "domcontentloaded", timeout: 20000 });
    
      const data = await page.evaluate(`(function() {
        var items = Array.from(document.querySelectorAll('.gs_r.gs_or.gs_scl'));
        var results = items.map(function(el) {
          var titleEl = el.querySelector('.gs_rt');
          var title = titleEl ? titleEl.textContent.trim() : null;
          var authorsEl = el.querySelector('.gs_a');
          var authors = authorsEl ? authorsEl.textContent.trim() : null;
          var snippetEl = el.querySelector('.gs_rs');
          var snippet = snippetEl ? snippetEl.textContent.trim() : null;
          var linkEl = el.querySelector('.gs_rt a');
          var link = linkEl ? linkEl.getAttribute('href') : null;
          var yearMatch = authors ? authors.match(/\\b(19|20)\\d{2}\\b/) : null;
          var year = yearMatch ? yearMatch[0] : null;
          return { title: title, authors: authors, snippet: snippet, link: link, year: year };
        });
        return results;
      })()`);
    
      await browser.close();
    
      const typedData = data as Array<{ title: string | null; authors: string | null; snippet: string | null; link: string | null; year: string | null }>;
    
      if (!typedData.length) {
        return {
          raw: "No results found on this Scholar page.",
          content_date: null,
          freshness_confidence: "low",
        };
      }
    
      const raw = typedData
        .map((r, i) =>
          [
            `[${i + 1}] ${r.title ?? "Untitled"}`,
            `Authors: ${r.authors ?? "Unknown"}`,
            `Year: ${r.year ?? "Unknown"}`,
            `Snippet: ${r.snippet ?? "N/A"}`,
            `Link: ${r.link ?? "N/A"}`,
          ].join("\n")
        )
        .join("\n\n");
    
      const years = typedData.map((r) => r.year).filter(Boolean) as string[];
      const newestYear = years.sort().reverse()[0] ?? null;
    
      return {
        raw,
        content_date: newestYear ? `${newestYear}-01-01` : null,
        freshness_confidence: newestYear ? "high" : "low",
      };
    }
  • src/server.ts:52-70 (registration)
    Registration of the 'extract_scholar' tool and its associated schema and handler wrapper.
    server.registerTool(
      "extract_scholar",
      {
        description:
          "Extract research results from a Google Scholar search URL. Returns titles, authors, publication years, and snippets — all timestamped.",
        inputSchema: z.object({
          url: z.string().url().describe("Google Scholar search URL e.g. https://scholar.google.com/scholar?q=..."),
          max_length: z.number().optional().default(6000),
        }),
        annotations: { readOnlyHint: true, openWorldHint: true },
      },
      async ({ url, max_length }) => {
        try {
          const result = await scholarAdapter({ url, maxLength: max_length });
          const ctx = stampFreshness(result, { url, maxLength: max_length }, "google_scholar");
          return { content: [{ type: "text", text: formatForLLM(ctx) }] };
        } catch (err) {
          return { content: [{ type: "text", text: formatSecurityError(err) }] };
        }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations provide readOnlyHint=true (safe read operation) and openWorldHint=true (can handle diverse inputs), which cover basic behavioral traits. The description adds value by specifying the output format (titles, authors, etc.) and timestamping, but does not disclose additional behavioral aspects like rate limits, authentication needs, or error handling. There is no contradiction with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the purpose and output details without unnecessary words. Every part earns its place by conveying essential information about the tool's function and results.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no output schema), the description is reasonably complete: it covers the purpose, source, and output format. However, it lacks details on parameter usage (especially 'max_length'), error cases, or behavioral nuances like pagination or data limits, which could be helpful for an agent. Annotations provide some safety context, but more operational guidance would enhance completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 50% (only the 'url' parameter has a description). The description adds no specific parameter semantics beyond what the schema provides—it mentions 'Google Scholar search URL' which aligns with the schema's 'url' description, but does not explain 'max_length' or provide additional context like format examples or constraints. With partial schema coverage, the description does not fully compensate for the gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('extract research results'), source ('from a Google Scholar search URL'), and output format ('titles, authors, publication years, and snippets — all timestamped'). It distinguishes itself from sibling tools by specifying Google Scholar as the source, unlike other extraction tools targeting different platforms like GitHub, HackerNews, or SEC filings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying 'Google Scholar search URL' as the input, indicating this tool is for extracting data from Scholar searches rather than other sources. However, it does not explicitly state when to use this tool versus alternatives (e.g., other extract_* tools) or provide exclusions, such as whether it works with non-search URLs or other academic databases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/PrinceGabriel-lgtm/freshcontext-mcp'

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