Skip to main content
Glama
aliyun

AlibabaCloud DevOps MCP Server

Official
by aliyun

list_branches

Retrieve and manage branch listings in Codeup repositories to track development work and organize code versions for team collaboration.

Instructions

[Code Management] List branches in a Codeup repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
organizationIdYesOrganization ID, can be found in the basic information page of the organization admin console
repositoryIdYesRepository ID or a combination of organization ID and repository name, for example: 2835387 or organizationId%2Frepo-name (Note: slashes need to be URL encoded as %2F)
pageNoPage number
perPageNoItems per page
sortNoSort order: name_asc - name ascending, name_desc - name descending, updated_asc - update time ascending, updated_desc - update time descendingname_asc
searchNoSearch query

Implementation Reference

  • Handler for list_branches tool: parses arguments with ListBranchesSchema, calls branches.listBranchesFunc, and returns JSON stringified result.
    case "list_branches": {
      const args = types.ListBranchesSchema.parse(request.params.arguments);
      const branchList = await branches.listBranchesFunc(
        args.organizationId,
        args.repositoryId,
        args.page,
        args.perPage,
        args.sort,
        args.search ?? undefined
      );
      return {
        content: [{ type: "text", text: JSON.stringify(branchList, null, 2) }],
      };
    }
  • Zod schema definition for list_branches input validation: defines organizationId, repositoryId, pagination, sort, and search params.
    export const ListBranchesSchema = z.object({
      organizationId: z.string().describe("Organization ID, can be found in the basic information page of the organization admin console"),
      repositoryId: z.string().describe("Repository ID or a combination of organization ID and repository name, for example: 2835387 or organizationId%2Frepo-name (Note: slashes need to be URL encoded as %2F)"),
      page: z.number().int().default(1).optional().describe("Page number"),
      perPage: z.number().int().default(20).optional().describe("Items per page"),
      sort: z.enum(["name_asc", "name_desc", "updated_asc", "updated_desc"]).default("name_asc").optional().describe("Sort order: name_asc - name ascending, name_desc - name descending, updated_asc - update time ascending, updated_desc - update time descending"),
      search: z.string().nullable().optional().describe("Search query"),
    });
  • Tool registration: defines name, description, and inputSchema for list_branches in the code management tools array.
    name: "list_branches",
    description: "[Code Management] List branches in a Codeup repository",
    inputSchema: zodToJsonSchema(types.ListBranchesSchema),
  • Core helper function listBranchesFunc: makes API request to list branches in a repository, handles URL encoding for repoId, builds query params, calls yunxiaoRequest, parses array of branches with CodeupBranchSchema.
    export async function listBranchesFunc(
        organizationId: string,
        repositoryId: string,
        page?: number,
        perPage?: number,
        sort?: string, // Possible values: name_asc, name_desc, updated_asc, updated_desc
        search?: string
    ): Promise<z.infer<typeof CodeupBranchSchema>[]> {
      console.error("listBranchesFunc page:" + page + " perPage:" + perPage + " sort:" + sort + " search:" + search);
      // Automatically handle unencoded slashes in repositoryId
      if (repositoryId.includes("/")) {
        // Found unencoded slash, automatically URL encode it
        const parts = repositoryId.split("/", 2);
        if (parts.length === 2) {
          const encodedRepoName = encodeURIComponent(parts[1]);
          // Remove + signs from encoding (spaces are encoded as +, but we need %20)
          const formattedEncodedName = encodedRepoName.replace(/\+/g, "%20");
          repositoryId = `${parts[0]}%2F${formattedEncodedName}`;
        }
      }
    
      const baseUrl = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${repositoryId}/branches`;
    
      // Build query parameters - use lowercase parameter names as expected by the API
      const queryParams: Record<string, string | number | undefined> = {};
      if (page !== undefined && page !== null) {
        queryParams.page = page;
      }
      if (perPage !== undefined && perPage !== null) {
        queryParams.perPage = perPage;
      }
      if (sort !== undefined && sort !== null) {
        queryParams.sort = sort;
      }
      if (search !== undefined && search !== null) {
        queryParams.search = search;
      }
    
      const url = buildUrl(baseUrl, queryParams);
    
      const response = await yunxiaoRequest(url, {
        method: "GET",
      });
    
      if (!Array.isArray(response)) {
        return [];
      }
    
      // Map each branch object and handle null values
      return response.map(branchData => {
        // Filter out null values that would cause parsing errors
        // This is a defensive approach until we update all schemas properly
        return CodeupBranchSchema.parse(branchData);
      });
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states it's a list operation (implying read-only), but doesn't cover pagination behavior (implied by parameters but not described), rate limits, authentication requirements, error conditions, or what the output looks like (no output schema).

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 extremely concise (one sentence) and front-loaded with the core purpose. Every word earns its place, with no redundant or verbose elements. The '[Code Management]' prefix efficiently provides domain context.

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?

For a tool with 6 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain the return format, pagination behavior, error handling, or authentication requirements. While the schema covers parameters well, the overall context for using this tool effectively is incomplete.

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%, providing complete parameter documentation. The description adds no additional parameter semantics beyond what's in the schema (e.g., doesn't explain how 'search' interacts with 'sort', or typical use cases for parameters). Baseline 3 is appropriate when schema does the heavy lifting.

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 ('List branches') and resource ('in a Codeup repository'), with the '[Code Management]' prefix providing domain context. It distinguishes from non-list siblings like 'get_branch' or 'create_branch', but doesn't explicitly differentiate from other list tools like 'list_commits' or 'list_files'.

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 is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., needing repository access), comparison to similar list operations, or when other tools like 'get_branch' or 'search' might be more appropriate.

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

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/aliyun/alibabacloud-devops-mcp-server'

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