Skip to main content
Glama
elmapicms

elmapicms-mcp-server

Official
by elmapicms

Create Field

create_field

Add a new field to a content collection by specifying slug, type, label, and name. Optionally include validations, options, and nested placement.

Instructions

Add a new field to a collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_slugYesThe slug of the collection to add the field to
typeYesField type: text, number, richtext, boolean, date, media, relation, select, longtext, group, etc.
labelYesDisplay label (max 60 chars)
nameYesField identifier in kebab-case (max 60 chars)
descriptionNoField description
placeholderNoPlaceholder text
optionsNoField-specific options (e.g. { repeatable: true } for group fields)
validationsNoValidation rules (e.g. { required: { status: true, message: 'Required' } })
parent_field_idNoInternal ID of a group field to nest this field under

Implementation Reference

  • Registration of the 'create_field' tool on the MCP server with input schema definition and handler function
    // ── create_field ──────────────────────────────────────────────────
    server.registerTool("create_field", {
      title: "Create Field",
      description: "Add a new field to a collection",
      inputSchema: {
        collection_slug: z
          .string()
          .describe("The slug of the collection to add the field to"),
        type: z
          .string()
          .describe(
            "Field type: text, number, richtext, boolean, date, media, relation, select, longtext, group, etc."
          ),
        label: z.string().describe("Display label (max 60 chars)"),
        name: z
          .string()
          .describe("Field identifier in kebab-case (max 60 chars)"),
        description: z.string().optional().describe("Field description"),
        placeholder: z.string().optional().describe("Placeholder text"),
        options: z
          .record(z.string(), z.unknown())
          .optional()
          .describe(
            "Field-specific options (e.g. { repeatable: true } for group fields)"
          ),
        validations: z
          .record(z.string(), z.unknown())
          .optional()
          .describe(
            "Validation rules (e.g. { required: { status: true, message: 'Required' } })"
          ),
        parent_field_id: z
          .number()
          .optional()
          .describe(
            "Internal ID of a group field to nest this field under"
          ),
      },
    }, async ({ collection_slug, ...fieldData }) => {
      const result = await client.post(
        `/collections/${collection_slug}/fields`,
        fieldData
      );
      return {
        content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
      };
    });
  • Input schema for 'create_field' using Zod: collection_slug, type, label, name, description, placeholder, options, validations, parent_field_id
    inputSchema: {
      collection_slug: z
        .string()
        .describe("The slug of the collection to add the field to"),
      type: z
        .string()
        .describe(
          "Field type: text, number, richtext, boolean, date, media, relation, select, longtext, group, etc."
        ),
      label: z.string().describe("Display label (max 60 chars)"),
      name: z
        .string()
        .describe("Field identifier in kebab-case (max 60 chars)"),
      description: z.string().optional().describe("Field description"),
      placeholder: z.string().optional().describe("Placeholder text"),
      options: z
        .record(z.string(), z.unknown())
        .optional()
        .describe(
          "Field-specific options (e.g. { repeatable: true } for group fields)"
        ),
      validations: z
        .record(z.string(), z.unknown())
        .optional()
        .describe(
          "Validation rules (e.g. { required: { status: true, message: 'Required' } })"
        ),
      parent_field_id: z
        .number()
        .optional()
        .describe(
          "Internal ID of a group field to nest this field under"
        ),
    },
  • Handler function that extracts collection_slug from params and POSTs the rest to /collections/{slug}/fields via the ElmapiClient
    }, async ({ collection_slug, ...fieldData }) => {
      const result = await client.post(
        `/collections/${collection_slug}/fields`,
        fieldData
      );
      return {
        content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
      };
    });
  • ElmapiClient.post() helper - the HTTP POST method used by the create_field handler to call the API
    async post(path: string, body?: unknown): Promise<unknown> {
      const response = await fetch(`${this.baseUrl}${path}`, {
        method: "POST",
        headers: this.headers(),
        body: body ? JSON.stringify(body) : undefined,
      });
    
      return this.handleResponse(response);
    }
  • src/index.ts:37-37 (registration)
    Top-level registration: registerFieldTools(server, client) is called to register all field tools including create_field
    registerFieldTools(server, client);
Behavior2/5

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

With no annotations provided, the description must fully convey behavioral traits. It merely states the action without any information about side effects, reversibility, permissions, or output behavior. This is insufficient.

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

Conciseness4/5

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

The description is a single, efficient sentence that gets to the point. It is appropriately brief, though could benefit from a little more detail without becoming verbose.

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?

Despite moderate complexity (9 parameters, nested objects) and no output schema, the description is minimal. It fails to explain important aspects like validation, success responses, or consequences of creation, making it incomplete for an agent.

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

Parameters3/5

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

The input schema has 100% description coverage for its 9 parameters, so the baseline is 3. The description does not add any additional meaning beyond what the schema already provides.

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

Purpose5/5

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

The description uses a specific verb 'Add' and a clear resource 'new field to a collection', which distinctively indicates the tool's function. It is unambiguous and distinguishes from sibling tools like update_field and reorder_fields.

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 such as update_field or reorder_fields. There is no mention of prerequisites, limitations, or context for appropriate use.

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/elmapicms/elmapicms-mcp-server'

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