aem_install_package
Deploy Adobe Experience Manager (AEM) packages by specifying the package file path, host, port, and credentials. Supports optional forced installation for streamlined AEM management.
Instructions
Install a package in AEM
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| force | No | Force installation (default: false) | |
| host | No | AEM host (default: localhost) | localhost |
| packagePath | Yes | Path to the package file (.zip) | |
| password | No | AEM password (default: admin) | admin |
| port | No | AEM port (default: 4502) | |
| username | No | AEM username (default: admin) | admin |
Implementation Reference
- src/index.ts:77-115 (registration)Registers the 'aem_install_package' tool including its name, description, and input schema 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/aem-tools.ts:35-57 (handler)Main handler for aem_install_package tool: validates input, calls AEMClient.installPackage, formats and returns the response as MCP content.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/index.ts:355-356 (registration)Registers the handler dispatch for 'aem_install_package' in the CallToolRequestSchema switch statement.case 'aem_install_package': return await this.aemTools.installPackage(args);
- src/aem-client.ts:103-156 (helper)Core helper function that performs the actual AEM package installation by sending a multipart POST request to /crx/packmgr/service.jsp with authentication and file upload.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/aem-tools.ts:6-13 (helper)Helper utility to extract and default AEM configuration from tool arguments.private getConfig(args: any): AEMConfig { return { host: args.host || 'localhost', port: args.port || 4506, username: args.username || 'admin', password: args.password || 'admin', }; }