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;
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. While 'Create' implies a write operation, it doesn't specify permissions required, whether the creation is reversible (e.g., via 'deleteComponent'), potential side effects, or response format. This leaves significant gaps for a mutation tool with zero annotation coverage.

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, efficient sentence that front-loads the core action and resource without unnecessary words. Every part of the sentence contributes directly to understanding the tool's purpose, making it highly concise and well-structured.

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?

For a mutation tool with 5 parameters (0% schema coverage), no annotations, no output schema, and nested objects, the description is incomplete. It lacks details on parameter usage, behavioral traits, and output expectations, making it inadequate for safe and effective tool invocation in this complex context.

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, the description doesn't add any meaning beyond the schema. It mentions 'on a page', which loosely relates to 'pagePath', but provides no details on what 'componentType', 'resourceType', 'properties', or 'name' represent, failing 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 ('a new component on a page'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'createPage' or 'updateComponent', which would require specifying what makes component creation distinct from page creation or component updates.

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. With siblings like 'createPage' (for creating pages) and 'updateComponent' (for modifying existing components), there's no indication of prerequisites, such as needing an existing page, or when to choose this over other creation or update tools.

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