Skip to main content
Glama
OctopusDeploy

Octopus Deploy MCP Server

Official

Find tenants in an Octopus Deploy space

find_tenants
Read-onlyIdempotent

Retrieve a specific tenant by ID or list all tenants in a space with optional filtering by project, tags, or name. Manage customer-specific deployments and configurations.

Instructions

Find tenants in a space - can retrieve a single tenant by ID or list all tenants

This unified tool can either:

  • Get details for a specific tenant when tenantId is provided, including the projects and environments the tenant is associated with

  • List all tenants in a space when tenantId is omitted

Tenants represent customers or clients in Octopus Deploy, allowing you to manage deployments and configurations specific to each tenant. Tenants can be grouped into tenant tags for easier management and deployment targeting. Tenants can also represent geographical locations, organizational units, or any other logical grouping.

Optionally provide filtering and pagination parameters when listing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
spaceNameYesThe space name
tenantIdNoThe ID of a specific tenant to retrieve. If omitted, lists all tenants.
skipNoNumber of tenants to skip for pagination (only used when listing)
takeNoNumber of tenants to take for pagination (only used when listing)
projectIdNoFilter by specific project ID (only used when listing)
tagsNoFilter by tenant tags (comma-separated list, only used when listing)
idsNoFilter by specific tenant IDs (only used when listing)
partialNameNoFilter by partial tenant name match (only used when listing)

Implementation Reference

  • The main handler function for the 'find_tenants' tool. It either fetches a single tenant by ID (with validation via validateEntityId) or lists all tenants in a space with optional filtering and pagination (skip, take, projectId, tags, ids, partialName). Uses the Octopus Deploy API client to make requests and returns standardized content with public URLs.
    export async function findTenantsHandler(params: FindTenantsParams) {
      const { spaceName, tenantId, skip, take, projectId, tags, ids, partialName } = params;
      const configuration = getClientConfigurationFromEnvironment();
      const client = await Client.create(configuration);
      const spaceId = await resolveSpaceId(client, spaceName);
    
      // If tenantId is provided, get a single tenant
      if (tenantId) {
        validateEntityId(tenantId, "tenant", ENTITY_PREFIXES.tenant);
    
        try {
          const tenant = await client.get<TenantResource>(
            "~/api/{spaceId}/tenant/{tenantId}",
            { spaceId, tenantId },
          );
    
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify({
                  id: tenant.Id,
                  name: tenant.Name,
                  slug: tenant.Slug,
                  description: tenant.Description,
                  isDisabled: tenant.IsDisabled,
                  projectEnvironments: tenant.ProjectEnvironments,
                  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.`,
                }),
              },
            ],
          };
        } catch (error) {
          handleOctopusApiError(error, {
            entityType: "tenant",
            entityId: tenantId,
            spaceName,
          });
        }
      }
    
      // Otherwise, list tenants
      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" as const,
            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,
                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.`,
              })),
            }),
          },
        ],
      };
    }
  • FindTenantsParams interface defining input parameters: spaceName (required), tenantId, skip, take, projectId, tags, ids, partialName (all optional). The Zod inputSchema in the registration (lines 143-164) mirrors these with descriptions for the MCP tool.
    export interface FindTenantsParams {
      spaceName: string;
      tenantId?: string;
      skip?: number;
      take?: number;
      projectId?: string;
      tags?: string;
      ids?: string[];
      partialName?: string;
    }
  • Registration of the 'find_tenants' tool. registerFindTenantsTool (line 129) calls server.registerTool with name 'find_tenants', title, description, Zod inputSchema, READ_ONLY_TOOL_ANNOTATIONS, and the handler. registerToolDefinition (line 171) adds it to the global TOOL_REGISTRY under toolset 'tenants' with readOnly: true.
    export function registerFindTenantsTool(server: McpServer) {
      server.registerTool(
        "find_tenants",
        {
          title: "Find tenants in an Octopus Deploy space",
          description: `Find tenants in a space - can retrieve a single tenant by ID or list all tenants
    
      This unified tool can either:
      - Get details for a specific tenant when tenantId is provided, including the projects and environments the tenant is associated with
      - List all tenants in a space when tenantId is omitted
    
      ${tenantsDescription}
    
      Optionally provide filtering and pagination parameters when listing.`,
          inputSchema: {
            spaceName: z.string().describe("The space name"),
            tenantId: z.string().optional().describe("The ID of a specific tenant to retrieve. If omitted, lists all tenants."),
            skip: z.number().optional().describe("Number of tenants to skip for pagination (only used when listing)"),
            take: z.number().optional().describe("Number of tenants to take for pagination (only used when listing)"),
            projectId: z
              .string()
              .optional()
              .describe("Filter by specific project ID (only used when listing)"),
            tags: z
              .string()
              .optional()
              .describe("Filter by tenant tags (comma-separated list, only used when listing)"),
            ids: z
              .array(z.string())
              .optional()
              .describe("Filter by specific tenant IDs (only used when listing)"),
            partialName: z
              .string()
              .optional()
              .describe("Filter by partial tenant name match (only used when listing)"),
          },
          annotations: READ_ONLY_TOOL_ANNOTATIONS,
        },
        findTenantsHandler,
      );
    }
    
    registerToolDefinition({
      toolName: "find_tenants",
      config: { toolset: "tenants", readOnly: true },
      registerFn: registerFindTenantsTool,
    });
  • TenantResource type definition and tenantsDescription. TenantResource extends SpaceScopedResource and NamedResource with fields: IsDisabled, Slug, Description, ClonedFromTenantId, TenantTags, and ProjectEnvironments (a map of project IDs to environment ID arrays).
    import { type NamedResource, type SpaceScopedResource } from "./baseResource.js";
    
    export const tenantsDescription = "Tenants represent customers or clients in Octopus Deploy, allowing you to manage deployments and configurations specific to each tenant. Tenants can be grouped into tenant tags for easier management and deployment targeting. Tenants can also represent geographical locations, organizational units, or any other logical grouping.";
    
    export interface TenantResource extends SpaceScopedResource, NamedResource {
        IsDisabled: boolean | undefined;
        Slug: string;
        Description: string | null;
        ClonedFromTenantId: string | null;
        TenantTags: string[];
        ProjectEnvironments: {
            [projectId: string]: string[];
        };
    }
  • Import of findTenants.ts in the central tool index file (src/tools/index.ts), which triggers self-registration when the module is loaded.
    import "./findTenants.js";
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description elaborates on the tool's behavior beyond annotations, such as explaining that retrieving a single tenant includes associated projects and environments, and providing domain context about what tenants represent. There is no contradiction with annotations (readOnlyHint=true, destructiveHint=false).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with separate paragraphs for the core functionality, usage modes, and domain context. While it includes extra context about tenants, it remains focused and does not contain wasteful sentences, though it could be slightly more concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (8 parameters, no output schema, rich annotations), the description covers all necessary aspects: dual functionality, filtering/pagination options, and tenant domain context. It provides complete guidance for using the tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Since the input schema has 100% description coverage, the description adds limited new meaning beyond the schema. It reiterates the conditional use of tenantId and mentions filtering/pagination broadly, but does not enrich parameter semantics significantly. Baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Find tenants in a space' and distinguishes between retrieving a single tenant by ID or listing all tenants. It uses specific verbs and resource, and the dual-mode behavior is explicitly described, making it highly clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear conditions for when to use each mode (tenantId provided vs omitted) and mentions optional filtering and pagination parameters for listing. However, it does not explicitly differentiate from sibling tools like find_accounts, though the entity context makes it somewhat clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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