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);

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