create_repository
Create a new GitHub repository in your account. Specify name, description, privacy settings, and whether to initialize with a README file.
Instructions
Create a new GitHub repository in your account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Repository name | |
| description | No | Repository description | |
| private | No | Whether the repository should be private | |
| autoInit | No | Initialize with README.md |
Implementation Reference
- src/operations/repository.ts:41-47 (handler)The core handler function that executes the create_repository tool by making a POST request to GitHub's /user/repos API endpoint and parsing 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 defining the input parameters for creating a repository (name, description, private, autoInit).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)Tool registration in the MCP server's listTools response, specifying name, description, and input schema.{ name: "create_repository", description: "Create a new GitHub repository in your account", inputSchema: zodToJsonSchema(repository.CreateRepositoryOptionsSchema), },
- src/index.ts:366-373 (registration)Dispatch handler in the server's callTool request handler that parses arguments, calls the repository.createRepository function, and formats the response.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) }], }; }