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
| Name | Required | Description | Default |
|---|---|---|---|
| partialName | No | ||
| skip | No | ||
| spaceName | Yes | ||
| take | No |
Implementation Reference
- src/tools/listEnvironments.ts:23-53 (handler)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, })) }), }, ], }; }
- src/tools/listEnvironments.ts:13-22 (schema)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, },
- src/tools/listEnvironments.ts:58-62 (registration)Self-registration of the 'list_environments' tool definition into the TOOL_REGISTRY.registerToolDefinition({ toolName: "list_environments", config: { toolset: "core", readOnly: true }, registerFn: registerListEnvironmentsTool, });
- src/tools/listEnvironments.ts:7-55 (registration)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, })) }), }, ], }; } ); }
- src/tools/index.ts:12-12 (registration)Import statement that loads the listEnvironments module, triggering its self-registration via registerToolDefinition.import "./listEnvironments.js";