aem_replicate_content
Activate or deactivate content replication to AEM publish instances by specifying the content path, action, and host details using the MCP server.
Instructions
Replicate content to publish instance
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | No | Replication action (activate/deactivate) | activate |
| host | No | AEM host (default: localhost) | localhost |
| password | No | AEM password (default: admin) | admin |
| path | Yes | Content path to replicate | |
| port | No | AEM port (default: 4502) | |
| username | No | AEM username (default: admin) | admin |
Implementation Reference
- src/aem-tools.ts:113-135 (handler)The main handler function for the 'aem_replicate_content' tool. It extracts arguments, validates input, calls the AEMClient to perform replication, and returns formatted response content.async replicateContent(args: any) { const config = this.getConfig(args); const { path, action = 'activate' } = args; if (!path) { throw new Error('Content path is required'); } const result = await this.aemClient.replicateContent(config, path, action); return { content: [ { type: 'text', text: `Content Replication Result: Success: ${result.success} Message: ${result.message} Path: ${path} Action: ${action}`, }, ], }; }
- src/aem-client.ts:226-262 (helper)Supporting utility in AEMClient that performs the actual HTTP POST request to AEM's /bin/replicate.json endpoint to activate or deactivate content.async replicateContent(config: AEMConfig, contentPath: string, action: string = 'activate'): Promise<any> { const baseUrl = this.getBaseUrl(config); const authHeader = this.getAuthHeader(config); const formData = new FormData(); formData.append('cmd', action); formData.append('path', contentPath); try { const response = await this.axiosInstance.post( `${baseUrl}/bin/replicate.json`, formData, { headers: { 'Authorization': authHeader, ...formData.getHeaders(), }, } ); if (response.status === 200) { return { success: true, message: `Content ${action}d successfully: ${contentPath}`, response: response.data, }; } else { return { success: false, message: `Replication failed: HTTP ${response.status}`, response: response.data, }; } } catch (error) { throw new Error(`Replication failed: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
- src/index.ts:191-230 (schema)The tool schema definition including inputSchema with properties, defaults, and required fields for the 'aem_replicate_content' tool.{ name: 'aem_replicate_content', description: 'Replicate content to publish instance', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Content path to replicate' }, action: { type: 'string', description: 'Replication action (activate/deactivate)', enum: ['activate', 'deactivate'], default: 'activate' }, 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' } }, required: ['path'] } },
- src/index.ts:361-362 (registration)Registration in the CallToolRequest handler switch statement, dispatching to the aemTools.replicateContent method.case 'aem_replicate_content': return await this.aemTools.replicateContent(args);