Skip to main content
Glama
alsonwangkhem

GitHub MCP Server

search-repos

Search GitHub repositories using queries and filters to find relevant code projects, with options to sort by stars, forks, help-wanted issues, or update date.

Instructions

Search for GitHub repositories

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
sortNoSort order
limitNoMaximum number of results to return

Implementation Reference

  • The main handler function for the 'search-repos' tool. It takes search arguments, queries the GitHub API using Octokit, maps the results to a simplified format, and returns them as JSON text content or an error message.
    const searchRepos = async (args: SearchReposArgs) => {
      const { query, sort = "stars", limit = 5 } = args;
      
      try {
        const response = await octokit.rest.search.repos({
          q: query,
          sort,
          per_page: limit,
        });
        
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                response.data.items.map(repo => ({
                  name: repo.full_name,
                  description: repo.description,
                  stars: repo.stargazers_count,
                  url: repo.html_url,
                  language: repo.language,
                  forks: repo.forks_count,
                })),
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
        return {
          content: [
            {
              type: "text",
              text: `Error searching repositories: ${errorMessage}`,
            },
          ],
        };
      }
    };
  • Tool specification including name, description, and input schema defining the expected parameters (query required, sort enum, limit number).
    "search-repos": {
      name: "search-repos",
      description: "Search for GitHub repositories",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Search query",
          },
          sort: {
            type: "string",
            enum: ["stars", "forks", "help-wanted-issues", "updated"],
            description: "Sort order",
          },
          limit: {
            type: "number",
            description: "Maximum number of results to return",
          }
        },
        required: ["query"],
      },
    },
  • src/tools.ts:322-327 (registration)
    Maps the 'search-repos' name to its handler function (searchRepos) in the toolHandlers export, which is imported and used by the MCP server in handlers.ts to dispatch tool calls.
    export const toolHandlers = {
      "search-repos": searchRepos,
      "get-repo-info": getRepoInfo,
      "list-issues": listIssues,
      "create-issue": createIssue,
    };
  • src/handlers.ts:22-31 (registration)
    Registers the generic tool call handler with MCP server using CallToolRequestSchema, which looks up and invokes the specific handler from toolHandlers based on the tool name 'search-repos'.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
        type ToolHandlerKey = keyof typeof toolHandlers;
        const { name, arguments: params } = request.params ?? {};
        const handler = toolHandlers[name as ToolHandlerKey];
    
        if (!handler) throw new Error("tool not found");
    
        type HandlerParams = Parameters<typeof handler>;
        return handler(params as any);
    })
  • TypeScript type definition for the input arguments of the search-repos handler, matching the inputSchema.
    type SearchReposArgs = {
      query: string;
      sort?: "stars" | "forks" | "help-wanted-issues" | "updated";
      limit?: number;
    };
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but provides minimal information. It mentions 'search' but doesn't disclose rate limits, authentication requirements, result format, pagination behavior, or what happens when no results are found. For a search tool with zero annotation coverage, this leaves significant behavioral gaps.

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 extremely concise at just four words, with zero wasted language. It's front-loaded with the essential purpose and doesn't include any unnecessary information. Every word earns its place in this minimal description.

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

Completeness2/5

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

For a search tool with 3 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns (repository objects? just names?), doesn't mention authentication needs, rate limits, or error conditions. The combination of missing behavioral context and lack of output information creates significant gaps.

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?

The schema has 100% description coverage, with all parameters well-documented in the schema itself. The description adds no additional parameter information beyond what's already in the schema - it doesn't explain search syntax, default values, or provide examples. The baseline of 3 is appropriate when the schema does the heavy lifting.

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 'Search for GitHub repositories' clearly states the verb ('Search') and resource ('GitHub repositories'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get-repo-info' or 'list-issues' - it doesn't specify this is for finding repositories by search criteria rather than retrieving specific repository details or listing issues.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to use search-repos instead of get-repo-info (for specific repository details) or list-issues (for repository issues), nor does it provide any context about prerequisites, limitations, or typical use cases.

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/alsonwangkhem/github-mcp-2'

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