Skip to main content
Glama
ddukbg

GitHub Enterprise MCP Server

create-repository

Create new repositories on GitHub Enterprise with options for privacy, README initialization, .gitignore templates, and licenses.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesRepository name
descriptionNoRepository description
privateNoWhether the repository is private
auto_initNoInitialize with README
gitignore_templateNoAdd .gitignore template
license_templateNoAdd a license template
orgNoOrganization name (if creating in an organization)

Implementation Reference

  • The MCP tool handler function for 'create-repository'. It validates parameters, constructs options, calls the appropriate RepositoryAPI create method (user or organization), formats the result using formatRepository, handles errors, and returns a structured text response.
    async ({ name, description, private: isPrivate, auto_init, gitignore_template, license_template, org }) => { try { // Parameter validation if (!name || typeof name !== 'string' || name.trim() === '') { return { content: [ { type: "text", text: "Repository name is required." } ] }; } const options = { name, description, private: isPrivate, auto_init, gitignore_template, license_template }; let repository; if (org) { repository = await context.repository.createOrganizationRepository(org, options); } else { repository = await context.repository.createRepository(options); } // Format repository information const formattedRepo = formatRepository(repository); return { content: [ { type: "text", text: `Successfully created repository: ${formattedRepo.full_name}\n\n${JSON.stringify(formattedRepo, null, 2)}` } ] }; } catch (error: any) { return { content: [ { type: "text", text: `Error creating repository: ${error.message}` } ] }; } }
  • Zod schema defining the input parameters for the 'create-repository' MCP tool, including repository name, description, privacy settings, initialization options, and optional organization.
    name: z.string().min(1).describe("Repository name"), description: z.string().optional().describe("Repository description"), private: z.boolean().optional().describe("Whether the repository is private"), auto_init: z.boolean().optional().describe("Initialize with README"), gitignore_template: z.string().optional().describe("Add .gitignore template"), license_template: z.string().optional().describe("Add a license template"), org: z.string().optional().describe("Organization name (if creating in an organization)")
  • Registration of the 'create-repository' tool on the MCP server instance using server.tool(), including name, input schema, and handler function.
    "create-repository", { name: z.string().min(1).describe("Repository name"), description: z.string().optional().describe("Repository description"), private: z.boolean().optional().describe("Whether the repository is private"), auto_init: z.boolean().optional().describe("Initialize with README"), gitignore_template: z.string().optional().describe("Add .gitignore template"), license_template: z.string().optional().describe("Add a license template"), org: z.string().optional().describe("Organization name (if creating in an organization)") }, async ({ name, description, private: isPrivate, auto_init, gitignore_template, license_template, org }) => { try { // Parameter validation if (!name || typeof name !== 'string' || name.trim() === '') { return { content: [ { type: "text", text: "Repository name is required." } ] }; } const options = { name, description, private: isPrivate, auto_init, gitignore_template, license_template }; let repository; if (org) { repository = await context.repository.createOrganizationRepository(org, options); } else { repository = await context.repository.createRepository(options); } // Format repository information const formattedRepo = formatRepository(repository); return { content: [ { type: "text", text: `Successfully created repository: ${formattedRepo.full_name}\n\n${JSON.stringify(formattedRepo, null, 2)}` } ] }; } catch (error: any) { return { content: [ { type: "text", text: `Error creating repository: ${error.message}` } ] }; } } );
  • RepositoryAPI helper method that performs the actual GitHub API POST request to create a new user repository.
    async createRepository(options: CreateRepoOptions): Promise<GitHubRepository> { return this.client.post<GitHubRepository>('user/repos', options); }
  • RepositoryAPI helper method that performs the GitHub API POST request to create a new organization repository.
    async createOrganizationRepository(org: string, options: CreateRepoOptions): Promise<GitHubRepository> { return this.client.post<GitHubRepository>(`orgs/${org}/repos`, options); }
  • TypeScript interface defining the CreateRepoOptions type used by the repository creation helper methods.
    export interface CreateRepoOptions { name: string; description?: string; homepage?: string; private?: boolean; visibility?: 'public' | 'private' | 'internal'; has_issues?: boolean; has_projects?: boolean; has_wiki?: boolean; has_downloads?: boolean; has_discussions?: boolean; is_template?: boolean; team_id?: number; auto_init?: boolean; gitignore_template?: string; license_template?: string; allow_squash_merge?: boolean; allow_merge_commit?: boolean; allow_rebase_merge?: boolean; allow_auto_merge?: boolean; delete_branch_on_merge?: boolean; }

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

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