Skip to main content
Glama
JaxonDigital

Optimizely DXP MCP Server

by JaxonDigital

reset_deployment

Rollback a deployment to its previous state when verification fails or errors occur. Reverses code changes and optionally database modifications.

Instructions

↩️ Rollback deployment to previous state. ASYNC: 5-15min. Reverses all changes made by deployment, restoring previous code and optionally database. Use when deployment verification fails or errors detected. Set resetWithDbRollback=true to also rollback database changes. Deployment transitions to "Reset" status when complete. Required: deploymentId. Agent workflow: If deployment verification fails → reset_deployment() → investigate logs with analyze_logs_streaming().

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deploymentIdYes
projectNameNo
projectIdNo
apiKeyNo
apiSecretNo

Implementation Reference

  • Primary handler implementation for the reset_deployment tool. Includes parameter validation, deployment status check, REST API call to reset, event emission, background monitoring, and response formatting.
    static async handleResetDeployment(args: ResetDeploymentArgs): Promise<any> {
        // Check if this is a self-hosted project
        if (args.isSelfHosted || args.connectionString) {
            return ResponseBuilder.invalidParams('Deployment reset is not available for self-hosted projects. Self-hosted projects can only download existing backups and blobs.');
        }
    
        if (!args.apiKey || !args.apiSecret || !args.projectId || !args.deploymentId) {
            return ResponseBuilder.invalidParams('Missing required parameters');
        }
    
        try {
            const result = await this.resetDeployment(args);
    
            // Check if result is already a structured response with data and message
            if (result && typeof result === 'object' && 'data' in result && 'message' in result) {
                return ResponseBuilder.successWithStructuredData(result.data, result.message);
            }
    
            // Fallback for legacy string responses
            return ResponseBuilder.success(result);
        } catch (error: any) {
            console.error('Reset deployment error:', error);
            return ResponseBuilder.internalError('Failed to reset deployment', error.message);
        }
    }
    
    static async resetDeployment(args: ResetDeploymentArgs): Promise<any> {
        const { apiKey, apiSecret, projectId, deploymentId, projectName } = args;
    
        console.error(`Resetting deployment ${deploymentId} for project ${projectId}`);
    
        // DXP-101: Get deployment details to determine if DB rollback is needed (using REST API)
        let includeDbRollback = false;
        let deploymentData: DeploymentResult | null = null;
    
        try {
            const statusResult: DeploymentResult = await DXPRestClient.getDeployments(
                projectId!,
                apiKey!,
                apiSecret!,
                deploymentId!,
                { apiUrl: args.apiUrl }
            );
    
            if (statusResult) {
                // Check if this deployment included database changes
                deploymentData = statusResult;
                includeDbRollback = (deploymentData as any).includeDatabase === true;
            }
        } catch (error: any) {
            console.error('Warning: Could not check deployment details before reset:', error.message);
            // Continue with reset even if we can't check details
        }
    
        // DXP-101: Use REST API instead of PowerShell (3-10x faster, no PowerShell dependency)
        let resetData: DeploymentResult = {} as DeploymentResult;
        try {
            const result: DeploymentResult = await DXPRestClient.resetDeployment(
                projectId!,
                apiKey!,
                apiSecret!,
                deploymentId!,
                {}, // No additional reset options needed
                { apiUrl: args.apiUrl } // Support custom API URLs
            );
    
            resetData = result || ({} as DeploymentResult);
    
            // Merge deployment data if available
            if (deploymentData && deploymentData.parameters) {
                resetData.parameters = deploymentData.parameters;
            }
    
            // DXP-136: Emit deployment reset event
            try {
                DeploymentResourceHandler.emitReset(deploymentId!, {
                    project: projectName,
                    includeDbRollback: includeDbRollback
                });
            } catch (eventError: any) {
                console.error(`Failed to emit deployment reset event: ${eventError.message}`);
                // Don't fail the operation if event emission fails
            }
    
            // Start monitoring the reset in the background
            this.monitorResetProgress(deploymentId!, projectId!, apiKey!, apiSecret!, projectName, args.apiUrl);
    
            // Format response
            return DeploymentFormatters.formatDeploymentReset(resetData, includeDbRollback, projectName);
    
        } catch (error: any) {
            // Handle REST API errors
            const errorDetails = {
                operation: 'Reset Deployment',
                projectId,
                projectName: args.projectName,
                deploymentId,
                apiKey
            };
    
            // Check if this is an access denied error
            if (error.statusCode === 401 || error.statusCode === 403) {
                return ErrorHandler.formatError({
                    type: 'ACCESS_DENIED',
                    message: 'Access denied to deployment API',
                    statusCode: error.statusCode
                } as any, errorDetails);
            }
    
            // Generic error handling
            return ErrorHandler.formatError({
                type: 'API_ERROR',
                message: error.message,
                statusCode: error.statusCode
            } as any, errorDetails);
        }
    }
  • TypeScript interface defining the input parameters/schema for the reset_deployment tool.
     * Reset deployment arguments
     */
    interface ResetDeploymentArgs {
        apiKey?: string;
        apiSecret?: string;
        projectId?: string;
        projectName?: string;
        deploymentId?: string;
        isSelfHosted?: boolean;
        connectionString?: string;
        apiUrl?: string;
    }
  • Thin wrapper handler in DeploymentTools that delegates to the main implementation in deployment-actions.ts.
    static async handleResetDeployment(args: any): Promise<any> {
        return DeploymentActionOperations.handleResetDeployment(args);
    }
  • Core REST API client method that performs the actual HTTP POST request to the Optimizely DXP API endpoint for resetting a deployment.
    static async resetDeployment(
        projectId: string,
        clientKey: string,
        clientSecret: string,
        deploymentId: string,
        resetOptions: ResetOptions = {},
        options: RequestOptions = {}
    ): Promise<any> {
        const uriEnding = `projects/${projectId}/deployments/${deploymentId}/reset`;
        return await this.makeRequest(clientKey, clientSecret, uriEnding, 'POST', resetOptions, options);
    }
  • Event emission handler that registers the 'reset_deployment' operation for resource notifications and MCP client updates.
    static emitReset(deploymentId: string, details: DeploymentDetails = {}): DXPEvent {
        const emitter = getGlobalEmitter();
        const event = createEvent(
            EVENT_TYPES.DEPLOYMENT_RESET,
            deploymentId,
            {
                deploymentId,
                status: 'Reset',
                ...details
            },
            {
                operation: 'reset_deployment',
                user: 'system'
            }
        );
    
        emitter.emitEvent(event);
        return event;
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure and does so effectively. It reveals the tool is ASYNC (5-15min), describes what gets reversed ('all changes made by deployment, restoring previous code and optionally database'), mentions the resulting status ('Deployment transitions to "Reset" status'), and provides workflow guidance. No contradictions exist since annotations are absent.

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 appropriately sized and front-loaded with the core purpose. Every sentence adds value: the first states what it does, the second gives timing and scope, the third provides usage context, the fourth explains a key parameter, the fifth describes outcome, and the sixth gives workflow guidance. Minor room for improvement in flow.

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?

For a mutation tool with no annotations and no output schema, the description provides substantial context about behavior, timing, outcomes, and workflow. It covers the essential 'what happens' and 'when to use' aspects well. The main gap is incomplete parameter coverage, but otherwise it's quite comprehensive given the complexity.

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?

With 0% schema description coverage for 5 parameters, the description partially compensates by explaining the purpose of one parameter ('Set resetWithDbRollback=true to also rollback database changes') and mentioning that 'deploymentId' is required. However, it doesn't cover the other 3 parameters (projectName, projectId, apiKey, apiSecret), leaving significant gaps in parameter understanding.

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 with specific verb ('Rollback') and resource ('deployment to previous state'), and distinguishes it from siblings by mentioning its unique rollback functionality. It goes beyond the name 'reset_deployment' by explaining what 'reset' means in this context.

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 explicitly states when to use the tool ('when deployment verification fails or errors detected') and provides a complete agent workflow with a specific alternative tool ('investigate logs with analyze_logs_streaming()'). This gives clear guidance on both usage context and next steps.

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/JaxonDigital/optimizely-dxp-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server