Skip to main content
Glama
OctopusDeploy

Octopus Deploy MCP Server

Official

Get Git branches for a version-controlled project

get_branches
Read-onlyIdempotent

Retrieve Git branches for any version-controlled project in a named Octopus space, with optional filtering and pagination.

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 handler function that executes the get_branches tool logic: validates the project ID, creates an API client, resolves the space, calls getProjectBranches helper, and returns the formatted branch results.
      async ({ spaceName, projectId, searchByName, skip, take }) => {
        validateEntityId(projectId, 'project', ENTITY_PREFIXES.project);
    
        const options = {
          searchByName,
          skip,
          take,
        };
    
        try {
          const configuration = getClientConfigurationFromEnvironment();
          const client = await Client.create(configuration);
          const spaceId = await resolveSpaceId(client, spaceName);
    
          const branches = await getProjectBranches(client, spaceId, projectId, options);
    
          if (branches.Items.length === 0 && !searchByName) {
            throw new Error(
              `No branches found for project '${projectId}'. This may indicate that the project is not version controlled or ` +
              "uses database storage instead of Git. Only version controlled projects have branches."
            );
          }
    
          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,
                }),
              },
            ],
          };
        } catch (error) {
          handleOctopusApiError(error, {
            entityType: 'project',
            entityId: projectId,
            spaceName
          });
        }
      }
    );
  • Registration of the get_branches tool via McpServer.registerTool with input schema (spaceName, projectId, searchByName, skip, take), description, and read-only annotations.
    export function registerGetBranchesTool(server: McpServer) {
      server.registerTool(
        "get_branches",
        {
          title: "Get Git branches for a version-controlled project",
          description: `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.`,
          inputSchema: {
            spaceName: z.string(),
            projectId: z.string(),
            searchByName: z.string().optional(),
            skip: z.number().optional(),
            take: z.number().optional(),
          },
          annotations: READ_ONLY_TOOL_ANNOTATIONS,
        },
        async ({ spaceName, projectId, searchByName, skip, take }) => {
          validateEntityId(projectId, 'project', ENTITY_PREFIXES.project);
    
          const options = {
            searchByName,
            skip,
            take,
          };
    
          try {
            const configuration = getClientConfigurationFromEnvironment();
            const client = await Client.create(configuration);
            const spaceId = await resolveSpaceId(client, spaceName);
    
            const branches = await getProjectBranches(client, spaceId, projectId, options);
    
            if (branches.Items.length === 0 && !searchByName) {
              throw new Error(
                `No branches found for project '${projectId}'. This may indicate that the project is not version controlled or ` +
                "uses database storage instead of Git. Only version controlled projects have branches."
              );
            }
    
            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,
                  }),
                },
              ],
            };
          } catch (error) {
            handleOctopusApiError(error, {
              entityType: 'project',
              entityId: projectId,
              spaceName
            });
          }
        }
      );
    }
    
    registerToolDefinition({
      toolName: "get_branches",
      config: { toolset: "context", readOnly: true },
      registerFn: registerGetBranchesTool,
      minimumOctopusVersion: "2021.2",
  • Self-registration via registerToolDefinition, adding to the TOOL_REGISTRY map with toolset 'context', readOnly=true, and minimum Octopus version 2021.2.
    registerToolDefinition({
      toolName: "get_branches",
      config: { toolset: "context", readOnly: true },
      registerFn: registerGetBranchesTool,
      minimumOctopusVersion: "2021.2",
  • The getProjectBranches helper function that makes the API call to ~/api/{spaceId}/projects/{projectId}/git/branches with optional query params (searchByName, skip, 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;
    }
  • Type definitions for GitBranch interface (IsProtected, Name, CanonicalName) and GetProjectBranchesOptions (searchByName, skip, take).
    export interface GitBranch {
      IsProtected: boolean;
      Name: string;
      CanonicalName: string;
    }
    
    export interface GetProjectBranchesOptions {
      searchByName?: string;
      skip?: number;
      take?: number;
Behavior4/5

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

Annotations already declare the tool as read-only and idempotent. The description adds behavioral context by disclosing optional filtering and pagination parameters, though it does not explain error handling or rate limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is short and to the point, with no extraneous content. However, the first sentence repeats the title slightly, but overall it is efficiently structured.

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

Completeness3/5

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

Given 5 parameters and no output schema, the description covers the basic purpose and optional filters but does not describe the return format or potential errors, leaving some gaps for an AI agent.

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 properties have no descriptions (0% coverage). The description names the parameters and their roles (required vs optional for filtering/pagination) but lacks precise semantics like the format of searchByName or the exact meaning of skip/take.

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 tool retrieves Git branches for a specific project, with a specific verb and resource. It distinguishes itself from sibling tools as the only branch-related operation.

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 explains required parameters (spaceName, projectId) and optional filtering/pagination. It implies usage when listing branches for a known project, but does not explicitly mention when not to use it or alternatives.

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