Skip to main content
Glama
piyushgIITian

GitHub Enterprise MCP Server

search-repositories

Find GitHub repositories using search queries with GitHub's search syntax to locate specific codebases, projects, or organizations based on criteria like name, description, language, or topic.

Instructions

Search for GitHub repositories

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNoPage number for pagination (default: 1)
perPageNoNumber of results per page (default: 30, max: 100)
queryYesSearch query (see GitHub search syntax)

Implementation Reference

  • The main handler function for 'search-repositories' tool. Validates input using SearchRepositoriesSchema, calls GitHub's search.repos API, maps and returns the results.
    export async function searchRepositories(args: unknown): Promise<any> { const { query, page, perPage } = SearchRepositoriesSchema.parse(args); const github = getGitHubApi(); return tryCatchAsync(async () => { const { data } = await github.getOctokit().search.repos({ q: query, page, per_page: perPage, }); return { total_count: data.total_count, incomplete_results: data.incomplete_results, items: data.items.map((repo) => ({ id: repo.id, name: repo.name, full_name: repo.full_name, owner: repo.owner ? { login: repo.owner.login, id: repo.owner.id, type: repo.owner.type, } : null, private: repo.private, description: repo.description, fork: repo.fork, created_at: repo.created_at, updated_at: repo.updated_at, pushed_at: repo.pushed_at, homepage: repo.homepage, size: repo.size, stargazers_count: repo.stargazers_count, watchers_count: repo.watchers_count, language: repo.language, forks_count: repo.forks_count, open_issues_count: repo.open_issues_count, default_branch: repo.default_branch, url: repo.html_url, })), }; }, 'Failed to search repositories'); }
  • Zod schema defining the input parameters for the search-repositories tool, used for validation in the handler.
    export const SearchRepositoriesSchema = z.object({ query: z.string().min(1, 'Search query is required'), page: z.number().optional(), perPage: z.number().min(1).max(100).optional(), });
  • src/server.ts:102-124 (registration)
    Tool registration in the server's listTools handler, defining name, description, and input schema.
    { name: 'search-repositories', description: 'Search for GitHub repositories', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (see GitHub search syntax)', }, page: { type: 'number', description: 'Page number for pagination (default: 1)', }, perPage: { type: 'number', description: 'Number of results per page (default: 30, max: 100)', }, }, required: ['query'], additionalProperties: false, }, },
  • Dispatch case in the server's CallToolRequest handler that invokes the searchRepositories function.
    case 'search-repositories': result = await searchRepositories(parsedArgs); break;

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/piyushgIITian/github-enterprice-mcp'

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