Skip to main content
Glama
piyushgIITian

GitHub Enterprise MCP Server

create-repository

Create a new GitHub repository in your account with customizable settings including name, description, privacy options, and README initialization.

Instructions

Create a new GitHub repository in your account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
autoInitNoInitialize with README.md
descriptionNoRepository description
nameYesRepository name
privateNoWhether the repository should be private

Implementation Reference

  • The core handler function that parses input arguments, calls the GitHub API to create a repository (in user account or organization), handles errors with tryCatchAsync, and returns the new repository details.
    export async function createRepository(args: unknown): Promise<any> {
      const { name, description, private: isPrivate, autoInit, org } = CreateRepositorySchema.parse(args);
      const github = getGitHubApi();
    
      return tryCatchAsync(async () => {
        let data;
    
        if (org) {
          // Create repository in an organization
          const response = await github.getOctokit().repos.createInOrg({
            org,
            name,
            description,
            private: isPrivate,
            auto_init: autoInit,
          });
          data = response.data;
        } else {
          // Create repository for the authenticated user
          const response = await github.getOctokit().repos.createForAuthenticatedUser({
            name,
            description,
            private: isPrivate,
            auto_init: autoInit,
          });
          data = response.data;
        }
    
        return {
          id: data.id,
          name: data.name,
          full_name: data.full_name,
          private: data.private,
          description: data.description,
          html_url: data.html_url,
          clone_url: data.clone_url,
          ssh_url: data.ssh_url,
          created_at: data.created_at,
          updated_at: data.updated_at,
          default_branch: data.default_branch,
        };
      }, 'Failed to create repository');
    }
  • Zod schema used for runtime input validation in the createRepository handler.
    export const CreateRepositorySchema = z.object({
      name: z.string().min(1, 'Repository name is required'),
      description: z.string().optional(),
      private: z.boolean().optional(),
      autoInit: z.boolean().optional(),
      org: z.string().optional(),
    });
  • MCP tool inputSchema definition provided to clients via listTools.
    name: 'create-repository',
    description: 'Create a new GitHub repository in your account',
    inputSchema: {
      type: 'object',
      properties: {
        name: {
          type: 'string',
          description: 'Repository name',
        },
        description: {
          type: 'string',
          description: 'Repository description',
        },
        private: {
          type: 'boolean',
          description: 'Whether the repository should be private',
        },
        autoInit: {
          type: 'boolean',
          description: 'Initialize with README.md',
        },
      },
      required: ['name'],
      additionalProperties: false,
  • Switch case in callToolRequestHandler that dispatches execution to the createRepository function.
    case 'create-repository':
      result = await createRepository(parsedArgs);
      break;
  • src/server.ts:125-151 (registration)
    Tool registration entry in the listTools response, including name, description, and input schema.
    {
      name: 'create-repository',
      description: 'Create a new GitHub repository in your account',
      inputSchema: {
        type: 'object',
        properties: {
          name: {
            type: 'string',
            description: 'Repository name',
          },
          description: {
            type: 'string',
            description: 'Repository description',
          },
          private: {
            type: 'boolean',
            description: 'Whether the repository should be private',
          },
          autoInit: {
            type: 'boolean',
            description: 'Initialize with README.md',
          },
        },
        required: ['name'],
        additionalProperties: false,
      },
    },

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