Skip to main content
Glama

create_branch

Create a new branch in a Gitee repository by specifying the owner, repository, and branch name, with an optional reference source for the branch.

Instructions

在 Gitee 仓库中创建一个新分支

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branch_nameYesName for the new branch
ownerYesRepository owner path (enterprise, organization, or personal path)
refsNoSource reference for the branch, default: mastermaster
repoYesRepository path

Implementation Reference

  • Core handler function that performs the actual branch creation by validating inputs, constructing API URL and body, sending POST request to Gitee API, and parsing response.
    export async function createBranchFromRef( owner: string, repo: string, branchName: string, refs: string = "master" ) { owner = validateOwnerName(owner); repo = validateRepositoryName(repo); branchName = validateBranchName(branchName); const url = `/repos/${owner}/${repo}/branches`; const body = { branch_name: branchName, refs: refs, }; const response = await giteeRequest(url, "POST", body); return GiteeBranchSchema.parse(response); }
  • Zod schema for input validation of the create_branch tool parameters: owner, repo, branch_name, refs.
    export const CreateBranchSchema = z.object({ // 仓库所属空间地址 (企业、组织或个人的地址 path) owner: z.string().describe("Repository owner path (enterprise, organization, or personal path)"), // 仓库路径 (path) repo: z.string().describe("Repository path"), // 新创建的分支名称 branch_name: z.string().describe("Name for the new branch"), // 起点名称,默认:master refs: z.string().default("master").describe("Source reference for the branch, default: master"), });
  • index.ts:62-70 (registration)
    Tool registration in MCP server, specifying name, description, schema, and thin handler wrapper that delegates to createBranchFromRef.
    server.registerTool({ name: "create_branch", description: "在 Gitee 仓库中创建一个新分支", schema: branchOperations.CreateBranchSchema, handler: async (params: any) => { const { owner, repo, branch_name, refs } = params; return await branchOperations.createBranchFromRef(owner, repo, branch_name, refs); }, });

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/normal-coder/gitee-mcp-server'

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