Skip to main content
Glama

createPage

Create new pages in Adobe Experience Manager by specifying parent path, title, and template for structured content management.

Instructions

Create a new page in AEM

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
parentPathYes
titleYes
templateYes
nameNo
propertiesNo

Implementation Reference

  • Core implementation of createPage tool: validates input, auto-selects template, creates cq:Page and jcr:content nodes via Sling POST, verifies creation and accessibility.
    async createPage(request) {
        return safeExecute(async () => {
            const { parentPath, title, template, name, properties = {} } = request;
            if (!isValidContentPath(parentPath)) {
                throw createAEMError(AEM_ERROR_CODES.INVALID_PARAMETERS, `Invalid parent path: ${String(parentPath)}`, { parentPath });
            }
            // Auto-select template if not provided
            let selectedTemplate = template;
            if (!selectedTemplate) {
                const templatesResponse = await this.getTemplates(parentPath);
                const availableTemplates = templatesResponse.data.availableTemplates;
                if (availableTemplates.length === 0) {
                    throw createAEMError(AEM_ERROR_CODES.INVALID_PARAMETERS, 'No templates available for this path', { parentPath });
                }
                selectedTemplate = availableTemplates[0].path;
                this.logger.info(`Auto-selected template: ${selectedTemplate}`);
            }
            // Validate template exists
            try {
                await this.httpClient.get(`${selectedTemplate}.json`);
            }
            catch (error) {
                if (error.response?.status === 404) {
                    throw createAEMError(AEM_ERROR_CODES.INVALID_PARAMETERS, `Template not found: ${selectedTemplate}`, { template: selectedTemplate });
                }
                throw handleAEMHttpError(error, 'createPage');
            }
            const pageName = name || title.replace(/[^a-zA-Z0-9-_]/g, '-').toLowerCase();
            const newPagePath = `${parentPath}/${pageName}`;
            // Create page with proper structure
            const pageData = {
                'jcr:primaryType': 'cq:Page',
                'jcr:content': {
                    'jcr:primaryType': 'cq:PageContent',
                    'jcr:title': title,
                    'cq:template': selectedTemplate,
                    'sling:resourceType': 'foundation/components/page',
                    'cq:lastModified': new Date().toISOString(),
                    'cq:lastModifiedBy': 'admin',
                    ...properties
                }
            };
            // Create the page using Sling POST servlet
            const formData = new URLSearchParams();
            formData.append('jcr:primaryType', 'cq:Page');
            // Create page first
            await this.httpClient.post(newPagePath, formData, {
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded'
                }
            });
            // Then create jcr:content node
            const contentFormData = new URLSearchParams();
            Object.entries(pageData['jcr:content']).forEach(([key, value]) => {
                if (key === 'jcr:created' || key === 'jcr:createdBy') {
                    return;
                }
                if (typeof value === 'object') {
                    contentFormData.append(key, JSON.stringify(value));
                }
                else {
                    contentFormData.append(key, String(value));
                }
            });
            await this.httpClient.post(`${newPagePath}/jcr:content`, contentFormData, {
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded'
                }
            });
            // Verify page creation
            const verificationResponse = await this.httpClient.get(`${newPagePath}.json`);
            const hasJcrContent = verificationResponse.data['jcr:content'] !== undefined;
            // Check if page is accessible in author mode
            let pageAccessible = false;
            try {
                const authorResponse = await this.httpClient.get(`${newPagePath}.html`, {
                    validateStatus: (status) => status < 500
                });
                pageAccessible = authorResponse.status === 200;
            }
            catch (error) {
                pageAccessible = false;
            }
            return createSuccessResponse({
                pagePath: newPagePath,
                title,
                templateUsed: selectedTemplate,
                jcrContentCreated: hasJcrContent,
                pageAccessible,
                errorLogCheck: {
                    hasErrors: false,
                    errors: []
                },
                creationDetails: {
                    timestamp: new Date().toISOString(),
                    steps: [
                        'Template validation completed',
                        'Page node created',
                        'jcr:content node created',
                        'Page structure verified',
                        'Accessibility check completed'
                    ]
                },
                pageStructure: verificationResponse.data
            }, 'createPage');
        }, 'createPage');
    }
  • MCP handler registration: dispatches createPage calls to AEMConnector.createPage in the handleRequest switch statement.
    case 'createPage':
        return await this.aemConnector.createPage(params);
  • Tool schema definition in getAvailableMethods(): defines name, description, and parameters for the createPage tool.
    { name: 'createPage', description: 'Create a new page in AEM', parameters: ['parentPath', 'title', 'template', 'name', 'properties'] },
  • Wrapper method in AEMConnector that delegates createPage to PageOperations module.
    async createPage(request) {
        return this.pageOps.createPage(request);
  • TypeScript interface definition for createPage method signature and return type.
    createPage(request: any): Promise<import("./interfaces/index.js").PageResponse>;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Create a new page' which implies a write/mutation operation, but doesn't cover critical aspects like required permissions, whether the operation is idempotent, potential side effects (e.g., triggering workflows), or error conditions. For a mutation tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place by conveying essential purpose without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (5 parameters with nested objects, no output schema, and no annotations), the description is insufficiently complete. It doesn't explain what the tool returns, how errors are handled, or the semantics of key parameters like 'properties'. For a creation tool in a content management system, more context about success/failure outcomes and parameter usage is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage for 5 parameters (3 required), the description provides no information about parameters beyond what the schema structure implies. It doesn't explain what 'parentPath', 'template', 'properties', etc., mean in the context of AEM page creation, their formats, or constraints. The description fails to compensate for the lack of schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create') and resource ('new page in AEM'), making the purpose immediately understandable. It distinguishes itself from siblings like 'deletePage' or 'listPages' by specifying creation. However, it doesn't explicitly differentiate from 'createComponent' or 'createVersion', which are also creation tools in the same system.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a parent path or template), exclusions (e.g., when not to create pages), or comparisons to siblings like 'bulkUpdateComponents' or 'uploadAsset' for related operations. Usage is implied but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/indrasishbanerjee/aem-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server