Skip to main content
Glama
piyushgIITian

GitHub Enterprise MCP Server

delete-repository

Remove a GitHub repository permanently from GitHub Enterprise. This tool requires repository owner, name, and confirmation to delete the repository and all its contents.

Instructions

Delete a GitHub repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
confirmYesConfirmation for deletion (must be true)
ownerYesRepository owner
repoYesRepository name

Implementation Reference

  • The main handler function that parses input using DeleteRepositorySchema, checks confirmation, calls GitHub API to delete the repository, and returns success message.
    export async function deleteRepository(args: unknown): Promise<any> {
      const { owner, repo, confirm } = DeleteRepositorySchema.parse(args);
      
      if (!confirm) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'You must confirm deletion by setting confirm to true'
        );
      }
      
      const github = getGitHubApi();
    
      return tryCatchAsync(async () => {
        await github.getOctokit().repos.delete({
          owner,
          repo,
        });
    
        return {
          success: true,
          message: `Repository ${owner}/${repo} has been deleted`,
        };
      }, 'Failed to delete repository');
    }
  • Zod schema for validating the input parameters of delete-repository tool, extending OwnerRepoSchema and requiring confirm: true.
    export const DeleteRepositorySchema = OwnerRepoSchema.extend({
      confirm: z.boolean().refine(val => val === true, {
        message: 'You must confirm deletion by setting confirm to true',
      }),
    });
  • src/server.ts:199-221 (registration)
    Tool registration in the listTools response, defining the name, description, and input schema for the MCP protocol.
    {
      name: 'delete-repository',
      description: 'Delete a GitHub repository',
      inputSchema: {
        type: 'object',
        properties: {
          owner: {
            type: 'string',
            description: 'Repository owner',
          },
          repo: {
            type: 'string',
            description: 'Repository name',
          },
          confirm: {
            type: 'boolean',
            description: 'Confirmation for deletion (must be true)',
          },
        },
        required: ['owner', 'repo', 'confirm'],
        additionalProperties: false,
      },
    },
  • Dispatch case in the CallToolRequest handler switch statement that invokes the deleteRepository function.
    case 'delete-repository':
      result = await deleteRepository(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