Skip to main content
Glama
devlimelabs

Meilisearch MCP Server

by devlimelabs

multi-search

Execute multiple search queries simultaneously across Meilisearch indexes in a single API request to reduce network overhead and improve efficiency.

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 main handler function for the 'multi-search' tool. Parses the JSON string of search objects, validates that it's an array with indexUid in each, calls the Meilisearch /multi-search API, and returns the JSON response as text content.
    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 parameter 'searches' 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 defining the input type for the multi-search handler.
    interface MultiSearchParams { searches: string; }
  • Full registration block for the 'multi-search' tool using server.tool(), including comment, name, description, input schema, and handler function.
    // Multi-search across multiple indexes 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)
    Invocation of registerSearchTools which registers the search tools including 'multi-search' on the main MCP server instance.
    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/devlimelabs/meilisearch-ts-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server