Skip to main content
Glama

fork_repository

Create a copy of a GitHub repository to your personal account or specified organization using owner and repo details. Enables easier collaboration and experimentation.

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

  • index.ts:106-108 (registration)
    Registration of the 'fork_repository' tool in the MCP server's list of tools, including name, description, and input schema reference.
    name: "fork_repository", description: "Fork a GitHub repository to your account or specified organization", inputSchema: zodToJsonSchema(repository.ForkRepositorySchema),
  • MCP CallToolRequest handler for 'fork_repository': parses input arguments using the schema, calls the forkRepository function, and returns the result as JSON text content.
    case "fork_repository": { const args = repository.ForkRepositorySchema.parse(request.params.arguments); const fork = await repository.forkRepository(args.owner, args.repo, args.organization); return { content: [{ type: "text", text: JSON.stringify(fork, null, 2) }], }; }
  • Zod schema defining the input parameters for the fork_repository tool: owner, repo, and optional organization.
    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)"), });
  • Core implementation function that constructs the GitHub forks API URL (with optional organization), performs POST request via githubRequest utility, parses and returns the forked repository response with extended schema.
    export async function forkRepository( 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(url, { method: "POST" }); return GitHubRepositorySchema.extend({ parent: GitHubRepositorySchema, source: GitHubRepositorySchema, }).parse(response); }

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

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