create-user
Facilitates the creation of GitHub Enterprise user accounts by defining essential attributes like username, email, and bio through an integrated MCP server interface.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bio | No | Biography for the user | |
| blog | No | URL of the user's blog or website | |
| company | No | Company for the user | |
| Yes | The email address for the user | ||
| location | No | Location for the user | |
| login | Yes | The username for the user | |
| name | No | Full name for the user | |
| twitter_username | No | Twitter username for the user |
Implementation Reference
- server/index.ts:1860-1918 (registration)Registration of the MCP 'create-user' tool, including Zod input schema validation and execution handler that checks for GitHub Enterprise and delegates to UserManagement.createUser"create-user", { login: z.string().describe("The username for the user"), email: z.string().describe("The email address for the user"), name: z.string().optional().describe("Full name for the user"), company: z.string().optional().describe("Company for the user"), location: z.string().optional().describe("Location for the user"), bio: z.string().optional().describe("Biography for the user"), blog: z.string().optional().describe("URL of the user's blog or website"), twitter_username: z.string().optional().describe("Twitter username for the user") }, async ({ login, email, name, company, location, bio, blog, twitter_username }) => { try { if (!context.isGitHubEnterprise) { return { content: [ { type: "text", text: "User creation is only available in GitHub Enterprise. This operation cannot be performed on GitHub.com." } ], isError: true }; } const user = await context.users.createUser(context.client, { login, email, name, company, location, bio, blog, twitter_username }); return { content: [ { type: "text", text: `User '${login}' successfully created:\n\n${JSON.stringify(user, null, 2)}` } ] }; } catch (error: any) { console.error('Error creating user:', error); return { content: [ { type: "text", text: `An error occurred while creating user: ${error.message}` } ], isError: true }; } } );
- api/users/users.ts:141-169 (helper)Core implementation of user creation via GitHub Enterprise Admin API POST to /admin/users, called by the MCP tool handlerasync createUser(client: any, params: CreateUserParams): Promise<User> { try { const { baseUrl, token } = client; if (!params.login || !params.email) { throw new Error('Username (login) and email are required'); } const url = `${baseUrl}/admin/users`; const response = await axios.post(url, params, { headers: { Authorization: `token ${token}`, Accept: 'application/vnd.github.v3+json', 'Content-Type': 'application/json' } }); return response.data; } catch (error: any) { if (error.response?.status === 404) { throw new Error('User creation endpoint not found. Make sure you have admin permissions and are using GitHub Enterprise.'); } else if (error.response?.status === 422) { throw new Error(`Validation failed: ${error.response.data.message || 'Check the username and email format'}`); } throw new Error(`Failed to create user: ${error.message}`); } }
- api/users/types.ts:99-139 (schema)TypeScript interface defining parameters for creating a user, matching the MCP tool inputs and used in the createUser helperexport interface CreateUserParams { /** * The username for the user */ login: string; /** * The email address for the user */ email: string; /** * Optional full name for the user */ name?: string; /** * Optional company for the user */ company?: string; /** * Optional location for the user */ location?: string; /** * Optional biography for the user */ bio?: string; /** * Optional URL of the user's blog or website */ blog?: string; /** * Optional Twitter username for the user */ twitter_username?: string; }