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;
    }
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 is a 'swap' but doesn't disclose critical behavioral traits: whether this is destructive (e.g., overwrites data), requires specific permissions, has side effects on associated data, or how it handles errors. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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, direct sentence with zero wasted words. It's front-loaded with the core action and target, making it highly efficient and easy to parse at a glance.

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 a mutation tool (swapping indexes likely involves data movement and potential downtime), no annotations, and no output schema, the description is incomplete. It lacks details on behavior, side effects, error handling, or return values, which are crucial for safe and effective use by 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 'indexes' parameter fully documented in the schema as a JSON array of index pairs. The description adds no additional meaning beyond what the schema provides, such as explaining the swap mechanism or constraints on index names. Baseline 3 is appropriate when the schema does the heavy lifting.

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 target ('indexes in Meilisearch'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'update-index' or 'create-index' that also manipulate indexes, leaving room for confusion about when to choose this specific operation.

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. With many sibling tools for index management (create-index, delete-index, update-index, list-indexes), the description offers no context about appropriate scenarios, prerequisites, or comparisons, leaving the agent to guess based on the name alone.

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/OrionPotter/iflow-mcp_meilisearch-ts-mcp'

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