Skip to main content
Glama

search_repos

Read-only

Find GitHub repositories by keyword or topic to identify competitors, similar tools, or related projects with activity signals and star rankings.

Instructions

Search GitHub for repositories matching a keyword or topic. Returns top results by stars with activity signals. Use to find competitors, similar tools, or related projects.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query e.g. 'mcp server typescript' or 'cashflow prediction python'
max_lengthNo

Implementation Reference

  • src/server.ts:121-130 (registration)
    Registration of the 'search_repos' tool in server.ts.
    server.registerTool(
      "search_repos",
      {
        description:
          "Search GitHub for repositories matching a keyword or topic. Returns top results by stars with activity signals. Use to find competitors, similar tools, or related projects.",
        inputSchema: z.object({
          query: z.string().describe("Search query e.g. 'mcp server typescript' or 'cashflow prediction python'"),
          max_length: z.number().optional().default(6000),
        }),
        annotations: { readOnlyHint: true, openWorldHint: true },
  • The tool handler function in server.ts which calls repoSearchAdapter.
    async ({ query, max_length }) => {
      try {
        const result = await repoSearchAdapter({ url: query, maxLength: max_length });
        const ctx = stampFreshness(result, { url: query, maxLength: max_length }, "github_search");
        return { content: [{ type: "text", text: formatForLLM(ctx) }] };
      } catch (err) {
        return { content: [{ type: "text", text: formatSecurityError(err) }] };
      }
    }
  • The actual implementation of the repoSearch logic.
    export async function repoSearchAdapter(options: ExtractOptions): Promise<AdapterResult> {
      // Sanitize query input
      const query_input = sanitizeQuery(options.url);
      let query = query_input;
    
      // If it's a full URL, extract the query param
      try {
        const parsed = new URL(options.url);
        if (parsed.hostname === "github.com" && parsed.pathname.includes("/search")) {
          query = parsed.searchParams.get("q") ?? options.url;
        } else if (parsed.hostname === "github.com") {
          // It's a direct URL — not a search
          query = parsed.pathname.replace("/search", "").trim().replace(/^\//, "");
        }
      } catch {
        // plain string query, use as-is
      }
    
      const apiUrl = `https://api.github.com/search/repositories?q=${encodeURIComponent(query)}&sort=stars&order=desc&per_page=10`;
    
      const res = await fetch(apiUrl, {
        headers: {
          Accept: "application/vnd.github.v3+json",
          "User-Agent": "freshcontext-mcp/0.1.0",
        },
      });
    
      if (!res.ok) {
        throw new Error(`GitHub Search API error: ${res.status} ${await res.text()}`);
      }
    
      const data = await res.json() as {
        total_count: number;
        items: Array<{
          full_name: string;
          description: string | null;
          html_url: string;
          stargazers_count: number;
          forks_count: number;
          language: string | null;
          topics: string[];
          pushed_at: string;
          created_at: string;
          open_issues_count: number;
        }>;
      };
    
      const raw = [
        `Total matching repos: ${data.total_count.toLocaleString()}`,
        `Top ${data.items.length} by stars:\n`,
        ...data.items.map((r, i) =>
          [
            `[${i + 1}] ${r.full_name}`,
            `⭐ ${r.stargazers_count.toLocaleString()} stars | 🍴 ${r.forks_count} forks | Issues: ${r.open_issues_count}`,
            `Language: ${r.language ?? "unknown"}`,
            `Topics: ${r.topics?.join(", ") || "none"}`,
            `Description: ${r.description ?? "N/A"}`,
            `Last push: ${r.pushed_at}`,
            `Created: ${r.created_at}`,
            `URL: ${r.html_url}`,
          ].join("\n")
        ),
      ]
        .join("\n\n")
        .slice(0, options.maxLength ?? 6000);
    
      // Most recently pushed repo date as content_date
      const dates = data.items.map((r) => r.pushed_at).sort().reverse();
    
      return {
        raw,
        content_date: dates[0] ?? null,
        freshness_confidence: "high",
      };
    }
Behavior3/5

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

Annotations indicate readOnlyHint=true and openWorldHint=true, so the agent knows this is a safe, open-ended search. The description adds context: 'Returns top results by stars with activity signals,' which discloses sorting behavior and additional data beyond basic results. However, it doesn't mention rate limits, authentication needs, or pagination details, so it adds some value but not rich behavioral context beyond annotations.

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 concise and front-loaded: the first sentence states the core purpose, followed by additional context. Both sentences earn their place by clarifying behavior and usage. It's appropriately sized without wasted words, though it could be slightly more structured for optimal clarity.

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

Completeness3/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 present), the description is somewhat complete but has gaps. It covers purpose and basic behavior but lacks details on error handling, exact return format, or how 'activity signals' are defined. With annotations providing safety info, it's adequate but not fully comprehensive for an open-world search tool.

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 'query' parameter has a description). The description doesn't add specific meaning for parameters beyond what's in the schema; it mentions 'keyword or topic' which aligns with 'query' but doesn't explain 'max_length' or provide additional syntax details. With partial schema coverage, the description compensates minimally, meeting the baseline for adequate but not enhanced parameter semantics.

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 tool's purpose: 'Search GitHub for repositories matching a keyword or topic.' It specifies the verb ('Search'), resource ('GitHub repositories'), and scope ('matching a keyword or topic'). However, it doesn't explicitly differentiate from sibling tools like 'extract_github' or 'package_trends', which might have overlapping functionality, so it doesn't reach the highest score.

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 provides implied usage guidance: 'Use to find competitors, similar tools, or related projects.' This gives context for when to use the tool but doesn't explicitly state when not to use it or mention alternatives among sibling tools. For example, it doesn't clarify if 'extract_github' is for different GitHub operations, leaving some ambiguity.

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