Skip to main content
Glama

createComponent

Add a new component to an Adobe Experience Manager page by specifying the page path, component type, and resource type.

Instructions

Create a new component on a page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pagePathYes
componentTypeYes
resourceTypeYes
propertiesNo
nameNo

Implementation Reference

  • Core handler function that executes the createComponent tool logic: validates inputs, constructs component path, performs HTTP POST to AEM instance to create the unstructured node with specified resourceType and properties.
    async createComponent(request: CreateComponentRequest): Promise<ComponentResponse> {
      return safeExecute<ComponentResponse>(async () => {
        const { pagePath, componentType, resourceType, properties = {}, name } = request;
        
        if (!isValidContentPath(pagePath)) {
          throw createAEMError(
            AEM_ERROR_CODES.INVALID_PARAMETERS, 
            `Invalid page path: ${String(pagePath)}`, 
            { pagePath }
          );
        }
        
        if (!isValidComponentType(componentType)) {
          throw createAEMError(
            AEM_ERROR_CODES.INVALID_PARAMETERS, 
            `Invalid component type: ${componentType}`, 
            { componentType }
          );
        }
    
        const componentName = name || `${componentType}_${Date.now()}`;
        const componentPath = `${pagePath}/jcr:content/${componentName}`;
    
        await this.httpClient.post(componentPath, {
          'jcr:primaryType': 'nt:unstructured',
          'sling:resourceType': resourceType,
          ...properties,
          ':operation': 'import',
          ':contentType': 'json',
          ':replace': 'true',
        });
    
        return createSuccessResponse({
          success: true,
          componentPath,
          componentType,
          resourceType,
          properties,
          timestamp: new Date().toISOString(),
        }, 'createComponent') as ComponentResponse;
      }, 'createComponent');
    }
  • MCP tool registration in the server tools list, defining the name, description, and input schema for the createComponent tool.
    {
      name: 'createComponent',
      description: 'Create a new component on a page',
      inputSchema: {
        type: 'object',
        properties: {
          pagePath: { type: 'string' },
          componentType: { type: 'string' },
          resourceType: { type: 'string' },
          properties: { type: 'object' },
          name: { type: 'string' },
        },
        required: ['pagePath', 'componentType', 'resourceType'],
      },
  • Top-level MCP server handler case that receives tool call, delegates to AEMConnector.createComponent, and formats response.
    case 'createComponent': {
      const result = await aemConnector.createComponent(args);
      return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
  • Delegation handler in AEMConnector that forwards the request to ComponentOperations module.
    async listPages(siteRoot: string, depth?: number, limit?: number) {
      return this.pageOps.listPages(siteRoot, depth, limit);
    }
    
    async getPageContent(pagePath: string) {
      return this.pageOps.getPageContent(pagePath);
    }
    
    async getPageProperties(pagePath: string) {
      return this.pageOps.getPageProperties(pagePath);
    }
    
    async activatePage(request: any) {
      return this.pageOps.activatePage(request);
    }
    
    async deactivatePage(request: any) {
      return this.pageOps.deactivatePage(request);
    }
    
    async getAllTextContent(pagePath: string) {
      return this.pageOps.getAllTextContent(pagePath);
    }
    
    async getPageTextContent(pagePath: string) {
      return this.pageOps.getPageTextContent(pagePath);
    }
    
    async getPageImages(pagePath: string) {
      return this.pageOps.getPageImages(pagePath);
    }
    
    // Component Operations
    async createComponent(request: any) {
  • TypeScript interface defining the input parameters for createComponent (note: approximate lines based on search; actual may vary slightly).
    export interface CreateComponentRequest {
      pagePath: string;
      componentType: string;
      resourceType: string;
      properties?: Record<string, unknown>;
      name?: string;
    }
    
    export interface UpdateComponentRequest {
      componentPath: string;

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