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);
      }
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.1.0

TDQS

B3.2/5.0
Behavior2/5

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

Without annotations, the description carries full burden but only states it's a mutation. It does not disclose side effects (e.g., whether ordering is atomic, overwrites or appends), permissions, or error conditions.

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 concise sentence with no unnecessary words, efficiently conveying the core purpose.

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 that there are no annotations or output schema, the description should provide more context about return values, error handling, or limitations. It only states the basic action, making it insufficient for complete understanding.

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?

Both parameters are well-documented in the schema (100% coverage), and the description adds no additional meaning beyond what the schema provides, earning the baseline score of 3.

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 clearly states the action ('Update') and the target ('display order of fields within a collection'), distinguishing it from sibling tools like 'reorder_collections' or 'update_field'.

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 are there any prerequisites or conditions for use.

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