Skip to main content
Glama
OctopusDeploy

Octopus Deploy MCP Server

Official

get_branches

Read-only

Retrieve Git branches for version-controlled projects in Octopus Deploy. Filter branches by name and manage results with pagination to streamline DevOps workflows.

Instructions

Get Git branches for a version-controlled project

This tool retrieves Git branches for a specific project in a space. The space name and project ID are required. Optionally provide searchByName, skip, and take parameters for filtering and pagination.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
spaceNameYes
projectIdYes
searchByNameNo
skipNo
takeNo

Implementation Reference

  • The main handler function implementing the get_branches tool logic: sets up Octopus client, resolves space ID, calls helper to fetch branches, formats and returns as MCP text content.
    async ({ spaceName, projectId, searchByName, skip, take }) => {
      const configuration = getClientConfigurationFromEnvironment();
      const client = await Client.create(configuration);
      const spaceId = await resolveSpaceId(client, spaceName);
    
      const options = {
        searchByName,
        skip,
        take,
      };
    
      const branches = await getProjectBranches(client, spaceId, projectId, options);
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({
              Items: branches.Items.map(branch => ({
                Name: branch.Name,
                IsProtected: branch.IsProtected,
                CanonicalName: branch.CanonicalName,
              })),
              TotalResults: branches.TotalResults,
              ItemsPerPage: branches.ItemsPerPage,
              NumberOfPages: branches.NumberOfPages,
              LastPageNumber: branches.LastPageNumber,
              ItemType: branches.ItemType,
            }),
          },
        ],
      };
    }
  • Zod input schema for the get_branches tool parameters.
      spaceName: z.string(),
      projectId: z.string(),
      searchByName: z.string().optional(),
      skip: z.number().optional(),
      take: z.number().optional(),
    },
  • Registration of the get_branches tool on the MCP server using server.tool(), including name, description, input schema, output metadata, and handler function.
    export function registerGetBranchesTool(server: McpServer) {
      server.tool(
        "get_branches",
        `Get Git branches for a version-controlled project
    
    This tool retrieves Git branches for a specific project in a space. The space name and project ID are required. Optionally provide searchByName, skip, and take parameters for filtering and pagination.`,
        {
          spaceName: z.string(),
          projectId: z.string(),
          searchByName: z.string().optional(),
          skip: z.number().optional(),
          take: z.number().optional(),
        },
        {
          title: "Get Git branches for a version-controlled project",
          readOnlyHint: true,
        },
        async ({ spaceName, projectId, searchByName, skip, take }) => {
          const configuration = getClientConfigurationFromEnvironment();
          const client = await Client.create(configuration);
          const spaceId = await resolveSpaceId(client, spaceName);
    
          const options = {
            searchByName,
            skip,
            take,
          };
    
          const branches = await getProjectBranches(client, spaceId, projectId, options);
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify({
                  Items: branches.Items.map(branch => ({
                    Name: branch.Name,
                    IsProtected: branch.IsProtected,
                    CanonicalName: branch.CanonicalName,
                  })),
                  TotalResults: branches.TotalResults,
                  ItemsPerPage: branches.ItemsPerPage,
                  NumberOfPages: branches.NumberOfPages,
                  LastPageNumber: branches.LastPageNumber,
                  ItemType: branches.ItemType,
                }),
              },
            ],
          };
        }
      );
    }
  • Supporting helper function that performs the actual API call to retrieve Git branches for a project, handling query parameters for search, skip, and take.
    export async function getProjectBranches(
      client: Client,
      spaceId: string,
      projectId: string,
      options?: GetProjectBranchesOptions
    ): Promise<ResourceCollection<GitBranch>> {
      const queryParams: Record<string, string> = {};
      
      if (options?.searchByName) {
        queryParams.searchByName = options.searchByName;
      }
      
      if (options?.skip !== undefined) {
        queryParams.skip = options.skip.toString();
      }
      
      if (options?.take !== undefined) {
        queryParams.take = options.take.toString();
      }
    
      const result = await client.get<ResourceCollection<GitBranch>>(
        "~/api/{spaceId}/projects/{projectId}/git/branches{?skip,take,searchByName}",
        {
          spaceId,
          projectId,
          ...queryParams,
        },
      );
    
      return result;
    }
  • Self-registration of the get_branches tool into the global TOOL_REGISTRY for conditional registration in index.ts based on toolset config.
    registerToolDefinition({
      toolName: "get_branches",
      config: { toolset: "context", readOnly: true },
      registerFn: registerGetBranchesTool,
      minimumOctopusVersion: "2021.2",
    });
Behavior3/5

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

Annotations include readOnlyHint=true, indicating a safe read operation, which the description aligns with by using 'retrieves'. The description adds context about filtering and pagination behavior, but does not disclose additional traits like rate limits, auth needs, or return format. With annotations covering safety, this adds some value but lacks rich behavioral details.

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 front-loaded with the core purpose in the first sentence, followed by specifics in the second. Both sentences earn their place by clarifying parameters and usage without redundancy. It is appropriately sized and structured for efficient understanding.

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

Completeness4/5

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

Given 5 parameters with 0% schema coverage and no output schema, the description compensates well by explaining all parameters and their roles. However, it lacks details on return values or error handling, which would enhance completeness for a tool with no output schema. It is largely adequate but has minor gaps.

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

Parameters4/5

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

Schema description coverage is 0%, so the description carries the burden. It explains the purpose of all 5 parameters: spaceName and projectId as required, and searchByName, skip, and take for filtering and pagination. This adds significant meaning beyond the schema, though it could provide more details on parameter formats or constraints.

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

Purpose5/5

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

The description clearly states the specific action ('retrieves Git branches') and resource ('for a specific project in a space'), distinguishing it from sibling tools like get_account or list_projects by focusing on version control branches. It explicitly mentions the required parameters (space name and project ID), making the purpose unambiguous.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('for a version-controlled project') and mentions optional parameters for filtering and pagination, but it does not explicitly state when not to use it or name alternatives. It implies usage for branch retrieval without comparing to other tools, which is adequate but not fully explicit.

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/OctopusDeploy/mcp-server'

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