Skip to main content
Glama
OctopusDeploy

Octopus Deploy MCP Server

Official
listDeployments.ts3.92 kB
import { Client, DeploymentRepository, TaskState, type Deployment } from "@octopusdeploy/api-client"; import { z } from "zod"; import { type McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { getClientConfigurationFromEnvironment } from "../helpers/getClientConfigurationFromEnvironment.js"; import { registerToolDefinition } from "../types/toolConfig.js"; export function registerListDeploymentsTool(server: McpServer) { server.tool( "list_deployments", `List deployments in a space This tool lists deployments in a given space. The space name is required. When requesting latest deployment consider which deployment state the user is interested in (successful or all). Optional filters include: projects (array of project IDs), environments (array of environment IDs), tenants (array of tenant IDs), channels (array of channel IDs), taskState (one of: Canceled, Cancelling, Executing, Failed, Queued, Success, TimedOut), and take (number of results to return).`, { spaceName: z.string(), projects: z.array(z.string()).optional(), environments: z.array(z.string()).optional(), tenants: z.array(z.string()).optional(), channels: z.array(z.string()).optional(), taskState: z.enum(["Canceled", "Cancelling", "Executing", "Failed", "Queued", "Success", "TimedOut"]).optional(), skip: z.number().optional(), take: z.number().optional() }, { title: "List deployments in an Octopus Deploy space", readOnlyHint: true, }, async ({ spaceName, projects, environments, tenants, channels, taskState, skip, take }) => { const configuration = getClientConfigurationFromEnvironment(); const client = await Client.create(configuration); const deploymentRepository = new DeploymentRepository(client, spaceName); const deploymentsResponse = await deploymentRepository.list({ projects, environments, tenants, channels, taskState: taskState ? TaskState[taskState as keyof typeof TaskState] : undefined, skip, take }); return { content: [ { type: "text", text: JSON.stringify({ totalResults: deploymentsResponse.TotalResults, itemsPerPage: deploymentsResponse.ItemsPerPage, numberOfPages: deploymentsResponse.NumberOfPages, lastPageNumber: deploymentsResponse.LastPageNumber, items: deploymentsResponse.Items.map((deployment: Deployment) => ({ spaceId: deployment.SpaceId, id: deployment.Id, name: deployment.Name, releaseId: deployment.ReleaseId, environmentId: deployment.EnvironmentId, tenantId: deployment.TenantId, projectId: deployment.ProjectId, channelId: deployment.ChannelId, created: deployment.Created, taskId: deployment.TaskId, deploymentProcessId: deployment.DeploymentProcessId, comments: deployment.Comments, formValues: deployment.FormValues, queueTime: deployment.QueueTime, queueTimeExpiry: deployment.QueueTimeExpiry, useGuidedFailure: deployment.UseGuidedFailure, specificMachineIds: deployment.SpecificMachineIds, excludedMachineIds: deployment.ExcludedMachineIds, skipActions: deployment.SkipActions, forcePackageDownload: deployment.ForcePackageDownload, forcePackageRedeployment: deployment.ForcePackageRedeployment, })) }), }, ], }; } ); } registerToolDefinition({ toolName: "list_deployments", config: { toolset: "deployments", readOnly: true }, registerFn: registerListDeploymentsTool, });

Implementation Reference

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