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);
      },
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states it creates a branch but doesn't disclose behavioral traits: whether it requires specific permissions, what happens if the branch already exists, if it's idempotent, rate limits, or what the response contains. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Chinese that directly states the tool's purpose. It's appropriately sized and front-loaded with no wasted words, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a mutation tool with no annotations, no output schema, and 4 parameters, the description is incomplete. It doesn't explain what the tool returns, error conditions, or behavioral nuances. The high schema coverage helps with parameters, but overall context for safe and effective use is lacking.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 4 parameters thoroughly. The description adds no parameter-specific information beyond implying the tool operates on a Gitee repository. With high schema coverage, the baseline is 3 even without param details in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('创建一个新分支' - create a new branch) and resource ('在 Gitee 仓库中' - in Gitee repository). It distinguishes from siblings like 'get_branch' (read) and 'list_branches' (list), but doesn't explicitly differentiate from other creation tools like 'create_issue' or 'create_pull_request' beyond the resource type.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing repository access), when to use 'fork_repository' instead for cross-repository branching, or how it relates to 'push_files' for subsequent commits. The description provides only the basic function without contextual usage advice.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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