Skip to main content
Glama

reset_deployment

Revert or reset a deployment to its previous state using a deployment ID. Supports rollback for Optimizely DXP environments, ensuring stability and control over deployment processes.

Instructions

Reset/rollback a deployment

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiKeyNo
apiSecretNo
deploymentIdYes
projectIdNo
projectNameNo

Implementation Reference

  • Primary handler for the reset_deployment MCP tool. Validates input parameters, checks for self-hosted restrictions, calls core resetDeployment logic, and formats the response.
    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 for the reset_deployment tool.
    interface ResetDeploymentArgs { apiKey?: string; apiSecret?: string; projectId?: string; projectName?: string; deploymentId?: string; isSelfHosted?: boolean; connectionString?: string; apiUrl?: string; }
  • Low-level REST API client method that makes the actual HTTP POST request to the Optimizely DXP API to reset the 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); }
  • Deployment tools aggregator that provides the top-level handleResetDeployment entry point, delegating to the implementation in deployment-actions.ts.
    static async handleResetDeployment(args: any): Promise<any> { return DeploymentActionOperations.handleResetDeployment(args); }
  • Tool availability registration defining hosting restrictions and metadata for the reset_deployment tool.
    'reset_deployment': { hostingTypes: ['dxp-paas'], category: 'Deployments', description: 'Reset a stuck deployment', restrictedMessage: 'Resetting deployments is only available for DXP PaaS hosting.'

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