Skip to main content
Glama

get-repo-info

Retrieve detailed information about a GitHub repository by specifying its owner and name, enabling users to access repository data through the GitHub MCP Server.

Instructions

Get information about a specific GitHub repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYesRepository owner (username or organization)
repoYesRepository name

Implementation Reference

  • The async handler function `getRepoInfo` that executes the tool logic: fetches GitHub repo info via Octokit and returns JSON-formatted response.
    const getRepoInfo = async (args: GetRepoInfoArgs) => {
      const { owner, repo } = args;
      
      try {
        const response = await octokit.rest.repos.get({
          owner,
          repo,
        });
        
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  name: response.data.full_name,
                  description: response.data.description,
                  stars: response.data.stargazers_count,
                  forks: response.data.forks_count,
                  issues: response.data.open_issues_count,
                  language: response.data.language,
                  created_at: response.data.created_at,
                  updated_at: response.data.updated_at,
                  url: response.data.html_url,
                  default_branch: response.data.default_branch,
                  license: response.data.license?.name || "No license",
                  topics: response.data.topics,
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
        return {
          content: [
            {
              type: "text",
              text: `Error getting repository information: ${errorMessage}`,
            },
          ],
        };
      }
    };
  • The tool schema definition including name, description, and inputSchema for validation.
    "get-repo-info": {
      name: "get-repo-info",
      description: "Get information about a specific GitHub repository",
      inputSchema: {
        type: "object",
        properties: {
          owner: {
            type: "string",
            description: "Repository owner (username or organization)",
          },
          repo: {
            type: "string",
            description: "Repository name",
          }
        },
        required: ["owner", "repo"],
      },
    },
  • src/tools.ts:322-327 (registration)
    Registration of tool handlers in the `toolHandlers` object, mapping tool name to handler function; used by MCP call tool handler.
    export const toolHandlers = {
      "search-repos": searchRepos,
      "get-repo-info": getRepoInfo,
      "list-issues": listIssues,
      "create-issue": createIssue,
    };
  • TypeScript type definition for the tool input arguments.
    type GetRepoInfoArgs = {
      owner: string;
      repo: string;
    };
  • src/handlers.ts:19-32 (registration)
    MCP server request handlers for listing tools (using `tools` object) and calling tools (dispatching to `toolHandlers[name]`).
        server.setRequestHandler(ListToolsRequestSchema, async () => ({
            tools: Object.values(tools)
        }));
        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);
        })
    }

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

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