Skip to main content
Glama
piyushgIITian

GitHub Enterprise MCP Server

fork-repository

Create a copy of a GitHub repository to your personal account or specified organization, enabling independent development and experimentation without affecting the original codebase.

Instructions

Fork a GitHub repository to your account or specified organization

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
organizationNoOptional: organization to fork to (defaults to your personal account)
ownerYesRepository owner (username or organization)
repoYesRepository name

Implementation Reference

  • The main handler function that executes the fork-repository tool logic using GitHub's Octokit API to create a fork of the specified repository.
    export async function forkRepository(args: unknown): Promise<any> {
      const { owner, repo, organization } = args as { owner: string; repo: string; organization?: string };
      const github = getGitHubApi();
    
      return tryCatchAsync(async () => {
        const { data } = await github.getOctokit().repos.createFork({
          owner,
          repo,
          organization,
        });
    
        return {
          id: data.id,
          name: data.name,
          full_name: data.full_name,
          owner: {
            login: data.owner.login,
            id: data.owner.id,
            type: data.owner.type,
          },
          private: data.private,
          html_url: data.html_url,
          description: data.description,
          fork: data.fork,
          created_at: data.created_at,
          updated_at: data.updated_at,
          pushed_at: data.pushed_at,
          default_branch: data.default_branch,
          parent: data.parent ? {
            name: data.parent.name,
            full_name: data.parent.full_name,
            owner: {
              login: data.parent.owner.login,
            },
          } : null,
          source: data.source ? {
            name: data.source.name,
            full_name: data.source.full_name,
            owner: {
              login: data.source.owner.login,
            },
          } : null,
        };
      }, 'Failed to fork repository');
    }
  • Input schema and metadata definition for the 'fork-repository' tool, registered with the MCP server.
    {
      name: 'fork-repository',
      description: 'Fork a GitHub repository to your account or specified organization',
      inputSchema: {
        type: 'object',
        properties: {
          owner: {
            type: 'string',
            description: 'Repository owner (username or organization)',
          },
          repo: {
            type: 'string',
            description: 'Repository name',
          },
          organization: {
            type: 'string',
            description: 'Optional: organization to fork to (defaults to your personal account)',
          },
        },
        required: ['owner', 'repo'],
        additionalProperties: false,
      },
    },
  • Dispatch registration in the tool call handler switch statement, routing 'fork-repository' calls to the forkRepository function.
    case 'fork-repository':
      result = await forkRepository(parsedArgs);
      break;
  • src/server.ts:25-31 (registration)
    Import statement registering the forkRepository handler from the tools/files module.
    import {
      createOrUpdateFile,
      pushFiles,
      getFileContents,
      forkRepository,
      getPullRequestFiles,
    } from './tools/files.js';

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/piyushgIITian/github-enterprice-mcp'

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