Skip to main content
Glama

search-repos

Find GitHub repositories using specific queries, sort results by stars, forks, or activity, and limit output for precise results.

Instructions

Search for GitHub repositories

Input Schema

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

Implementation Reference

  • The main handler function `searchRepos` that executes the GitHub repository search using the Octokit client, processes results, and handles errors.
    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}`, }, ], }; } };
  • The input schema definition for the 'search-repos' tool, including properties for query, sort, and limit.
    "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)
    Registration of tool handlers, mapping 'search-repos' to the searchRepos function.
    export const toolHandlers = { "search-repos": searchRepos, "get-repo-info": getRepoInfo, "list-issues": listIssues, "create-issue": createIssue, };
  • Type definition for the arguments accepted by the searchRepos handler.
    type SearchReposArgs = { query: string; sort?: "stars" | "forks" | "help-wanted-issues" | "updated"; limit?: number; };

Other Tools

Related 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