Skip to main content
Glama

list_branches

Retrieve and sort branches in a Gitee repository by name or update date, filtering by owner, repo, and page settings. Simplify repository branch management.

Instructions

列出 Gitee 仓库中的分支

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directionNoSort directionasc
ownerYesRepository owner path (enterprise, organization, or personal path)
pageNoPage number
per_pageNoNumber of items per page, maximum 100
repoYesRepository path
sortNoSort fieldname

Implementation Reference

  • The core handler function that implements the logic to list branches from a Gitee repository by constructing the API URL with query parameters and fetching/parsing the response.
    export async function listBranches(
      owner: string,
      repo: string,
      sort?: string,
      direction?: string,
      page?: number,
      per_page?: number
    ) {
      owner = validateOwnerName(owner);
      repo = validateRepositoryName(repo);
    
      const url = new URL(`${getGiteeApiBaseUrl()}/repos/${owner}/${repo}/branches`);
    
      if (sort) {
        url.searchParams.append("sort", sort);
      }
      if (direction) {
        url.searchParams.append("direction", direction);
      }
      if (page !== undefined) {
        url.searchParams.append("page", page.toString());
      }
      if (per_page !== undefined) {
        url.searchParams.append("per_page", per_page.toString());
      }
    
      const response = await giteeRequest(url.toString());
      return z.array(GiteeBranchSchema).parse(response);
    }
  • Zod schema defining the input parameters for the list_branches tool, including owner, repo, sorting, pagination options.
    export const ListBranchesSchema = z.object({
      // 仓库所属空间地址 (企业、组织或个人的地址 path)
      owner: z.string().describe("Repository owner path (enterprise, organization, or personal path)"),
      // 仓库路径 (path)
      repo: z.string().describe("Repository path"),
      // 排序字段
      sort: z.enum(["name", "updated"]).default("name").optional().describe("Sort field"),
      // 排序方向
      direction: z.enum(["asc", "desc"]).default("asc").optional().describe("Sort direction"),
      // 当前的页码
      page: z.number().int().default(1).optional().describe("Page number"),
      // 每页的数量,最大为 100
      per_page: z.number().int().min(1).max(100).optional().describe("Number of items per page, maximum 100"),
    });
  • index.ts:72-87 (registration)
    Tool registration in the MCP server, specifying name, description, schema, and a wrapper handler that delegates to the implementation in branchOperations.
    server.registerTool({
      name: "list_branches",
      description: "列出 Gitee 仓库中的分支",
      schema: branchOperations.ListBranchesSchema,
      handler: async (params: any) => {
        const { owner, repo, sort, direction, page, per_page } = params;
        return await branchOperations.listBranches(
          owner,
          repo,
          sort,
          direction,
          page,
          per_page
        );
      },
    });
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('list') but doesn't describe behavioral traits such as pagination behavior (implied by 'page' and 'per_page' parameters but not explained), rate limits, authentication requirements, or what the output looks like. For a tool with 6 parameters and no annotation coverage, this leaves significant gaps in understanding how the tool behaves beyond basic functionality.

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 without any fluff or redundancy. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place, and there's no wasted verbiage.

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 the tool's complexity (6 parameters, no annotations, no output schema), the description is incomplete. It lacks information on behavioral aspects like pagination, output format, error handling, or authentication needs. While the schema covers parameter details, the description doesn't compensate for missing annotations or output schema, leaving gaps in understanding how to effectively use the tool in practice.

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?

The schema description coverage is 100%, with all parameters well-documented in the schema (e.g., 'owner' as repository owner path, 'per_page' with maximum 100). The description adds no additional meaning beyond the schema, such as explaining parameter interactions or providing examples. According to guidelines, with high schema coverage (>80%), the baseline is 3 even without param info in the description, which fits here.

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 ('列出' meaning 'list') and resource ('Gitee 仓库中的分支' meaning 'branches in Gitee repository'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'get_branch' (which retrieves a single branch), but the verb 'list' implies a collection operation. The description is specific enough to convey the core function without being tautological.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_branch' (for single branch details) or 'create_branch' (for creating new branches), nor does it specify prerequisites or contextual cues for selection. Usage is implied only by the tool name and description, with no explicit when/when-not instructions.

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