list_spaces
Retrieve all organizational spaces in Octopus Deploy to verify availability and manage project, infrastructure, and tenant separation.
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-48 (handler)The handler function that implements the core logic of the 'list_spaces' tool. It uses the Octopus Deploy API client to list spaces with optional pagination and filtering, then formats and returns the results as a text content block with JSON data.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:12-20 (schema)Input schema using Zod for optional parameters partialName, skip, take; and output metadata indicating read-only nature.{ partialName: z.string().optional(), skip: z.number().optional(), take: z.number().optional() }, { title: "List all spaces in an Octopus Deploy instance", readOnlyHint: true, },
- src/tools/listSpaces.ts:8-50 (registration)The registerListSpacesTool function that registers the 'list_spaces' tool on the MCP server, including name, description, schema, and 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 for conditional registration based on toolset config.registerToolDefinition({ toolName: "list_spaces", config: { toolset: "core", readOnly: true }, registerFn: registerListSpacesTool, });
- src/tools/index.ts:10-10 (registration)Import statement in index.ts that loads the listSpaces module, triggering its self-registration.import "./listSpaces.js";