aem_create_page
Create a new page in Adobe Experience Manager by specifying parent path, page name, title, and template using the AEM MCP Server tool.
Instructions
Create a new page in AEM
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | No | AEM host (default: localhost) | localhost |
| pageName | Yes | Name of the new page | |
| pageTitle | Yes | Title of the new page | |
| parentPath | Yes | Parent path where to create the page | |
| password | No | AEM password (default: admin) | admin |
| port | No | AEM port (default: 4502) | |
| template | Yes | Template path for the page | |
| username | No | AEM username (default: admin) | admin |
Implementation Reference
- src/aem-tools.ts:86-111 (handler)Main handler function for aem_create_page tool. Extracts parameters, validates inputs, calls AEMClient.createPage, and formats the MCP response.async createPage(args: any) { const config = this.getConfig(args); const { parentPath, pageName, pageTitle, template } = args; if (!parentPath || !pageName || !pageTitle || !template) { throw new Error('parentPath, pageName, pageTitle, and template are required'); } const result = await this.aemClient.createPage(config, parentPath, pageName, pageTitle, template); return { content: [ { type: 'text', text: `Page Creation Result: Success: ${result.success} Message: ${result.message} ${result.path ? `Path: ${result.path}` : ''} Parent: ${parentPath} Name: ${pageName} Title: ${pageTitle} Template: ${template}`, }, ], }; }
- src/index.ts:145-190 (schema)Tool schema definition including input schema, returned in ListTools request.{ name: 'aem_create_page', description: 'Create a new page in AEM', inputSchema: { type: 'object', properties: { parentPath: { type: 'string', description: 'Parent path where to create the page' }, pageName: { type: 'string', description: 'Name of the new page' }, pageTitle: { type: 'string', description: 'Title of the new page' }, template: { type: 'string', description: 'Template path for the page' }, 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: ['parentPath', 'pageName', 'pageTitle', 'template'] } },
- src/index.ts:359-360 (registration)Registration of the tool handler in the CallToolRequest switch statement.case 'aem_create_page': return await this.aemTools.createPage(args);
- src/aem-client.ts:185-224 (helper)Helper function in AEMClient that performs the actual HTTP POST request to AEM's /bin/wcmcommand endpoint to create the page.async createPage(config: AEMConfig, parentPath: string, pageName: string, pageTitle: string, template: string): Promise<any> { const baseUrl = this.getBaseUrl(config); const authHeader = this.getAuthHeader(config); const formData = new FormData(); formData.append('cmd', 'createPage'); formData.append('parentPath', parentPath); formData.append('title', pageTitle); formData.append('label', pageName); formData.append('template', template); try { const response = await this.axiosInstance.post( `${baseUrl}/bin/wcmcommand`, formData, { headers: { 'Authorization': authHeader, ...formData.getHeaders(), }, } ); if (response.status === 200 || response.status === 201) { return { success: true, message: `Page created successfully at ${parentPath}/${pageName}`, path: `${parentPath}/${pageName}`, }; } else { return { success: false, message: `Page creation failed: HTTP ${response.status}`, response: response.data, }; } } catch (error) { throw new Error(`Page creation failed: ${error instanceof Error ? error.message : 'Unknown error'}`); } }