create-repository
Create new repositories on GitHub Enterprise with options for privacy, README initialization, .gitignore templates, and licenses.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Repository name | |
| description | No | Repository description | |
| private | No | Whether the repository is private | |
| auto_init | No | Initialize with README | |
| gitignore_template | No | Add .gitignore template | |
| license_template | No | Add a license template | |
| org | No | Organization name (if creating in an organization) |
Implementation Reference
- server/index.ts:984-1035 (handler)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}` } ] }; } }
- server/index.ts:976-982 (schema)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)")
- server/index.ts:974-1036 (registration)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}` } ] }; } } );
- api/repos/repository.ts:59-61 (helper)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); }
- api/repos/repository.ts:66-68 (helper)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); }
- api/repos/types.ts:91-112 (schema)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; }