Skip to main content
Glama
OrionPotter

Meilisearch MCP Server

by OrionPotter

update-index

Modify a Meilisearch index by changing its primary key to organize data more effectively for search operations.

Instructions

Update a Meilisearch index (currently only supports updating the primary key)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexUidYesUnique identifier of the index
primaryKeyYesNew primary key for the index

Implementation Reference

  • The core handler function for the 'update-index' tool. It performs a PATCH request to the Meilisearch API to update the primary key of the specified index and returns the JSON response or an error message.
    async ({ indexUid, primaryKey }: UpdateIndexParams) => {
      try {
        const response = await apiClient.patch(`/indexes/${indexUid}`, {
          primaryKey,
        });
        return {
          content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }],
        };
      } catch (error) {
        return createErrorResponse(error);
      }
    }
  • Zod input schema for the 'update-index' tool, defining the required parameters: indexUid and primaryKey.
    {
      indexUid: z.string().describe('Unique identifier of the index'),
      primaryKey: z.string().describe('New primary key for the index'),
    },
  • MCP tool registration for 'update-index', including name, description, schema, and handler function.
    server.tool(
      'update-index',
      'Update a Meilisearch index (currently only supports updating the primary key)',
      {
        indexUid: z.string().describe('Unique identifier of the index'),
        primaryKey: z.string().describe('New primary key for the index'),
      },
      async ({ indexUid, primaryKey }: UpdateIndexParams) => {
        try {
          const response = await apiClient.patch(`/indexes/${indexUid}`, {
            primaryKey,
          });
          return {
            content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }],
          };
        } catch (error) {
          return createErrorResponse(error);
        }
      }
    );
  • src/index.ts:64-64 (registration)
    Invocation of registerIndexTools which registers the 'update-index' tool (among others) on the main MCP server instance.
    registerIndexTools(server);
  • TypeScript interface defining the input parameters for the update-index tool handler.
    interface UpdateIndexParams {
      indexUid: string;
      primaryKey: 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