Skip to main content
Glama
OrionPotter

Meilisearch MCP Server

by OrionPotter

multi-search

Execute multiple search queries across different indexes in a single request to Meilisearch, reducing API calls and improving efficiency for batch search operations.

Instructions

Perform multiple searches in one request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchesYesJSON array of search queries, each with indexUid and q fields

Implementation Reference

  • The execution handler for the 'multi-search' MCP tool. It parses the input JSON string containing an array of search objects, validates that each has an 'indexUid', makes a POST request to the '/multi-search' API endpoint using apiClient, and returns the formatted response or error.
      async ({ searches }: MultiSearchParams) => {
        try {
          // Parse the searches string to ensure it's valid JSON
          const parsedSearches = JSON.parse(searches);
          
          // Ensure searches is an array
          if (!Array.isArray(parsedSearches)) {
            return {
              isError: true,
              content: [{ type: 'text', text: 'Searches must be a JSON array' }],
            };
          }
          
          // Ensure each search has at least indexUid
          for (const search of parsedSearches) {
            if (!search.indexUid) {
              return {
                isError: true,
                content: [{ type: 'text', text: 'Each search must have an indexUid field' }],
              };
            }
          }
          
          const response = await apiClient.post('/multi-search', {
            queries: parsedSearches,
          });
          return {
            content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }],
          };
        } catch (error) {
          return createErrorResponse(error);
        }
      }
    );
  • Zod schema defining the input parameters for the 'multi-search' tool: a single 'searches' field as a string containing JSON array of search queries.
    {
      searches: z.string().describe('JSON array of search queries, each with indexUid and q fields'),
    },
  • TypeScript interface 'MultiSearchParams' defining the expected shape of the handler input parameters.
    interface MultiSearchParams {
      searches: string;
    }
  • The server.tool() registration call for 'multi-search', specifying the tool name, description, input schema, and handler function.
    server.tool(
      'multi-search',
      'Perform multiple searches in one request',
      {
        searches: z.string().describe('JSON array of search queries, each with indexUid and q fields'),
      },
      async ({ searches }: MultiSearchParams) => {
        try {
          // Parse the searches string to ensure it's valid JSON
          const parsedSearches = JSON.parse(searches);
          
          // Ensure searches is an array
          if (!Array.isArray(parsedSearches)) {
            return {
              isError: true,
              content: [{ type: 'text', text: 'Searches must be a JSON array' }],
            };
          }
          
          // Ensure each search has at least indexUid
          for (const search of parsedSearches) {
            if (!search.indexUid) {
              return {
                isError: true,
                content: [{ type: 'text', text: 'Each search must have an indexUid field' }],
              };
            }
          }
          
          const response = await apiClient.post('/multi-search', {
            queries: parsedSearches,
          });
          return {
            content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }],
          };
        } catch (error) {
          return createErrorResponse(error);
        }
      }
    );
  • src/index.ts:66-66 (registration)
    Top-level registration call to registerSearchTools(server), which includes the 'multi-search' tool among others, in the main MCP server initialization.
    registerSearchTools(server);

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
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 the tool performs searches but doesn't disclose behavioral traits such as whether it's read-only, potential rate limits, error handling for partial failures, or the format of results. This leaves significant gaps for an agent to understand how to use it effectively.

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 purpose and appropriately sized for the tool's complexity.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., aggregated results, error responses) or provide context on usage scenarios. For a tool that likely returns complex data, this leaves the agent with insufficient information.

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 'searches' parameter fully documented in the schema. The description adds no additional meaning beyond the schema, such as examples of the JSON array structure or constraints on the number of searches. Baseline 3 is appropriate since 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 ('perform multiple searches') and the scope ('in one request'), which is specific and distinguishes it from the basic 'search' tool. However, it doesn't explicitly contrast with other search-related tools like 'facet-search' or 'vector-search', so it's not fully differentiated from all siblings.

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?

The description provides no guidance on when to use this tool versus alternatives like the standard 'search' tool or other search-related siblings. It lacks any mention of prerequisites, performance considerations, or specific scenarios where batching searches is beneficial.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.