Skip to main content
Glama
OctopusDeploy

Octopus Deploy MCP Server

Official

Update a feature toggle

update_feature_toggle
Destructive

Patch an existing feature toggle's default state, description, or per-environment settings (enable/disable, rollout percentages). Preserves unmentioned environments and fields.

Instructions

Adjust an existing customer feature toggle in an Octopus Deploy project.

Narrow surface — flip an environment on/off, change rollout percentages, or update the toggle-level description / default state. Internally fetches the current toggle, applies your patches in memory, and PUTs the merged body, so unmentioned environments and unmentioned fields are preserved.

Deliberately not exposed: name/slug rename, tag changes, rollout group attach/detach, tenant targeting, segments, minimum version, adding or removing environment configurations entirely. For those, use the Octopus UI.

Patches that reference an environment not already configured on the toggle are rejected with reason: environment_not_configured. The tool does not add new environment configurations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
spaceNameYesSpace name.
projectIdYesProject ID (e.g. Projects-123). Feature toggles are scoped per project.
slugYesThe toggle's Slug (not its Id). Find it via find_feature_toggles.
defaultIsEnabledNoToggle-level default. The value returned for environments that have no explicit per-environment configuration.
descriptionNoToggle-level description (max 1000 chars). Markdown supported in the UI.
environmentsNoPer-environment patches. Environments not listed here are preserved as-is. Each entry must reference a deploymentEnvironmentId that already exists on the toggle; unknown environments are rejected rather than silently added. Each environment may appear at most once in this array — duplicates are rejected.
confirmNoRequired only when the MCP client does not support elicitation. Set to true to confirm the update; otherwise the tool aborts.

