aem_install_package
Install content packages into Adobe Experience Manager to deploy code, configurations, and assets to AEM instances.
Instructions
Install a package in AEM
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| packagePath | Yes | Path to the package file (.zip) | |
| host | No | AEM host (default: localhost) | localhost |
| port | No | AEM port (default: 4502) | |
| username | No | AEM username (default: admin) | admin |
| password | No | AEM password (default: admin) | admin |
| force | No | Force installation (default: false) |
Implementation Reference
- src/aem-tools.ts:35-57 (handler)The primary handler function for the 'aem_install_package' tool. It processes input arguments, validates the package path, delegates to AEMClient for installation, and formats the response.async installPackage(args: any) { const config = this.getConfig(args); const { packagePath, force = false } = args; if (!packagePath) { throw new Error('Package path is required'); } const result = await this.aemClient.installPackage(config, packagePath, force); return { content: [ { type: 'text', text: `Package Installation Result: Success: ${result.success} Message: ${result.message} Package: ${packagePath} Force: ${force}`, }, ], }; }
- src/aem-client.ts:103-156 (helper)Core helper function that handles the actual AEM package installation via HTTP POST to the CRX package manager endpoint, including file upload and authentication.async installPackage(config: AEMConfig, packagePath: string, force: boolean = false): Promise<any> { const baseUrl = this.getBaseUrl(config); const authHeader = this.getAuthHeader(config); const readFile = promisify(fs.readFile); const access = promisify(fs.access); try { // Check if file exists await access(packagePath, fs.constants.F_OK); } catch (error) { throw new Error(`Package file not found: ${packagePath}`); } try { // Read the file as buffer instead of using createReadStream const fileBuffer = await readFile(packagePath); const formData = new FormData(); formData.append('file', fileBuffer, { filename: packagePath.split(/[/\\]/).pop() || 'package.zip', contentType: 'application/zip' }); formData.append('force', force.toString()); formData.append('install', 'true'); const response = await this.axiosInstance.post( `${baseUrl}/crx/packmgr/service.jsp`, formData, { headers: { 'Authorization': authHeader, ...formData.getHeaders(), }, } ); if (response.status === 200) { return { success: true, message: 'Package installed successfully', response: response.data, }; } else { return { success: false, message: `Installation failed: HTTP ${response.status}`, response: response.data, }; } } catch (error) { throw new Error(`Package installation failed: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
- src/index.ts:77-115 (schema)Input schema and metadata definition for the 'aem_install_package' tool, registered in the ListTools response.{ name: 'aem_install_package', description: 'Install a package in AEM', inputSchema: { type: 'object', properties: { packagePath: { type: 'string', description: 'Path to the package file (.zip)' }, host: { type: 'string', description: 'AEM host (default: localhost)', default: 'localhost' }, port: { type: 'number', description: 'AEM port (default: 4502)', default: 4502 }, username: { type: 'string', description: 'AEM username (default: admin)', default: 'admin' }, password: { type: 'string', description: 'AEM password (default: admin)', default: 'admin' }, force: { type: 'boolean', description: 'Force installation (default: false)', default: false } }, required: ['packagePath'] } },
- src/index.ts:355-356 (registration)Switch case in the CallToolRequest handler that routes execution to the tool's handler function.case 'aem_install_package': return await this.aemTools.installPackage(args);