create_repository
Create a new GitHub repository in your account by specifying its name, description, privacy, and optional README initialization.
Instructions
Create a new GitHub repository in your account
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Repository name | |
| description | No | Repository description | |
| private | No | Whether repo should be private | |
| autoInit | No | Initialize with README |
Implementation Reference
- src/tools/repositories.ts:479-481 (registration)Comment header indicating the start of the 'Create Repository' tool registration.
) // Tool: Create Repository - src/tools/repositories.ts:482-512 (registration)The 'server.tool("create_repository", ...)' call that registers the tool with its name, description, and input schema.
server.tool( "create_repository", "Create a new GitHub repository in your account", { name: z.string().describe("Repository name"), description: z.string().optional().describe("Repository description"), private: z .boolean() .optional() .describe("Whether repo should be private"), autoInit: z.boolean().optional().describe("Initialize with README"), }, async ({ name, description, private: isPrivate, autoInit }) => { try { const response = await octokit.rest.repos.createForAuthenticatedUser({ name, description, private: isPrivate, auto_init: autoInit, }) const r = response.data return { content: [{ type: "text", text: `Repository created: **${r.full_name}**\nURL: ${r.html_url}\nVisibility: ${r.private ? "private" : "public"}\nDefault branch: ${r.default_branch}` }], } } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.message}` }], } } }, ) - src/tools/repositories.ts:485-493 (schema)Zod schema defining the input parameters: name (required string), description (optional string), private (optional boolean), autoInit (optional boolean).
{ name: z.string().describe("Repository name"), description: z.string().optional().describe("Repository description"), private: z .boolean() .optional() .describe("Whether repo should be private"), autoInit: z.boolean().optional().describe("Initialize with README"), }, - src/tools/repositories.ts:494-511 (handler)Async handler function that calls octokit.rest.repos.createForAuthenticatedUser() with the input params and returns a formatted success/error response.
async ({ name, description, private: isPrivate, autoInit }) => { try { const response = await octokit.rest.repos.createForAuthenticatedUser({ name, description, private: isPrivate, auto_init: autoInit, }) const r = response.data return { content: [{ type: "text", text: `Repository created: **${r.full_name}**\nURL: ${r.html_url}\nVisibility: ${r.private ? "private" : "public"}\nDefault branch: ${r.default_branch}` }], } } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.message}` }], } } },