Skip to main content
Glama

extract_github

Read-only

Extract real-time GitHub repository data including README, stars, forks, language, topics, and last commit. Returns timestamped information for accurate, current insights.

Instructions

Extract real-time data from a GitHub repository — README, stars, forks, language, topics, last commit. Returns timestamped freshcontext.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesFull GitHub repo URL e.g. https://github.com/owner/repo
max_lengthNoMax content length

Implementation Reference

  • The `githubAdapter` function performs the actual scraping and data extraction of GitHub repository details using Playwright.
    export async function githubAdapter(options: ExtractOptions): Promise<AdapterResult> {
      const safeUrl = validateUrl(options.url, "github");
      options = { ...options, url: safeUrl };
    
      const browser = await chromium.launch({ headless: true });
      const page = await browser.newPage();
    
      // Spoof a real browser UA to avoid bot detection
      await page.setExtraHTTPHeaders({
        "User-Agent":
          "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
      });
    
      await page.goto(options.url, { waitUntil: "domcontentloaded", timeout: 20000 });
    
      // Extract key repo signals — no inner functions to avoid esbuild __name injection
      const data = await page.evaluate(`(function() {
        var readme = (document.querySelector('[data-target="readme-toc.content"]') || document.querySelector('.markdown-body') || {}).textContent || null;
        var starsEl = document.querySelector('[id="repo-stars-counter-star"]') || document.querySelector('.Counter.js-social-count');
        var stars = starsEl ? starsEl.textContent.trim() : null;
        var forksEl = document.querySelector('[id="repo-network-counter"]');
        var forks = forksEl ? forksEl.textContent.trim() : null;
        var commitEl = document.querySelector('relative-time');
        var lastCommit = commitEl ? commitEl.getAttribute('datetime') : null;
        var descEl = document.querySelector('.f4.my-3');
        var description = descEl ? descEl.textContent.trim() : null;
        var topics = Array.from(document.querySelectorAll('.topic-tag')).map(function(t) { return t.textContent.trim(); });
        var langEl = document.querySelector('.color-fg-default.text-bold.mr-1');
        var language = langEl ? langEl.textContent.trim() : null;
        return { readme: readme, stars: stars, forks: forks, lastCommit: lastCommit, description: description, topics: topics, language: language };
      })()`);
      const typedData = data as { readme: string | null; stars: string | null; forks: string | null; lastCommit: string | null; description: string | null; topics: string[]; language: string | null };
    
      await browser.close();
    
      const raw = [
        `Description: ${typedData.description ?? "N/A"}`,
        `Stars: ${typedData.stars ?? "N/A"} | Forks: ${typedData.forks ?? "N/A"}`,
        `Language: ${typedData.language ?? "N/A"}`,
        `Last commit: ${typedData.lastCommit ?? "N/A"}`,
        `Topics: ${typedData.topics?.join(", ") ?? "none"}`,
        `\n--- README ---\n${typedData.readme ?? "No README found"}`,
      ].join("\n");
    
      return {
        raw,
        content_date: typedData.lastCommit ?? null,
        freshness_confidence: typedData.lastCommit ? "high" : "medium",
      };
    }
  • src/server.ts:28-49 (registration)
    Tool registration for `extract_github` in `src/server.ts`, which calls `githubAdapter`.
    // ─── Tool: extract_github ────────────────────────────────────────────────────
    server.registerTool(
      "extract_github",
      {
        description:
          "Extract real-time data from a GitHub repository — README, stars, forks, language, topics, last commit. Returns timestamped freshcontext.",
        inputSchema: z.object({
          url: z.string().url().describe("Full GitHub repo URL e.g. https://github.com/owner/repo"),
          max_length: z.number().optional().default(6000).describe("Max content length"),
        }),
        annotations: { readOnlyHint: true, openWorldHint: true },
      },
      async ({ url, max_length }) => {
        try {
          const result = await githubAdapter({ url, maxLength: max_length });
          const ctx = stampFreshness(result, { url, maxLength: max_length }, "github");
          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 indicate readOnlyHint=true and openWorldHint=true, covering safety and data scope. The description adds value by specifying 'real-time data' and 'timestamped freshcontext', implying freshness and temporal context, and lists exact data fields extracted. It doesn't contradict annotations, but also doesn't disclose additional traits like rate limits, authentication needs, or error handling beyond what annotations provide.

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

Conciseness4/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 key details (data fields, return context). It avoids redundancy and wastes no words, though it could be slightly more structured by separating usage notes. Overall, it's appropriately sized for the tool's complexity.

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), annotations cover safety and scope, and the description adds specific data fields and temporal context. It adequately informs the agent about what the tool does and returns, though it lacks details on output format or error cases. With annotations handling key behavioral aspects, the description is sufficiently complete for effective use.

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 100%, with parameters 'url' and 'max_length' well-documented in the schema. The description doesn't add meaning beyond the schema, as it doesn't explain parameter usage, constraints, or interactions. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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

Purpose4/5

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

The description clearly states the verb 'extract' and resource 'real-time data from a GitHub repository', listing specific data fields (README, stars, forks, etc.) and mentioning the return includes 'timestamped freshcontext'. It distinguishes from siblings by specifying GitHub as the source, unlike other extract tools targeting different platforms (e.g., HackerNews, SEC filings). However, it doesn't explicitly contrast with sibling 'extract_landscape' or 'search_repos', which might overlap in scope.

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

Usage Guidelines3/5

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

The description implies usage for extracting GitHub repository data, but provides no explicit guidance on when to use this tool versus alternatives like 'extract_landscape' (which might handle broader data) or 'search_repos' (which might involve querying). It mentions 'real-time data' and 'timestamped freshcontext', suggesting timeliness, but lacks clear when-not-to-use scenarios or prerequisites.

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