fork_repository
Create a copy of a GitHub repository to your personal account or organization for development, testing, or contribution purposes.
Instructions
Fork a GitHub repository to your account or specified organization
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | Repository owner (username or organization) | |
| repo | Yes | Repository name | |
| organization | No | Optional: organization to fork to (defaults to your personal account) |
Implementation Reference
- operations/repository.ts:51-65 (handler)The main handler function that forks a GitHub repository by making a POST request to the GitHub API and parsing the response.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); }
- 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)"), });
- index.ts:108-112 (registration)Tool registration in the list of tools returned by ListToolsRequest, specifying name, description, and input schema.{ name: "fork_repository", description: "Fork a GitHub repository to your account or specified organization", inputSchema: zodToJsonSchema(repository.ForkRepositorySchema), },
- index.ts:169-175 (registration)Handler case in the CallToolRequest switch statement that parses arguments, calls the forkRepository function, and returns the result.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) }], }; }