create_repo
Create a new GitHub repository by specifying a name, description, and privacy setting to organize and share code projects.
Instructions
Create a new GitHub repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_name | Yes | The name of the repository to create | |
| description | No | A description of the repository | |
| private | No | Whether the repository should be private |
Implementation Reference
- src/index.ts:199-235 (handler)Handler for the 'create_repo' tool. Validates the repository name, then sends a POST request to GitHub's /user/repos endpoint to create a new repository with the provided name, description, and privacy setting. Returns the API response or an error.} else if (request.params.name === 'create_repo') { const repo_name = args.repo_name; if (!repo_name) { throw new McpError(ErrorCode.InvalidParams, 'Repository name is required'); } try { const response = await this.axiosInstance.post('/user/repos', { name: repo_name, description: args.description, private: args.private ?? false, }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { if (axios.isAxiosError(error)) { return { content: [ { type: 'text', text: `GitHub API error: ${ error.response?.data.message ?? error.message }`, }, ], isError: true, }; } throw error; }
- src/index.ts:111-131 (schema)Schema definition for the 'create_repo' tool, including name, description, and input schema specifying required 'repo_name' and optional 'description' and 'private' fields.name: 'create_repo', description: 'Create a new GitHub repository', inputSchema: { type: 'object', properties: { repo_name: { type: 'string', description: 'The name of the repository to create', }, description: { type: 'string', description: 'A description of the repository', }, private: { type: 'boolean', description: 'Whether the repository should be private', default: false, }, }, required: ['repo_name'], },
- src/index.ts:94-161 (registration)Registration of available tools in the ListToolsRequestSchema handler, including the 'create_repo' tool in the tools array.this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { name: 'get_user', description: 'Get GitHub user information', inputSchema: { type: 'object', properties: { username: { type: 'string', description: 'GitHub username', }, }, required: ['username'], }, }, { name: 'create_repo', description: 'Create a new GitHub repository', inputSchema: { type: 'object', properties: { repo_name: { type: 'string', description: 'The name of the repository to create', }, description: { type: 'string', description: 'A description of the repository', }, private: { type: 'boolean', description: 'Whether the repository should be private', default: false, }, }, required: ['repo_name'], }, }, { name: 'push_to_repo', description: 'Push content to a GitHub repository', inputSchema: { type: 'object', properties: { repo_name: { type: 'string', description: 'The name of the repository to push to', }, file_path: { type: 'string', description: 'The path where the file should be created in the repository', }, content: { type: 'string', description: 'The content to push to the repository', }, message: { type: 'string', description: 'The commit message', default: 'Update via GitHub MCP', }, }, required: ['repo_name', 'file_path', 'content'], }, }, ], }));