Skip to main content
Glama
OrionPotter

Meilisearch MCP Server

by OrionPotter

swap-indexes

Exchange the positions of two or more indexes in Meilisearch to reorganize data without downtime or data loss.

Instructions

Swap two or more indexes in Meilisearch

Input Schema

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

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "indexes": { "description": "JSON array of index pairs to swap, e.g. [[\"movies\", \"movies_new\"]]", "type": "string" } }, "required": [ "indexes" ], "type": "object" }

Implementation Reference

  • Executes the swap-indexes tool: parses JSON input of index pairs, validates structure, posts to '/swap-indexes' API endpoint, 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 for the swap-indexes tool defining the 'indexes' parameter as a string containing JSON array of pairs.
    { indexes: z.string().describe('JSON array of index pairs to swap, e.g. [["movies", "movies_new"]]'), },
  • Full registration of the 'swap-indexes' MCP tool with server.tool(), including description, schema, and handler function.
    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 for swap-indexes parameters used in the handler signature.
    interface SwapIndexesParams { indexes: string; }

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