unpublishContent
Remove content from the publish environment in Adobe Experience Manager. Specify content paths to unpublish individual items or entire trees.
Instructions
Unpublish content from the publish environment
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contentPaths | Yes | ||
| unpublishTree | No |
Implementation Reference
- Core handler function that performs the unpublishing by sending POST requests to AEM's /bin/replicate.json with cmd=Deactivate for each content path, handling multiple paths and tree option.async unpublishContent(request: UnpublishContentRequest): Promise<UnpublishResponse> { return safeExecute<UnpublishResponse>(async () => { const { contentPaths, unpublishTree = false } = request; if (!contentPaths || (Array.isArray(contentPaths) && contentPaths.length === 0)) { throw createAEMError( AEM_ERROR_CODES.INVALID_PARAMETERS, 'Content paths array is required and cannot be empty', { contentPaths } ); } const results: Array<{ path: string; success: boolean; response?: unknown; error?: unknown; }> = []; // Process each path individually using the correct AEM replication API for (const path of Array.isArray(contentPaths) ? contentPaths : [contentPaths]) { try { // Use the correct AEM replication servlet endpoint const formData = new URLSearchParams(); formData.append('cmd', 'Deactivate'); formData.append('path', path); formData.append('ignoredeactivated', 'false'); formData.append('onlymodified', 'false'); if (unpublishTree) { formData.append('deep', 'true'); } const response = await this.httpClient.post('/bin/replicate.json', formData, { headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, }); results.push({ path, success: true, response: response.data }); } catch (error: any) { results.push({ path, success: false, error: error.response?.data || error.message }); } } return createSuccessResponse({ success: results.every(r => r.success), results, unpublishedPaths: contentPaths, unpublishTree, timestamp: new Date().toISOString(), }, 'unpublishContent') as UnpublishResponse; }, 'unpublishContent'); }
- src/mcp-server.ts:721-723 (handler)MCP server top-level handler that receives tool calls for unpublishContent and delegates to AEMConnector.case 'unpublishContent': { const result = await aemConnector.unpublishContent(args); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
- src/mcp-server.ts:321-332 (schema)JSON schema defining the input parameters for the unpublishContent tool (contentPaths array required, unpublishTree optional boolean).{ name: 'unpublishContent', description: 'Unpublish content from the publish environment', inputSchema: { type: 'object', properties: { contentPaths: { type: 'array', items: { type: 'string' } }, unpublishTree: { type: 'boolean' }, }, required: ['contentPaths'], }, },
- src/mcp-server.ts:578-580 (registration)Registration of the listTools handler that returns the tools array including unpublishContent.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
- src/aem-connector-new.ts:192-193 (handler)Delegation from AEMConnector to ReplicationOperations.unpublishContent.async unpublishContent(request: any) { return this.replicationOps.unpublishContent(request);