Skip to main content
Glama
OrionPotter

Meilisearch MCP Server

by OrionPotter

swap-indexes

Swap two or more indexes in Meilisearch to reorganize search data without downtime, enabling index updates and schema changes.

Instructions

Swap two or more indexes in Meilisearch

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexesYesJSON array of index pairs to swap, e.g. [["movies", "movies_new"]]

Implementation Reference

  • The handler function for the 'swap-indexes' MCP tool. Parses JSON input of index pairs, validates structure, calls API to swap indexes, and returns formatted response or error.
    async ({ indexes }: SwapIndexesParams) => {
      try {
        // Parse the indexes string to ensure it's valid JSON
        const parsedIndexes = JSON.parse(indexes);
        
        // Ensure indexes is an array of arrays
        if (!Array.isArray(parsedIndexes) || !parsedIndexes.every(pair => Array.isArray(pair) && pair.length === 2)) {
          return {
            isError: true,
            content: [{ type: 'text', text: 'Indexes must be a JSON array of pairs, e.g. [["movies", "movies_new"]]' }],
          };
        }
        
        const response = await apiClient.post('/swap-indexes', parsedIndexes);
        return {
          content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }],
        };
      } catch (error) {
        return createErrorResponse(error);
      }
    }
  • Zod input schema defining the 'indexes' parameter as a string containing JSON array of index pairs.
    {
      indexes: z.string().describe('JSON array of index pairs to swap, e.g. [["movies", "movies_new"]]'),
    },
  • Registration of the 'swap-indexes' tool with the MCP server using server.tool(), including description, schema, and handler.
    server.tool(
      'swap-indexes',
      'Swap two or more indexes in Meilisearch',
      {
        indexes: z.string().describe('JSON array of index pairs to swap, e.g. [["movies", "movies_new"]]'),
      },
      async ({ indexes }: SwapIndexesParams) => {
        try {
          // Parse the indexes string to ensure it's valid JSON
          const parsedIndexes = JSON.parse(indexes);
          
          // Ensure indexes is an array of arrays
          if (!Array.isArray(parsedIndexes) || !parsedIndexes.every(pair => Array.isArray(pair) && pair.length === 2)) {
            return {
              isError: true,
              content: [{ type: 'text', text: 'Indexes must be a JSON array of pairs, e.g. [["movies", "movies_new"]]' }],
            };
          }
          
          const response = await apiClient.post('/swap-indexes', parsedIndexes);
          return {
            content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }],
          };
        } catch (error) {
          return createErrorResponse(error);
        }
      }
    );
  • TypeScript interface defining the parameters for the swap-indexes handler.
    interface SwapIndexesParams {
      indexes: string;
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the action ('swap') but doesn't disclose behavioral traits like whether this is a destructive operation, if it requires specific permissions, what happens during the swap process, or potential side effects. The description is minimal and lacks critical operational context.

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 directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, with zero wasted content.

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 complexity of swapping indexes (a potentially destructive operation) and the lack of annotations and output schema, the description is insufficient. It doesn't explain what 'swap' entails operationally, what the tool returns, or any error conditions, leaving significant gaps for an AI 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?

Schema description coverage is 100%, with the schema fully documenting the single parameter 'indexes' as a JSON array of index pairs. The description doesn't add any meaning beyond what the schema provides, so it meets the baseline of 3 when schema coverage is high.

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 ('swap') and the resource ('two or more indexes in Meilisearch'), providing a specific verb+resource combination. It doesn't explicitly differentiate from siblings like 'update-index' or 'create-index', but the core purpose is unambiguous.

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. The description doesn't mention prerequisites, timing considerations, or how it differs from other index-related operations like 'update-index' or 'delete-index'.

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