deleteComponent
Remove a component from Adobe Experience Manager by specifying its path and optional force flag using the MCP Server's API.
Instructions
Delete a component from AEM
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| componentPath | Yes | ||
| force | No |
Implementation Reference
- Core handler implementation for deleting a component via HTTP DELETE or Sling POST delete operation, with path validation and error handling.async deleteComponent(request: DeleteComponentRequest): Promise<DeleteResponse> { return safeExecute<DeleteResponse>(async () => { const { componentPath, force = false } = request; if (!isValidContentPath(componentPath)) { throw createAEMError( AEM_ERROR_CODES.INVALID_PARAMETERS, `Invalid component path: ${String(componentPath)}`, { componentPath } ); } let deleted = false; try { await this.httpClient.delete(componentPath); deleted = true; } catch (err: any) { if (err.response && err.response.status === 405) { try { await this.httpClient.post(componentPath, { ':operation': 'delete' }); deleted = true; } catch (slingErr: any) { this.logger.error('Sling POST delete failed', { error: slingErr.response?.status, data: slingErr.response?.data }); throw slingErr; } } else { this.logger.error('DELETE failed', { status: err.response?.status, data: err.response?.data }); throw err; } } return createSuccessResponse({ success: deleted, deletedPath: componentPath, timestamp: new Date().toISOString(), }, 'deleteComponent') as DeleteResponse; }, 'deleteComponent'); }
- src/interfaces/index.ts:259-262 (schema)TypeScript interface defining the input parameters for the deleteComponent tool.export interface DeleteComponentRequest { componentPath: string; force?: boolean; }
- src/mcp-server.ts:717-720 (registration)MCP server tool dispatch/registration: handles CallToolRequest for 'deleteComponent' by calling aemConnector.deleteComponent.case 'deleteComponent': { const result = await aemConnector.deleteComponent(args); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
- src/mcp-server.ts:309-320 (schema)JSON schema definition for the deleteComponent tool input, used in ListTools response.{ name: 'deleteComponent', description: 'Delete a component from AEM', inputSchema: { type: 'object', properties: { componentPath: { type: 'string' }, force: { type: 'boolean' }, }, required: ['componentPath'], }, },
- src/aem-connector-new.ts:128-130 (handler)Delegation from AEMConnector to ComponentOperations for deleteComponent execution.async deleteComponent(request: any) { return this.componentOps.deleteComponent(request); }