fork_repository
Create a copy of a Gitee repository by specifying the owner and repository paths. Optionally, fork into an organization for collaborative development.
Instructions
Fork Gitee 仓库
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| organization | No | Organization path, defaults to personal account if not provided | |
| owner | Yes | Repository owner path (enterprise, organization, or personal path) | |
| repo | Yes | Repository path |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"organization": {
"description": "Organization path, defaults to personal account if not provided",
"type": "string"
},
"owner": {
"description": "Repository owner path (enterprise, organization, or personal path)",
"type": "string"
},
"repo": {
"description": "Repository path",
"type": "string"
}
},
"required": [
"owner",
"repo"
],
"type": "object"
}
Implementation Reference
- operations/repos.ts:64-82 (handler)Implements the fork_repository tool by validating inputs, constructing the Gitee API URL `/repos/{owner}/{repo}/forks`, sending a POST request with optional organization, and parsing the response as a repository object.export async function forkRepository( owner: string, repo: string, organization?: string ) { owner = validateOwnerName(owner); repo = validateRepositoryName(repo); const url = `/repos/${owner}/${repo}/forks`; const body: Record<string, string> = {}; if (organization) { body.organization = validateOwnerName(organization); } const response = await giteeRequest(url, "POST", body); return GiteeRepositorySchema.parse(response); }
- operations/repos.ts:29-36 (schema)Zod schema defining the input parameters for the fork_repository tool: owner (required string), repo (required string), organization (optional string).export const ForkRepositorySchema = z.object({ // 仓库所属空间地址 (企业、组织或个人的地址 path) owner: z.string().describe("Repository owner path (enterprise, organization, or personal path)"), // 仓库路径 (path) repo: z.string().describe("Repository path"), // 组织空间地址,不传默认为个人 organization: z.string().optional().describe("Organization path, defaults to personal account if not provided"), });
- index.ts:51-59 (registration)Registers the 'fork_repository' tool on the MCP server, referencing the schema and delegating to the forkRepository handler from repoOperations.server.registerTool({ name: "fork_repository", description: "Fork Gitee 仓库", schema: repoOperations.ForkRepositorySchema, handler: async (params: any) => { const { owner, repo, organization } = params; return await repoOperations.forkRepository(owner, repo, organization); }, });