Skip to main content
Glama
OctopusDeploy

Octopus Deploy MCP Server

Official

get_branches

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", });

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