list_spaces
Retrieve all available spaces in your Octopus Deploy instance to verify space existence and access project boundaries before performing operations.
Instructions
List all spaces in the Octopus Deploy instance. Spaces is the main organizational unit in Octopus Deploy, Spaces keep the different projects, infrastructure and tenants completely separate. Spaces typically represent team or project boundary, but not customer boundary (use tenants for those). Always use this tool first to check that the requested space exists.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| partialName | No | ||
| skip | No | ||
| take | No |
Implementation Reference
- src/tools/listSpaces.ts:21-49 (handler)The handler function that implements the core logic of the 'list_spaces' tool: creates an Octopus Deploy client using environment config, queries the SpaceRepository for spaces with optional partialName filter, skip, and take parameters, maps the response to a simplified JSON structure, and returns it as a markdown text content block.async ({ partialName, skip, take }) => { const configuration = getClientConfigurationFromEnvironment(); const client = await Client.create(configuration); const spaceRepository = new SpaceRepository(client); const spacesResponse = await spaceRepository.list({ partialName, skip, take }); return { content: [ { type: "text", text: JSON.stringify({ totalResults: spacesResponse.TotalResults, itemsPerPage: spacesResponse.ItemsPerPage, numberOfPages: spacesResponse.NumberOfPages, lastPageNumber: spacesResponse.LastPageNumber, items: spacesResponse.Items.map((space) => ({ id: space.Id, name: space.Name, description: space.Description, isDefault: space.IsDefault, taskQueueStopped: space.TaskQueueStopped, })) }), }, ], }; } );
- src/tools/listSpaces.ts:13-16 (schema)Input schema validation using Zod for the 'list_spaces' tool parameters: optional partialName (string), skip (number), take (number). Defines the expected tool call arguments.partialName: z.string().optional(), skip: z.number().optional(), take: z.number().optional() },
- src/tools/listSpaces.ts:8-50 (registration)Primary registration function for the 'list_spaces' tool on the MCP server, including name, description, input schema, output metadata, and inline handler.export function registerListSpacesTool(server: McpServer) { server.tool( "list_spaces", `List all spaces in the Octopus Deploy instance. ${spacesDescription} Always use this tool first to check that the requested space exists.`, { partialName: z.string().optional(), skip: z.number().optional(), take: z.number().optional() }, { title: "List all spaces in an Octopus Deploy instance", readOnlyHint: true, }, async ({ partialName, skip, take }) => { const configuration = getClientConfigurationFromEnvironment(); const client = await Client.create(configuration); const spaceRepository = new SpaceRepository(client); const spacesResponse = await spaceRepository.list({ partialName, skip, take }); return { content: [ { type: "text", text: JSON.stringify({ totalResults: spacesResponse.TotalResults, itemsPerPage: spacesResponse.ItemsPerPage, numberOfPages: spacesResponse.NumberOfPages, lastPageNumber: spacesResponse.LastPageNumber, items: spacesResponse.Items.map((space) => ({ id: space.Id, name: space.Name, description: space.Description, isDefault: space.IsDefault, taskQueueStopped: space.TaskQueueStopped, })) }), }, ], }; } ); }
- src/tools/listSpaces.ts:52-56 (registration)Self-registration of the 'list_spaces' tool into the global TOOL_REGISTRY, specifying toolset 'core' and read-only nature, linking to the register function for dynamic tool loading.registerToolDefinition({ toolName: "list_spaces", config: { toolset: "core", readOnly: true }, registerFn: registerListSpacesTool, });
- src/tools/index.ts:58-65 (registration)Central registration function that iterates over all tools in TOOL_REGISTRY (including list_spaces via its self-registration) and conditionally registers enabled tools on the MCP server based on toolset config and read-only mode.export function registerTools(server: McpServer, config: ToolsetConfig = {}) { // Iterate through all registered tools and register those that are enabled for (const [, toolRegistration] of TOOL_REGISTRY) { if (isToolEnabled(toolRegistration, config)) { toolRegistration.registerFn(server); } } }