Skip to main content
Glama
alsonwangkhem

GitHub MCP Server

list-issues

Retrieve issues from a GitHub repository by specifying owner, repository name, state (open/closed/all), and optional limit to manage and track project tasks.

Instructions

List issues in a GitHub repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYesRepository owner (username or organization)
repoYesRepository name
stateNoIssue state
limitNoMaximum number of issues to return

Implementation Reference

  • The main handler function that executes the list-issues tool logic, fetching issues from a GitHub repository using the Octokit client and returning formatted JSON.
    const listIssues = async (args: ListIssuesArgs) => {
      const { owner, repo, state = "open", limit = 10 } = args;
      
      try {
        const response = await octokit.rest.issues.listForRepo({
          owner,
          repo,
          state,
          per_page: limit,
        });
        
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                response.data.map(issue => ({
                  number: issue.number,
                  title: issue.title,
                  state: issue.state,
                  created_at: issue.created_at,
                  updated_at: issue.updated_at,
                  user: issue.user?.login,
                  labels: issue.labels.map(label => 
                    typeof label === 'string' ? label : label.name
                  ),
                  url: issue.html_url,
                  comments: issue.comments,
                })),
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
        return {
          content: [
            {
              type: "text",
              text: `Error listing issues: ${errorMessage}`,
            },
          ],
        };
      }
    };
  • Input schema definition for the list-issues tool, specifying parameters like owner, repo, state, and limit.
    "list-issues": {
      name: "list-issues",
      description: "List issues in a GitHub repository",
      inputSchema: {
        type: "object",
        properties: {
          owner: {
            type: "string",
            description: "Repository owner (username or organization)",
          },
          repo: {
            type: "string",
            description: "Repository name",
          },
          state: {
            type: "string",
            enum: ["open", "closed", "all"],
            description: "Issue state",
          },
          limit: {
            type: "number",
            description: "Maximum number of issues to return",
          }
        },
        required: ["owner", "repo"],
      },
    },
  • src/tools.ts:322-327 (registration)
    Export of the toolHandlers mapping that associates the 'list-issues' name with its handler function listIssues.
    export const toolHandlers = {
      "search-repos": searchRepos,
      "get-repo-info": getRepoInfo,
      "list-issues": listIssues,
      "create-issue": createIssue,
    };
  • src/handlers.ts:22-31 (registration)
    MCP server handler for CallToolRequestSchema that dynamically invokes the tool handler based on the tool name 'list-issues' from toolHandlers.
    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);
    })
  • src/handlers.ts:19-21 (registration)
    MCP server handler for ListToolsRequestSchema that lists all available tools including the schema for 'list-issues'.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: Object.values(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