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
| Name | Required | Description | Default |
|---|---|---|---|
| autoInit | No | Initialize with README.md | |
| description | No | Repository description | |
| name | Yes | Repository name | |
| private | No | Whether the repository should be private |
Implementation Reference
- src/tools/repository.ts:65-107 (handler)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'); }
- src/utils/validation.ts:46-52 (schema)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(), });
- src/server.ts:126-149 (schema)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,
- src/server.ts:1166-1168 (registration)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, }, },