updateAsset
Modify existing assets in Adobe Experience Manager's Digital Asset Management system by updating metadata, file content, or MIME types to maintain accurate and current digital resources.
Instructions
Update an existing asset in AEM DAM
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assetPath | Yes | ||
| metadata | No | ||
| fileContent | No | ||
| mimeType | No |
Implementation Reference
- Core implementation of updateAsset: performs HTTP POST to update asset metadata and/or file content in AEM DAM, with path validation, form data preparation, verification, and comprehensive error handling.async updateAsset(request: UpdateAssetRequest): Promise<AssetResponse> { return safeExecute<AssetResponse>(async () => { const { assetPath, metadata, fileContent, mimeType } = request; if (!isValidContentPath(assetPath)) { throw createAEMError( AEM_ERROR_CODES.INVALID_PARAMETERS, `Invalid asset path: ${String(assetPath)}`, { assetPath } ); } const formData = new URLSearchParams(); // Update file content if provided if (fileContent) { formData.append('file', fileContent); if (mimeType) { formData.append('jcr:content/jcr:mimeType', mimeType); } } // Update metadata if provided if (metadata && typeof metadata === 'object') { Object.entries(metadata).forEach(([key, value]) => { formData.append(`jcr:content/metadata/${key}`, String(value)); }); } try { const response = await this.httpClient.post(assetPath, formData, { headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, }); // Verify the update const verificationResponse = await this.httpClient.get(`${assetPath}.json`); return createSuccessResponse({ success: true, assetPath, fileName: assetPath.split('/').pop() || 'unknown', updatedMetadata: metadata, updateResponse: response.data, assetData: verificationResponse.data, timestamp: new Date().toISOString(), }, 'updateAsset') as AssetResponse; } catch (error: any) { throw handleAEMHttpError(error, 'updateAsset'); } }, 'updateAsset'); }
- src/mcp-server.ts:373-385 (schema)MCP tool schema definition specifying input parameters for updateAsset: assetPath (required), metadata, fileContent, mimeType.name: 'updateAsset', description: 'Update an existing asset in AEM DAM', inputSchema: { type: 'object', properties: { assetPath: { type: 'string' }, metadata: { type: 'object' }, fileContent: { type: 'string' }, mimeType: { type: 'string' }, }, required: ['assetPath'], }, },
- src/mcp-server.ts:737-740 (registration)MCP server tool dispatch/registration: handles 'updateAsset' tool calls by invoking aemConnector.updateAsset and formatting response.case 'updateAsset': { const result = await aemConnector.updateAsset(args); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
- src/aem-connector-new.ts:153-154 (helper)Delegation helper in AEMConnector: forwards updateAsset calls to the AssetOperations module.async updateAsset(request: any) { return this.assetOps.updateAsset(request);
- src/mcp-handler.ts:151-152 (schema)Alternative schema listing in MCP handler's available methods.{ name: 'updateAsset', description: 'Update an existing asset in AEM DAM', parameters: ['assetPath', 'metadata', 'fileContent', 'mimeType'] }, { name: 'deleteAsset', description: 'Delete an asset from AEM DAM', parameters: ['assetPath', 'force'] },