create_repository
Initialize a new GitLab project with customizable settings like name, description, visibility, and README file. Streamline project creation on the enhanced GitLab MCP Server with activity tracking and group projects.
Instructions
Create a new GitLab project
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | ||
| initialize_with_readme | No | ||
| name | No | ||
| visibility | No | private |
Input Schema (JSON Schema)
{
"properties": {
"description": {
"type": "string"
},
"initialize_with_readme": {
"default": true,
"type": "boolean"
},
"name": {
"type": "string"
},
"visibility": {
"default": "private",
"enum": [
"private",
"internal",
"public"
],
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/index.ts:352-356 (handler)MCP tool handler for 'create_repository': parses arguments using the schema and delegates to GitLabApi.createRepository method.case "create_repository": { const args = CreateRepositorySchema.parse(request.params.arguments); const repository = await gitlabApi.createRepository(args); return { content: [{ type: "text", text: JSON.stringify(repository, null, 2) }] }; }
- src/gitlab-api.ts:789-814 (helper)Core implementation of repository creation: sends POST request to GitLab /projects endpoint with options.async createRepository( options: z.infer<typeof CreateRepositoryOptionsSchema> ): Promise<GitLabRepository> { const response = await fetch(`${this.apiUrl}/projects`, { method: "POST", headers: { "Authorization": `Bearer ${this.token}`, "Content-Type": "application/json" }, body: JSON.stringify({ name: options.name, description: options.description, visibility: options.visibility, initialize_with_readme: options.initialize_with_readme }) }); if (!response.ok) { throw new McpError( ErrorCode.InternalError, `GitLab API error: ${response.statusText}` ); } return GitLabRepositorySchema.parse(await response.json()); }
- src/index.ts:120-124 (registration)Tool registration in ALL_TOOLS array, defining name, description, input schema, and readOnly flag.{ name: "create_repository", description: "Create a new GitLab project", inputSchema: createJsonSchema(CreateRepositorySchema), readOnly: false
- src/schemas.ts:362-407 (schema)Zod schemas for input validation: CreateRepositoryOptionsSchema defines parameters, aliased as CreateRepositorySchema.export const CreateRepositoryOptionsSchema = z.object({ name: z.string(), description: z.string().optional(), visibility: z.enum(['private', 'internal', 'public']).default('private'), initialize_with_readme: z.boolean().default(true) }); export const CreateBranchOptionsSchema = z.object({ name: z.string(), ref: z.string().optional() }); export const CreateIssueOptionsSchema = z.object({ title: z.string(), description: z.string().optional(), assignee_ids: z.array(z.number()).optional(), milestone_id: z.number().optional(), labels: z.array(z.string()).optional() }); export const CreateMergeRequestOptionsSchema = z.object({ title: z.string(), description: z.string().optional(), source_branch: z.string(), target_branch: z.string(), allow_collaboration: z.boolean().optional(), draft: z.boolean().optional() }); // Tool Schemas export const CreateOrUpdateFileSchema = z.object({ project_id: z.string(), file_path: z.string(), content: z.string(), commit_message: z.string(), branch: z.string(), previous_path: z.string().optional() }); export const SearchRepositoriesSchema = z.object({ search: z.string(), page: z.number().optional(), per_page: z.number().optional() }); export const CreateRepositorySchema = CreateRepositoryOptionsSchema;