create_repository
Set up a new GitHub repository with custom name, description, privacy settings, and optional README initialization using the MCP-github server.
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/operations/repository.ts:41-47 (handler)Core implementation of the create_repository tool: makes a POST request to GitHub API to create a new repository and parses the response.export async function createRepository(github_pat: string, options: CreateRepositoryOptions) { const response = await githubRequest(github_pat, "https://api.github.com/user/repos", { method: "POST", body: options, }); return GitHubRepositorySchema.parse(response); }
- src/operations/repository.ts:6-11 (schema)Zod schema for the input parameters of the create_repository tool (excluding github_pat).export const CreateRepositoryOptionsSchema = z.object({ name: z.string().describe("Repository name"), description: z.string().optional().describe("Repository description"), private: z.boolean().optional().describe("Whether the repository should be private"), autoInit: z.boolean().optional().describe("Initialize with README.md"), });
- src/index.ts:88-92 (registration)Registration of the create_repository tool in the ListTools response.{ name: "create_repository", description: "Create a new GitHub repository in your account", inputSchema: zodToJsonSchema(repository.CreateRepositoryOptionsSchema), },
- src/index.ts:366-373 (handler)Dispatch handler in CallToolRequestHandler that parses arguments and calls the createRepository function.case "create_repository": { const argsWithPat = repository._CreateRepositoryOptionsSchema.parse(params.arguments); const { github_pat, ...args } = argsWithPat; const result = await repository.createRepository(github_pat, args); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
- src/operations/repository.ts:13-15 (schema)Extended Zod schema including the required github_pat for internal use in dispatch.export const _CreateRepositoryOptionsSchema = CreateRepositoryOptionsSchema.extend({ github_pat: z.string().describe("GitHub Personal Access Token"), });