Skip to main content
Glama
OrionPotter

Meilisearch MCP Server

by OrionPotter

update-documents

Modify existing documents in a Meilisearch index by providing updated JSON data and index identifier to maintain current information.

Instructions

Update documents in a Meilisearch index

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexUidYesUnique identifier of the index
documentsYesJSON array of documents to update
primaryKeyNoPrimary key for the documents

Implementation Reference

  • Handler function that executes the tool logic: parses input documents JSON, validates array, prepares params with optional primaryKey, performs PUT request to update documents in Meilisearch via apiClient, returns response or error.
    async ({ indexUid, documents, primaryKey }: UpdateDocumentsParams) => {
      try {
        // Parse the documents string to ensure it's valid JSON
        const parsedDocuments = JSON.parse(documents);
        
        // Ensure documents is an array
        if (!Array.isArray(parsedDocuments)) {
          return {
            isError: true,
            content: [{ type: 'text', text: 'Documents must be a JSON array' }],
          };
        }
        
        const params: Record<string, string> = {};
        if (primaryKey) {
          params.primaryKey = primaryKey;
        }
        
        const response = await apiClient.put(`/indexes/${indexUid}/documents`, parsedDocuments, {
          params,
        });
        return {
          content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }],
        };
      } catch (error) {
        return createErrorResponse(error);
      }
    }
  • Zod input schema defining parameters for the update-documents tool: indexUid (required string), documents (required JSON string of array), primaryKey (optional string).
    {
      indexUid: z.string().describe('Unique identifier of the index'),
      documents: z.string().describe('JSON array of documents to update'),
      primaryKey: z.string().optional().describe('Primary key for the documents'),
    },
  • MCP server.tool registration for 'update-documents', including description, input schema, and handler function.
    server.tool(
      'update-documents',
      'Update documents in a Meilisearch index',
      {
        indexUid: z.string().describe('Unique identifier of the index'),
        documents: z.string().describe('JSON array of documents to update'),
        primaryKey: z.string().optional().describe('Primary key for the documents'),
      },
      async ({ indexUid, documents, primaryKey }: UpdateDocumentsParams) => {
        try {
          // Parse the documents string to ensure it's valid JSON
          const parsedDocuments = JSON.parse(documents);
          
          // Ensure documents is an array
          if (!Array.isArray(parsedDocuments)) {
            return {
              isError: true,
              content: [{ type: 'text', text: 'Documents must be a JSON array' }],
            };
          }
          
          const params: Record<string, string> = {};
          if (primaryKey) {
            params.primaryKey = primaryKey;
          }
          
          const response = await apiClient.put(`/indexes/${indexUid}/documents`, parsedDocuments, {
            params,
          });
          return {
            content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }],
          };
        } catch (error) {
          return createErrorResponse(error);
        }
      }
    );
  • src/index.ts:65-65 (registration)
    Top-level call to registerDocumentTools on the MCP server instance, which includes the update-documents tool.
    registerDocumentTools(server);
  • TypeScript interface defining the parameters for the update-documents handler.
    interface UpdateDocumentsParams {
      indexUid: string;
      documents: string;
      primaryKey?: string;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states 'Update documents' but doesn't disclose behavioral traits such as whether this is a destructive operation, what happens on failure, if it requires specific permissions, or how it interacts with Meilisearch's task system (implied by sibling tools like 'get-task'). This leaves significant gaps for a mutation tool.

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 with zero waste. It's front-loaded with the core action and resource, making it easy to parse quickly.

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 with no annotations and no output schema, the description is incomplete. It doesn't address key contextual aspects like error handling, return values (e.g., task IDs), or how it differs from similar tools (e.g., 'add-documents'). For a tool that modifies data, more behavioral context is needed.

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%, so the input schema already documents all parameters (indexUid, documents, primaryKey) with descriptions. The description adds no additional meaning beyond the schema, such as explaining the JSON format for 'documents' or when 'primaryKey' is required. 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 ('Update') and resource ('documents in a Meilisearch index'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'add-documents' or 'delete-documents', which would require specifying what 'update' means in this context (e.g., partial vs. full updates).

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 like 'add-documents' or 'delete-documents'. The description lacks context about prerequisites (e.g., existing documents to update) or exclusions, leaving the agent to infer usage from the tool 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