updateComponent
Modify component properties in Adobe Experience Manager to adjust content behavior and appearance for dynamic web experiences.
Instructions
Update component properties in AEM
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| componentPath | Yes | ||
| properties | Yes |
Implementation Reference
- Core implementation of the updateComponent tool. Validates input parameters, verifies component existence, constructs form data from properties handling arrays/objects/nulls, performs HTTP POST to update the component in AEM, fetches updated component for verification, and returns detailed success response.async updateComponent(request) { return safeExecute(async () => { const { componentPath, properties } = request; if (!componentPath || typeof componentPath !== 'string') { throw createAEMError(AEM_ERROR_CODES.INVALID_PARAMETERS, 'Component path is required and must be a string'); } if (!properties || typeof properties !== 'object') { throw createAEMError(AEM_ERROR_CODES.INVALID_PARAMETERS, 'Properties are required and must be an object'); } if (!isValidContentPath(componentPath)) { throw createAEMError(AEM_ERROR_CODES.INVALID_PATH, `Component path '${componentPath}' is not within allowed content roots`, { path: componentPath, allowedRoots: Object.values(this.config.contentPaths) }); } // Verify component exists try { await this.httpClient.get(`${componentPath}.json`); } catch (error) { if (error.response?.status === 404) { throw createAEMError(AEM_ERROR_CODES.COMPONENT_NOT_FOUND, `Component not found at path: ${componentPath}`, { componentPath }); } throw handleAEMHttpError(error, 'updateComponent'); } // Prepare form data for AEM const formData = new URLSearchParams(); Object.entries(properties).forEach(([key, value]) => { if (value === null || value === undefined) { formData.append(`${key}@Delete`, ''); } else if (Array.isArray(value)) { value.forEach((item) => { formData.append(`${key}`, item.toString()); }); } else if (typeof value === 'object') { formData.append(key, JSON.stringify(value)); } else { formData.append(key, value.toString()); } }); // Update the component const response = await this.httpClient.post(componentPath, formData, { headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json', }, timeout: this.config.queries.timeoutMs, }); // Verify the update const verificationResponse = await this.httpClient.get(`${componentPath}.json`); return createSuccessResponse({ message: 'Component updated successfully', path: componentPath, properties, updatedProperties: verificationResponse.data, response: response.data, verification: { success: true, propertiesChanged: Object.keys(properties).length, timestamp: new Date().toISOString(), }, }, 'updateComponent'); }, 'updateComponent');
- dist/mcp-handler.js:11-12 (registration)Tool dispatch registration in MCPRequestHandler.handleRequest switch statement. Routes 'updateComponent' calls to the AEMConnector instance.case 'updateComponent': return await this.aemConnector.updateComponent(params);
- dist/mcp-handler.js:116-116 (schema)Tool metadata and schema definition in getAvailableMethods(), specifying name, description, and expected input parameters (componentPath, properties).{ name: 'updateComponent', description: 'Update component properties in AEM', parameters: ['componentPath', 'properties'] },
- dist/aem-connector-new.js:104-105 (helper)Proxy/delegation method in AEMConnector class that forwards updateComponent requests to the specialized ComponentOperations module.async updateComponent(request) { return this.componentOps.updateComponent(request);
- dist/aem-connector-new.js:35-35 (helper)Initialization of ComponentOperations instance in AEMConnector constructor, providing httpClient, logger, and AEM config for the updateComponent handler.this.componentOps = new ComponentOperations(this.httpClient, this.logger, config.aem);