Skip to main content
Glama
elmapicms

elmapicms-mcp-server

Official
by elmapicms

Reorder Fields

reorder_fields

Rearrange fields in a collection by assigning new display order positions to each field UUID.

Instructions

Update the display order of fields within a collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_slugYesThe collection slug
fieldsYesArray of { uuid, order } objects

Implementation Reference

  • Registration of the 'reorder_fields' tool via server.registerTool, including its title, description, and Zod-based input schema.
    // ── reorder_fields ────────────────────────────────────────────────
    server.registerTool("reorder_fields", {
      title: "Reorder Fields",
      description: "Update the display order of fields within a collection",
      inputSchema: {
        collection_slug: z.string().describe("The collection slug"),
        fields: z
          .array(
            z.object({
              uuid: z.string().describe("Field UUID"),
              order: z.number().describe("New display order (0-based)"),
            })
          )
          .describe("Array of { uuid, order } objects"),
      },
    }, async ({ collection_slug, fields }) => {
      const result = await client.post(
        `/collections/${collection_slug}/fields/reorder`,
        { fields }
      );
      return {
        content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
      };
    });
  • Input schema for reorder_fields: requires 'collection_slug' (string) and 'fields' (array of { uuid: string, order: number } objects).
    inputSchema: {
      collection_slug: z.string().describe("The collection slug"),
      fields: z
        .array(
          z.object({
            uuid: z.string().describe("Field UUID"),
            order: z.number().describe("New display order (0-based)"),
          })
        )
        .describe("Array of { uuid, order } objects"),
    },
  • Handler that sends a POST request to /collections/{collection_slug}/fields/reorder with the provided fields array, returning the API response.
    }, async ({ collection_slug, fields }) => {
      const result = await client.post(
        `/collections/${collection_slug}/fields/reorder`,
        { fields }
      );
      return {
        content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
      };
    });
  • The ElmapiClient.post() method used by the handler to make the HTTP POST request to the ElmapiCMS 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);
      }
    
      async put(path: string, body?: unknown): Promise<unknown> {
        const response = await fetch(`${this.baseUrl}${path}`, {
          method: "PUT",
          headers: this.headers(),
          body: body ? JSON.stringify(body) : undefined,
        });
    
        return this.handleResponse(response);
      }
    
      async delete(path: string, body?: unknown): Promise<unknown> {
        const response = await fetch(`${this.baseUrl}${path}`, {
          method: "DELETE",
          headers: this.headers(),
          body: body ? JSON.stringify(body) : undefined,
        });
    
        return this.handleResponse(response);
      }
    
      /**
       * Upload a file via multipart/form-data.
       * Accepts a Buffer, the original filename, and its MIME type.
       */
      async uploadFile(
        path: string,
        fileBuffer: Buffer,
        filename: string,
        mimeType: string
      ): Promise<unknown> {
        const blob = new Blob([new Uint8Array(fileBuffer)], { type: mimeType });
        const formData = new FormData();
        formData.append("file", blob, filename);
    
        const headers: Record<string, string> = {
          Accept: "application/json",
          Authorization: `Bearer ${this.token}`,
          "project-id": this.projectId,
          // Do NOT set Content-Type — fetch sets it with the boundary automatically
        };
    
        const response = await fetch(`${this.baseUrl}${path}`, {
          method: "POST",
          headers,
          body: formData,
        });
    
        return this.handleResponse(response);
      }
    }
Behavior2/5

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

With no annotations, the description must disclose behavior. It indicates a mutation (update) but fails to specify whether the order is fully replaced or merged, constraints on order values, or the effect on existing fields. This leaves significant gaps in behavioral understanding.

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

Conciseness3/5

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

The description is a single sentence, which is concise but omits critical information. It prioritizes brevity over completeness, making it less helpful than it could be.

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 tool's complexity (nested array parameter, no output schema, no annotations), the description is insufficient. It does not mention the effect on existing field ordering, idempotency, or error cases, leaving the agent underinformed.

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?

Schema coverage is 100%, so the schema fully documents both parameters. The description adds no extra meaning beyond the schema, such as the fact that 'fields' is an array of objects with uuid and order. Hence a baseline score of 3 is appropriate.

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 verb 'Update' and resource 'display order of fields within a collection', making the purpose clear. However, it does not explicitly distinguish from the sibling tool 'reorder_collections', though the resource difference is implied.

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?

No guidance is provided on when to use this tool versus alternatives, nor any prerequisites (e.g., collection must exist) or conditions for reordering. The description lacks usage context entirely.

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