Skip to main content
Glama

fork_repository

Fork a GitLab project to your account or a specific namespace using this tool. Simplify repository duplication and manage projects efficiently with precise namespace control.

Instructions

Fork a GitLab project to your account or specified namespace

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceNo
project_idNo

Implementation Reference

  • Handler for the fork_repository tool that parses input arguments using the schema, delegates to GitLabApi.forkProject helper, and formats the response as JSON text.
    case "fork_repository": { const args = ForkRepositorySchema.parse(request.params.arguments); const fork = await gitlabApi.forkProject(args.project_id, args.namespace); return { content: [{ type: "text", text: JSON.stringify(fork, null, 2) }] }; }
  • Zod schema defining the input structure for the fork_repository tool: project_id (required string) and optional namespace.
    export const ForkRepositorySchema = z.object({ project_id: z.string(), namespace: z.string().optional() });
  • src/index.ts:150-154 (registration)
    Tool registration in the ALL_TOOLS array, specifying name, description, input schema conversion, and readOnly flag.
    { name: "fork_repository", description: "Fork a GitLab project to your account or specified namespace", inputSchema: createJsonSchema(ForkRepositorySchema), readOnly: false
  • Implementation of forkProject method in GitLabApi class that makes the POST request to GitLab's /projects/{id}/fork endpoint, handles response, and validates with GitLabForkSchema.
    async forkProject( projectId: string, namespace?: string ): Promise<GitLabFork> { const url = `${this.apiUrl}/projects/${encodeURIComponent(projectId)}/fork`; const queryParams = namespace ? `?namespace=${encodeURIComponent(namespace)}` : ''; const response = await fetch(url + queryParams, { method: "POST", headers: { "Authorization": `Bearer ${this.token}`, "Content-Type": "application/json" } }); if (!response.ok) { throw new McpError( ErrorCode.InternalError, `GitLab API error: ${response.statusText}` ); } return GitLabForkSchema.parse(await response.json()); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yoda-digital/mcp-gitlab-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server