Skip to main content
Glama
OctopusDeploy

Octopus Deploy MCP Server

Official

get_branches

Retrieve Git branches for version-controlled projects in Octopus Deploy spaces. Filter branches by name and manage results with pagination for efficient project management.

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
projectIdYes
searchByNameNo
skipNo
spaceNameYes
takeNo

Implementation Reference

  • The main handler function for the 'get_branches' tool. It creates an Octopus client, resolves the space ID, calls the getProjectBranches helper, and returns the formatted JSON response.
    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 defining parameters for the get_branches tool: spaceName, projectId, and optional pagination/filtering.
    spaceName: z.string(), projectId: z.string(), searchByName: z.string().optional(), skip: z.number().optional(), take: z.number().optional(), },
  • Primary registration of the 'get_branches' tool using server.tool, including name, description, schema, metadata, and handler.
    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, }), }, ], }; } ); }
  • Registers the tool definition in the TOOL_REGISTRY for conditional enabling via toolsets.
    registerToolDefinition({ toolName: "get_branches", config: { toolset: "context", readOnly: true }, registerFn: registerGetBranchesTool, minimumOctopusVersion: "2021.2", });
  • Supporting helper function that performs the actual API call to retrieve Git branches for a project from Octopus Deploy.
    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; }

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