Skip to main content
Glama

fork_repository

Fork a GitHub repository to your account or a specified organization using the 'fork_repository' tool from the mcp-github server. Requires owner and repository name, with an optional organization parameter. Simplifies repository duplication for collaboration or personal use.

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 handler function that performs the GitHub repository fork operation by making a POST request to the GitHub Forks API.
    export async function forkRepository( github_pat: string, owner: string, repo: string, organization?: string ) { const url = organization ? `https://api.github.com/repos/${owner}/${repo}/forks?organization=${organization}` : `https://api.github.com/repos/${owner}/${repo}/forks`; const response = await githubRequest(github_pat, url, { method: "POST" }); return GitHubRepositorySchema.extend({ parent: GitHubRepositorySchema, source: GitHubRepositorySchema, }).parse(response); }
  • Zod schema defining the input parameters for the fork_repository tool.
    export const ForkRepositorySchema = z.object({ owner: z.string().describe("Repository owner (username or organization)"), repo: z.string().describe("Repository name"), organization: z.string().optional().describe("Optional: organization to fork to (defaults to your personal account)"), });
  • src/index.ts:114-117 (registration)
    Tool registration in the listTools handler, defining name, description, and input schema.
    name: "fork_repository", description: "Fork a GitHub repository to your account or specified organization", inputSchema: zodToJsonSchema(repository.ForkRepositorySchema), },
  • src/index.ts:331-337 (registration)
    Dispatch handler in the CallToolRequestSchema that parses arguments and calls the forkRepository function.
    case "fork_repository": { const args = repository._ForkRepositorySchema.parse(params.arguments); const fork = await repository.forkRepository(args.github_pat, args.owner, args.repo, args.organization); return { content: [{ type: "text", text: JSON.stringify(fork, null, 2) }], }; }

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

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