Skip to main content
Glama
OctopusDeploy

Octopus Deploy MCP Server

Official

list_environments

Retrieve all configured environments in a specified space to understand available deployment targets and infrastructure setup.

Instructions

List environments in a space

This tool lists all environments in a given space. The space name is required. Use this tool as early as possible to understand which environments are configured. Optionally filter by partial name match using partialName parameter.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
partialNameNo
skipNo
spaceNameYes
takeNo

Implementation Reference

  • The main handler function for the 'list_environments' tool. It creates an Octopus Deploy client, queries the environment repository for the given space with optional filters, and returns the paginated results as JSON text content.
    async ({ spaceName, partialName, skip, take }) => { const configuration = getClientConfigurationFromEnvironment(); const client = await Client.create(configuration); const environmentRepository = new EnvironmentRepository(client, spaceName); const environmentsResponse = await environmentRepository.list({ partialName, skip, take }); return { content: [ { type: "text", text: JSON.stringify({ totalResults: environmentsResponse.TotalResults, itemsPerPage: environmentsResponse.ItemsPerPage, numberOfPages: environmentsResponse.NumberOfPages, lastPageNumber: environmentsResponse.LastPageNumber, items: environmentsResponse.Items.map((environment: DeploymentEnvironment) => ({ spaceId: environment.SpaceId, id: environment.Id, name: environment.Name, description: environment.Description, sortOrder: environment.SortOrder, useGuidedFailure: environment.UseGuidedFailure, allowDynamicInfrastructure: environment.AllowDynamicInfrastructure, extensionSettings: environment.ExtensionSettings, })) }), }, ], }; }
  • Input validation schema using Zod for parameters (spaceName required, others optional) and output metadata for the 'list_environments' tool.
    { spaceName: z.string(), partialName: z.string().optional(), skip: z.number().optional(), take: z.number().optional() }, { title: "List all environments in an Octopus Deploy space", readOnlyHint: true, },
  • Self-registration of the 'list_environments' tool definition into the TOOL_REGISTRY.
    registerToolDefinition({ toolName: "list_environments", config: { toolset: "core", readOnly: true }, registerFn: registerListEnvironmentsTool, });
  • The registration function that registers the 'list_environments' tool on the MCP server using server.tool(), including name, description, schema, and handler.
    export function registerListEnvironmentsTool(server: McpServer) { server.tool( "list_environments", `List environments in a space This tool lists all environments in a given space. The space name is required. Use this tool as early as possible to understand which environments are configured. Optionally filter by partial name match using partialName parameter.`, { spaceName: z.string(), partialName: z.string().optional(), skip: z.number().optional(), take: z.number().optional() }, { title: "List all environments in an Octopus Deploy space", readOnlyHint: true, }, async ({ spaceName, partialName, skip, take }) => { const configuration = getClientConfigurationFromEnvironment(); const client = await Client.create(configuration); const environmentRepository = new EnvironmentRepository(client, spaceName); const environmentsResponse = await environmentRepository.list({ partialName, skip, take }); return { content: [ { type: "text", text: JSON.stringify({ totalResults: environmentsResponse.TotalResults, itemsPerPage: environmentsResponse.ItemsPerPage, numberOfPages: environmentsResponse.NumberOfPages, lastPageNumber: environmentsResponse.LastPageNumber, items: environmentsResponse.Items.map((environment: DeploymentEnvironment) => ({ spaceId: environment.SpaceId, id: environment.Id, name: environment.Name, description: environment.Description, sortOrder: environment.SortOrder, useGuidedFailure: environment.UseGuidedFailure, allowDynamicInfrastructure: environment.AllowDynamicInfrastructure, extensionSettings: environment.ExtensionSettings, })) }), }, ], }; } ); }
  • Import statement that loads the listEnvironments module, triggering its self-registration via registerToolDefinition.
    import "./listEnvironments.js";

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