Skip to main content
Glama
Tiberriver256

Azure DevOps MCP Server

create_branch

Create a new branch from an existing branch in Azure DevOps repositories to support feature development, bug fixes, or code isolation.

Instructions

Create a new branch from an existing one

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdNoThe ID or name of the project (Default: MyProject)
organizationIdNoThe ID or name of the organization (Default: mycompany)
repositoryIdYesThe ID or name of the repository
sourceBranchYesName of the branch to copy from (without "refs/heads/", e.g., "master")
newBranchYesName of the new branch to create (without "refs/heads/", e.g., "feature/my-branch")

Implementation Reference

  • Core handler function that executes the branch creation logic using Azure DevOps Git API: fetches source branch commit, creates ref update, and pushes the new branch.
    export async function createBranch(
      connection: WebApi,
      options: CreateBranchOptions,
    ): Promise<void> {
      try {
        const gitApi = await connection.getGitApi();
        const source = await gitApi.getBranch(
          options.repositoryId,
          options.sourceBranch,
          options.projectId,
        );
        const commitId = source?.commit?.commitId;
        if (!commitId) {
          throw new AzureDevOpsError(
            `Source branch '${options.sourceBranch}' not found`,
          );
        }
    
        const refUpdate: GitRefUpdate = {
          name: `refs/heads/${options.newBranch}`,
          oldObjectId: '0000000000000000000000000000000000000000',
          newObjectId: commitId,
        };
    
        const result = await gitApi.updateRefs(
          [refUpdate],
          options.repositoryId,
          options.projectId,
        );
        if (!result.every((r) => r.success)) {
          throw new AzureDevOpsError('Failed to create new branch');
        }
      } catch (error) {
        if (error instanceof AzureDevOpsError) {
          throw error;
        }
        throw new Error(
          `Failed to create branch: ${error instanceof Error ? error.message : String(error)}`,
        );
      }
    }
  • Zod schema for validating input arguments to the create_branch tool: projectId, organizationId, repositoryId, sourceBranch, newBranch.
    export const CreateBranchSchema = z
      .object({
        projectId: z
          .string()
          .optional()
          .describe(`The ID or name of the project (Default: ${defaultProject})`),
        organizationId: z
          .string()
          .optional()
          .describe(`The ID or name of the organization (Default: ${defaultOrg})`),
        repositoryId: z.string().describe('The ID or name of the repository'),
        sourceBranch: z
          .string()
          .describe(
            'Name of the branch to copy from (without "refs/heads/", e.g., "master")',
          ),
        newBranch: z
          .string()
          .describe(
            'Name of the new branch to create (without "refs/heads/", e.g., "feature/my-branch")',
          ),
      })
      .describe(
        'Create a new branch from an existing branch.\n' +
          '- Pass plain branch names (no "refs/heads/"). Example: sourceBranch="master", newBranch="codex/test1".\n' +
          '- When creating pull requests later, use fully-qualified refs (e.g., "refs/heads/codex/test1").',
      );
  • MCP tool registration defining the 'create_branch' tool name, description, and JSON schema for inputs.
    {
      name: 'create_branch',
      description: 'Create a new branch from an existing one',
      inputSchema: zodToJsonSchema(CreateBranchSchema),
    },
  • Request handler switch case that parses arguments with CreateBranchSchema and invokes the createBranch handler function.
    case 'create_branch': {
      const args = CreateBranchSchema.parse(request.params.arguments);
      await createBranch(connection, {
        ...args,
        projectId: args.projectId ?? defaultProject,
      });
      return {
        content: [{ type: 'text', text: 'Branch created successfully' }],
      };
    }
  • TypeScript interface defining options passed to the createBranch handler function.
    export interface CreateBranchOptions {
      projectId: string;
      repositoryId: string;
      /** Source branch name to copy from */
      sourceBranch: string;
      /** Name of the new branch to create */
      newBranch: string;
    }
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. While 'Create' implies a write/mutation operation, the description doesn't address permissions required, whether the operation is idempotent, what happens if the branch already exists, or any rate limits. This leaves significant gaps for an agent to understand the tool's behavior.

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, clear sentence that efficiently communicates the core functionality without any wasted words. It's appropriately sized and front-loaded with the essential information.

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 mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the tool returns, error conditions, or behavioral constraints. Given the complexity of creating a branch in a version control system, more context about permissions, conflicts, and results is needed.

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 5 parameters thoroughly. The description adds no additional parameter information beyond what's in the schema, maintaining the baseline score of 3 for adequate but not enhanced parameter documentation.

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 the resource ('from an existing one'), making the purpose immediately understandable. However, it doesn't explicitly differentiate this tool from sibling tools like 'create_commit' or 'create_pull_request' in terms of when to use one over another for branch-related operations.

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. With sibling tools like 'create_commit' and 'create_pull_request' available, there's no indication of whether this should be used before creating commits or pull requests, or what the prerequisites might be for branch creation.

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/Tiberriver256/mcp-server-azure-devops'

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