fork_repository
Create a copy of a GitLab project in your account or specified namespace to modify code independently from the original repository.
Instructions
Fork a GitLab project to your account or specified namespace
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | Project ID or URL-encoded path | |
| namespace | No | Namespace to fork to (full path) |
Implementation Reference
- src/api/projects.ts:47-57 (handler)The implementation of `forkProject` that handles the API call for forking a repository.
export async function forkProject(projectId: string, namespace?: string): Promise<GitLabFork> { if (!projectId?.trim()) { throw new Error("Project ID is required"); } const endpoint = `/projects/${encodeProjectId(projectId)}/fork`; const body = namespace ? { namespace } : undefined; const fork = await gitlabPost<GitLabFork>(endpoint, body); return GitLabForkSchema.parse(fork); } - src/server.ts:221-225 (registration)The MCP tool registration and request handler switch case for `fork_repository`.
case "fork_repository": { const args = ForkRepositorySchema.parse(request.params.arguments); const fork = await api.forkProject(args.project_id, args.namespace); return { content: [{ type: "text", text: JSON.stringify(fork, null, 2) }] }; } - src/schemas.ts:280-284 (schema)Definition of the input parameters for the `fork_repository` tool.
export const ForkRepositorySchema = ProjectParamsSchema.extend({ namespace: z.string().optional().describe("Namespace to fork to (full path)") }); export const CreateBranchSchema = ProjectParamsSchema.extend({