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
| 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
- src/tools/files.ts:211-255 (handler)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'); }
- src/server.ts:498-520 (schema)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, }, },
- src/server.ts:1201-1203 (registration)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';