Skip to main content
Glama

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
NameRequiredDescriptionDefault
project_idYesProject ID or URL-encoded path
namespaceNoNamespace to fork to (full path)

Implementation Reference

  • 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) }] };
    }
  • 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({

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/TheRealChrisThomas/gitlab-mcp-server'

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