Skip to main content
Glama
piyushgIITian

GitHub Enterprise MCP Server

update-issue

Modify existing GitHub repository issues by updating titles, descriptions, assignees, milestones, labels, or status through the GitHub Enterprise MCP Server.

Instructions

Update an existing issue in a GitHub repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
assigneesNo
bodyNo
issue_numberYes
labelsNo
milestoneNo
ownerYes
repoYes
stateNo
titleNo

Implementation Reference

  • The primary handler function for the 'update-issue' tool. It validates the input parameters using UpdateIssueSchema, calls the GitHub API to update the specified issue, and returns a formatted response with the updated issue details.
    export async function updateIssue(args: unknown): Promise<any> {
      const { owner, repo, issue_number, title, body, assignees, milestone, labels, state } = UpdateIssueSchema.parse(args);
      const github = getGitHubApi();
    
      return tryCatchAsync(async () => {
        const { data } = await github.getOctokit().issues.update({
          owner,
          repo,
          issue_number,
          title,
          body,
          assignees,
          milestone,
          labels,
          state,
        });
    
        return {
          id: data.id,
          number: data.number,
          title: data.title,
          state: data.state,
          assignees: data.assignees?.map((assignee) => ({
            login: assignee.login,
            id: assignee.id,
          })),
          labels: data.labels?.map((label) => 
            typeof label === 'string' ? label : {
              name: label.name,
              color: label.color,
            }
          ),
          milestone: data.milestone ? {
            number: data.milestone.number,
            title: data.milestone.title,
          } : null,
          updated_at: data.updated_at,
          body: data.body,
          url: data.html_url,
        };
      }, 'Failed to update issue');
    }
  • Zod schema used for input validation in the updateIssue handler, extending OwnerRepoSchema with optional update fields.
    export const UpdateIssueSchema = OwnerRepoSchema.extend({
      issue_number: z.number().int().positive(),
      title: z.string().optional(),
      body: z.string().optional(),
      assignees: z.array(z.string()).optional(),
      milestone: z.number().optional(),
      labels: z.array(z.string()).optional(),
      state: z.enum(['open', 'closed']).optional(),
    });
  • src/server.ts:624-668 (registration)
    MCP tool registration including name, description, and input schema definition passed to server.setTools().
    {
      name: 'update-issue',
      description: 'Update an existing issue in a GitHub repository',
      inputSchema: {
        type: 'object',
        properties: {
          owner: {
            type: 'string',
          },
          repo: {
            type: 'string',
          },
          issue_number: {
            type: 'number',
          },
          title: {
            type: 'string',
          },
          body: {
            type: 'string',
          },
          assignees: {
            type: 'array',
            items: {
              type: 'string',
            },
          },
          milestone: {
            type: 'number',
          },
          labels: {
            type: 'array',
            items: {
              type: 'string',
            },
          },
          state: {
            type: 'string',
            enum: ['open', 'closed'],
          },
        },
        required: ['owner', 'repo', 'issue_number'],
        additionalProperties: false,
      },
    },
  • Dispatch case in the MCP request handler that routes 'update-issue' calls to the updateIssue function.
    case 'update-issue':
      result = await updateIssue(parsedArgs);
      break;
  • Shared GitHub API client utility (getGitHubApi) used by the handler to obtain the Octokit instance.
    import { Octokit } from '@octokit/rest';
    import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
    
    /**
     * GitHub API client wrapper
     */
    export class GitHubApi {
      private octokit: Octokit;
      private baseUrl?: string;
    
      /**
       * Create a new GitHub API client
       * @param token GitHub Personal Access Token
       * @param baseUrl Optional base URL for GitHub Enterprise
       */
      constructor(token: string, baseUrl?: string) {
        if (!token) {
          throw new McpError(
            ErrorCode.ConfigurationError,
            'GitHub Personal Access Token is required'
          );
        }
    
        this.baseUrl = baseUrl;
        this.octokit = new Octokit({
          auth: token,
          ...(baseUrl ? { baseUrl } : {}),
        });
      }
    
      /**
       * Get the Octokit instance

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