Skip to main content
Glama
devlimelabs

Meilisearch MCP Server

by devlimelabs

swap-indexes

Swap two or more indexes in Meilisearch to reorganize search data without downtime or data loss.

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 that implements the core logic of the 'swap-indexes' tool: parses the JSON string input, validates it as an array of index pairs, calls the API, and returns the 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);
      }
    }
  • Type definition for the input parameters of the swap-indexes tool.
    interface SwapIndexesParams {
      indexes: string;
    }
  • Registration of the 'swap-indexes' MCP tool using server.tool(), defining name, description, input schema with Zod, and inline 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);
        }
      }
    );
  • src/index.ts:64-64 (registration)
    Top-level registration call to registerIndexTools on the main MCP server instance, which includes the swap-indexes tool.
    registerIndexTools(server);
  • Zod schema object for validating the input parameters of the swap-indexes tool.
    {
      indexes: z.string().describe('JSON array of index pairs to swap, e.g. [["movies", "movies_new"]]'),
    },
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.

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/devlimelabs/meilisearch-ts-mcp'

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