Skip to main content
Glama

fork_repository

Create a GitHub repository fork to your account or a specific organization with specified owner and repository details for efficient code management.

Instructions

Fork a GitHub repository to your account or specified organization

Input Schema

NameRequiredDescriptionDefault
organizationNoOptional: organization to fork to (defaults to your personal account)
ownerYesRepository owner (username or organization)
repoYesRepository name

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "organization": { "description": "Optional: organization to fork to (defaults to your personal account)", "type": "string" }, "owner": { "description": "Repository owner (username or organization)", "type": "string" }, "repo": { "description": "Repository name", "type": "string" } }, "required": [ "owner", "repo" ], "type": "object" }

Implementation Reference

  • index.ts:108-112 (registration)
    Registration of the 'fork_repository' tool in the MCP server's listTools response, 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 tool dispatcher case for 'fork_repository': validates input using the schema and delegates to the forkRepository implementation.
    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 input schema for the fork_repository tool, defining parameters: 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 of the fork_repository tool: constructs the GitHub API URL for forking (with optional organization) and performs the POST request, parsing the forked repository 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); }

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/PhialsBasement/mcp-github-server-plus'

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