list_tenants
Retrieve all tenants within a specified Octopus Deploy space. Filter results by project, tags, IDs, or name, and use pagination for large datasets.
Instructions
List tenants in a space
This tool lists all tenants in a given space. The space name is required. Optionally provide skip and take parameters for pagination.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| spaceName | Yes | The space name | |
| skip | No | ||
| take | No | ||
| projectId | No | Filter by specific project ID | |
| tags | No | Filter by tenant tags (comma-separated list) | |
| ids | No | Filter by specific tenant IDs | |
| partialName | No | Filter by partial tenant name match |
Implementation Reference
- src/tools/listTenants.ts:28-73 (handler)The handler function that fetches and returns the list of tenants from the Octopus Deploy API, including pagination info and tenant details with public URLs.async ({spaceName, skip, take, projectId, tags, ids, partialName}) => { const configuration = getClientConfigurationFromEnvironment(); const client = await Client.create(configuration); const spaceId = await resolveSpaceId(client, spaceName); const tenantsResponse = await client.get<ResourceCollection<TenantResource>>( "~/api/{spaceId}/tenants{?skip,take,projectId,tags,ids,partialName}", { spaceId, skip, take, projectId, tags, ids, partialName }); return { content: [ { type: "text", text: JSON.stringify({ totalResults: tenantsResponse.TotalResults, itemsPerPage: tenantsResponse.ItemsPerPage, numberOfPages: tenantsResponse.NumberOfPages, lastPageNumber: tenantsResponse.LastPageNumber, items: tenantsResponse.Items.map(tenant => ({ id: tenant.Id, name: tenant.Name, slug: tenant.Slug, description: tenant.Description, isDisabled: tenant.IsDisabled ?? false, // Disabling tenants was introduced in 2024.4. Prior to that, all tenants could be considered IsDisabled=false. tenantTags: tenant.TenantTags, clonedFromTenantId: tenant.ClonedFromTenantId, spaceId: tenant.SpaceId, publicUrl: getPublicUrl(`${configuration.instanceURL}/app#/{spaceId}/tenants/{tenantId}/overview`, { spaceId: tenant.SpaceId, tenantId: tenant.Id }), publicUrlInstruction: `You can view more details about this tenant in the Octopus Deploy web portal at the provided publicUrl.` })) }), }, ], }; }
- src/tools/listTenants.ts:15-23 (schema)Zod schema defining input parameters for the list_tenants tool: spaceName (required), optional pagination (skip, take), and filters (projectId, tags, ids, partialName).{ spaceName: z.string().describe("The space name"), skip: z.number().optional(), take: z.number().optional(), projectId: z.string().optional().describe("Filter by specific project ID"), tags: z.string().optional().describe("Filter by tenant tags (comma-separated list)"), ids: z.array(z.string()).optional().describe("Filter by specific tenant IDs"), partialName: z.string().optional().describe("Filter by partial tenant name match") },
- src/tools/listTenants.ts:9-75 (registration)The registerListTenantsTool function that calls server.tool to register the list_tenants tool with MCP server, including name, description, input schema, output hints, and handler.export function registerListTenantsTool(server: McpServer) { server.tool( "list_tenants", `List tenants in a space This tool lists all tenants in a given space. The space name is required. Optionally provide skip and take parameters for pagination.`, { spaceName: z.string().describe("The space name"), skip: z.number().optional(), take: z.number().optional(), projectId: z.string().optional().describe("Filter by specific project ID"), tags: z.string().optional().describe("Filter by tenant tags (comma-separated list)"), ids: z.array(z.string()).optional().describe("Filter by specific tenant IDs"), partialName: z.string().optional().describe("Filter by partial tenant name match") }, { title: "List all tenants in an Octopus Deploy space", readOnlyHint: true, }, async ({spaceName, skip, take, projectId, tags, ids, partialName}) => { const configuration = getClientConfigurationFromEnvironment(); const client = await Client.create(configuration); const spaceId = await resolveSpaceId(client, spaceName); const tenantsResponse = await client.get<ResourceCollection<TenantResource>>( "~/api/{spaceId}/tenants{?skip,take,projectId,tags,ids,partialName}", { spaceId, skip, take, projectId, tags, ids, partialName }); return { content: [ { type: "text", text: JSON.stringify({ totalResults: tenantsResponse.TotalResults, itemsPerPage: tenantsResponse.ItemsPerPage, numberOfPages: tenantsResponse.NumberOfPages, lastPageNumber: tenantsResponse.LastPageNumber, items: tenantsResponse.Items.map(tenant => ({ id: tenant.Id, name: tenant.Name, slug: tenant.Slug, description: tenant.Description, isDisabled: tenant.IsDisabled ?? false, // Disabling tenants was introduced in 2024.4. Prior to that, all tenants could be considered IsDisabled=false. tenantTags: tenant.TenantTags, clonedFromTenantId: tenant.ClonedFromTenantId, spaceId: tenant.SpaceId, publicUrl: getPublicUrl(`${configuration.instanceURL}/app#/{spaceId}/tenants/{tenantId}/overview`, { spaceId: tenant.SpaceId, tenantId: tenant.Id }), publicUrlInstruction: `You can view more details about this tenant in the Octopus Deploy web portal at the provided publicUrl.` })) }), }, ], }; } ); }
- src/tools/listTenants.ts:77-81 (registration)Self-registration of the tool in the TOOL_REGISTRY via registerToolDefinition, allowing conditional registration based on config in index.ts.registerToolDefinition({ toolName: "list_tenants", config: {toolset: "tenants", readOnly: true}, registerFn: registerListTenantsTool, });