Skip to main content
Glama
aliyun

AlibabaCloud DevOps MCP Server

Official
by aliyun

create_branch

Create a new branch in a Codeup repository to organize development work, using a source branch as the starting point for changes.

Instructions

[Code Management] Create a new branch 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)
branchYesName of the branch to be created
refNoSource branch name, the new branch will be created based on this branch, default value is mastermaster

Implementation Reference

  • MCP tool handler for 'create_branch': parses arguments using CreateBranchSchema and delegates to branches.createBranchFunc, returning the result as JSON text.
    case "create_branch": {
      const args = types.CreateBranchSchema.parse(request.params.arguments);
      const branch = await branches.createBranchFunc(
        args.organizationId,
        args.repositoryId,
        args.branch,
        args.ref
      );
      return {
        content: [{ type: "text", text: JSON.stringify(branch, null, 2) }],
      };
    }
  • Tool registration entry for 'create_branch' including name, description, and input schema derived from CreateBranchSchema.
    {
      name: "create_branch",
      description: "[Code Management] Create a new branch in a Codeup repository",
      inputSchema: zodToJsonSchema(types.CreateBranchSchema),
    },
  • Zod input schema definition for create_branch tool parameters: organizationId, repositoryId, branch, ref.
    export const CreateBranchSchema = 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)"),
      branch: z.string().describe("Name of the branch to be created"),
      ref: z.string().default("master").describe("Source branch name, the new branch will be created based on this branch, default value is master"),
    });
  • Core helper function createBranchFunc that constructs the API URL, handles repositoryId encoding, makes POST request to create branch, and parses response with CodeupBranchSchema.
    export async function createBranchFunc(
        organizationId: string,
        repositoryId: string,
        branch: string,
        ref: string = "master"
    ): Promise<z.infer<typeof CodeupBranchSchema>>{
      // 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
      const queryParams: Record<string, string | number | undefined> = {
        branch: branch,
        ref: ref
      };
    
      const url = buildUrl(baseUrl, queryParams);
      console.error("createBranchFunc url:" + url);
    
      const response = await yunxiaoRequest(url, {
        method: "POST",
      });
      return CodeupBranchSchema.parse(response);
    }

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