Implementation Reference

  • Main handler that resolves the space, fetches the current toggle, applies environment patches, validates changes, prompts for confirmation, and PUTs the merged toggle resource.
    export async function updateFeatureToggleHandler(
      server: McpServer,
      params: UpdateFeatureToggleParams,
    ) {
      const { spaceName, projectId, slug, environments, confirm } = params;
    
      const noPatches =
        params.defaultIsEnabled === undefined &&
        params.description === undefined &&
        (!environments || environments.length === 0);
      if (noPatches) {
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(
                {
                  success: false,
                  reason: "no_patches",
                  message:
                    "No fields supplied to update. Pass at least one of defaultIsEnabled, description, or environments[].",
                },
                null,
                2,
              ),
            },
          ],
          isError: true,
        };
      }
    
      const client = await Client.create(getClientConfigurationFromEnvironment());
    
      let spaceId: string;
      try {
        spaceId = await resolveSpaceId(client, spaceName);
      } catch (error) {
        handleOctopusApiError(error, { spaceName });
      }
    
      let current: FeatureToggleResource;
      try {
        current = await client.get<FeatureToggleResource>(
          "~/api/{spaceId}/projects/{projectId}/featuretoggles/{slug}",
          { spaceId, projectId, slug },
        );
      } catch (error) {
        handleOctopusApiError(error, {
          entityType: "feature toggle",
          entityId: slug,
          spaceName,
          helpText:
            "Use find_feature_toggles to list valid slugs. If 404 persists across all toggles in the project, the customer feature toggles capability may be disabled on the Octopus instance.",
        });
      }
    
      // Match patch entries to existing environment configurations. Unknown
      // environments are rejected — the contract is "slight adjustment", not
      // "configure new environments".
      const envPatches: PatchedEnvironment[] = [];
      if (environments) {
        for (const patch of environments) {
          const existing = current.Environments.find(
            (e) => e.DeploymentEnvironmentId === patch.deploymentEnvironmentId,
          );
          if (!existing) {
            const configured = current.Environments.map(
              (e) => e.DeploymentEnvironmentId,
            );
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify(
                    {
                      success: false,
                      reason: "environment_not_configured",
                      message:
                        `Environment '${patch.deploymentEnvironmentId}' is not configured on toggle '${current.Slug}'. ` +
                        "This tool only adjusts existing environment configurations; it does not add new ones. " +
                        "Use the Octopus UI to add an environment to a toggle.",
                      configuredEnvironmentIds: configured,
                    },
                    null,
                    2,
                  ),
                },
              ],
              isError: true,
            };
          }
          envPatches.push(applyEnvironmentPatch(existing, patch));
        }
      }
    
      // Detect a no-op call (everything provided already matches current state)
      // before involving the user with a confirmation dialog.
      const toggleLevelChanges =
        (params.defaultIsEnabled !== undefined &&
          params.defaultIsEnabled !== current.DefaultIsEnabled) ||
        (params.description !== undefined &&
          params.description !== (current.Description ?? undefined));
      const envLevelChanges = envPatches.some((p) => p.changedFields.length > 0);
      if (!toggleLevelChanges && !envLevelChanges) {
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(
                {
                  success: true,
                  noOp: true,
                  message:
                    "All supplied fields already match the current toggle state — nothing to update.",
                  slug: current.Slug,
                },
                null,
                2,
              ),
            },
          ],
        };
      }
    
      const merged: FeatureToggleResource = {
        ...current,
        DefaultIsEnabled:
          params.defaultIsEnabled !== undefined
            ? params.defaultIsEnabled
            : current.DefaultIsEnabled,
        Description:
          params.description !== undefined ? params.description : current.Description,
        Environments: current.Environments.map((env) => {
          const patch = envPatches.find(
            (p) => p.current.DeploymentEnvironmentId === env.DeploymentEnvironmentId,
          );
          return patch ? patch.merged : env;
        }),
      };
    
      const confirmation = await requireConfirmation(server, {
        message: `Update feature toggle "${current.Name}" (${current.Slug}) in space ${spaceName}?`,
        fallbackConfirm: confirm,
        change: {
          source: buildDiffSource(current, params, envPatches),
          target: buildDiffTarget(params, envPatches),
        },
      });
      if (!confirmation.confirmed) {
        return unconfirmedResponse(confirmation, {
          action: "feature toggle update",
        });
      }
    
      try {
        await client.doUpdate<FeatureToggleResource>(
          "~/api/{spaceId}/projects/{projectId}/featuretoggles",
          merged,
          { spaceId, projectId },
        );
      } catch (error) {
        handleOctopusApiError(error, {
          entityType: "feature toggle",
          entityId: current.Id,
          spaceName,
          helpText:
            "Verify you have FeatureToggleEdit on the project and every environment referenced. Server-side validation rules (max segments, ephemeral environment clamping, etc.) are documented in the Octopus feature toggles API reference.",
        });
      }
    
      const encodedSpace = encodeURIComponent(spaceName);
      const encodedProjectId = encodeURIComponent(projectId);
      const encodedSlug = encodeURIComponent(current.Slug);
      const resourceUri = `octopus://spaces/${encodedSpace}/projects/${encodedProjectId}/featuretoggles/${encodedSlug}`;
    
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify(
              {
                success: true,
                id: current.Id,
                slug: current.Slug,
                name: current.Name,
                resourceUri,
                message: `Feature toggle '${current.Slug}' updated successfully.`,
                helpText:
                  "Dereference resourceUri to read the updated toggle body.",
              },
              null,
              2,
            ),
          },
        ],
      };
    }
  • Input validation schema with superRefine that rejects duplicate deploymentEnvironmentIds in the environments array.
    export const updateFeatureToggleValidationSchema =
      updateFeatureToggleInputSchema.superRefine((args, ctx) => {
        // Reject duplicate deploymentEnvironmentIds up front. Without this,
        // the merge picks the FIRST patch for the env while the confirmation
        // diff overwrites earlier entries with later ones using the same key —
        // the user could see one change in the prompt and a different one
        // actually go through.
        if (!args.environments) return;
        const seen = new Map<string, number>();
        for (let i = 0; i < args.environments.length; i++) {
          const id = args.environments[i].deploymentEnvironmentId;
          const prev = seen.get(id);
          if (prev !== undefined) {
            ctx.addIssue({
              code: z.ZodIssueCode.custom,
              message:
                `Duplicate environment entry for '${id}' at index ${i} (also at index ${prev}). ` +
                "Combine the patches into a single entry per environment.",
              path: ["environments", i, "deploymentEnvironmentId"],
            });
          }
          seen.set(id, i);
        }
      });
  • Raw input schema (published as inputSchema for the MCP tool registration) defining spaceName, projectId, slug, defaultIsEnabled, description, environments (array of patches), and confirm.
    export const updateFeatureToggleInputSchema = z.object(
      updateFeatureToggleRawShape,
    );
  • Schema for per-environment patches: deploymentEnvironmentId, isEnabled, rolloutPercentage, clientRolloutPercentage.
    const environmentPatchSchema = z.object({
  • Self-registration via registerToolDefinition, called at module import time (side effect when src/tools/index.ts imports the file).
    registerToolDefinition({
      toolName: "update_feature_toggle",
      config: { toolset: "featureToggles", readOnly: false },
      registerFn: registerUpdateFeatureToggleTool,
      minimumOctopusVersion: "2026.1.10655",
    });
  • Registers the tool with the MCP server under the name 'update_feature_toggle', with input schema and a callback that validates and delegates to the handler.
    export function registerUpdateFeatureToggleTool(server: McpServer) {
      server.registerTool(
        "update_feature_toggle",
        {
          title: "Update a feature toggle",
          description: `Adjust an existing customer feature toggle in an Octopus Deploy project.
    
    Narrow surface — flip an environment on/off, change rollout percentages, or update the toggle-level description / default state. Internally fetches the current toggle, applies your patches in memory, and PUTs the merged body, so unmentioned environments and unmentioned fields are preserved.
    
    Deliberately not exposed: name/slug rename, tag changes, rollout group attach/detach, tenant targeting, segments, minimum version, adding or removing environment configurations entirely. For those, use the Octopus UI.
    
    Patches that reference an environment not already configured on the toggle are rejected with reason: environment_not_configured. The tool does not add new environment configurations.`,
          inputSchema: updateFeatureToggleInputSchema,
          annotations: DESTRUCTIVE_WRITE_TOOL_ANNOTATIONS,
        },
        async (args) => {
          const parsed = updateFeatureToggleValidationSchema.safeParse(args);
          if (!parsed.success) return zodErrorResponse(parsed.error);
          return updateFeatureToggleHandler(server, parsed.data);
        },
      );
    }
Behavior4/5

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

Annotations indicate destructiveHint: true. The description adds behavioral context: it fetches the current toggle, applies patches in memory, PUTs the merged body, preserving unmentioned fields. It also explains rejection of unknown environment references. This adds value beyond annotations.

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

Conciseness5/5

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

The description is well-structured and concise. It starts with the primary purpose, then details the scope, explicitly lists exclusions, and explains error conditions. Every sentence adds value without redundancy.

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

Completeness4/5

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

Given the complexity (7 parameters, destructive action, no output schema), the description covers essential behavioral aspects, error handling, and usage boundaries. It lacks mention of return values, but that is acceptable without an output schema. Overall comprehensive.

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

Parameters4/5

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

Input schema covers all 7 parameters with descriptions (100% coverage). The description adds supplementary context, such as explaining that unmentioned environments are preserved, duplicates are rejected, and the confirm parameter's conditional requirement.

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: 'Adjust an existing customer feature toggle in an Octopus Deploy project.' It specifies the narrow surface (flip environments, change rollout, update description/default state) and explicitly lists what is not exposed, distinguishing it from other operations.

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

Usage Guidelines5/5

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

The description provides explicit guidance: it states what is deliberately not exposed and directs users to the Octopus UI for those cases. It also explains that patches referencing unknown environments are rejected with a specific reason, and that slugs are obtained via find_feature_toggles.

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