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
| Name | Required | Description | Default |
|---|---|---|---|
| organization | No | Optional: organization to fork to (defaults to your personal account) | |
| owner | Yes | Repository owner (username or organization) | |
| repo | Yes | Repository 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),
- index.ts:316-322 (handler)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) }], }; }
- operations/repository.ts:19-23 (schema)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)"), });
- operations/repository.ts:51-65 (helper)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); }