multi-search
Execute multiple search queries simultaneously across Meilisearch indexes to retrieve consolidated results in a single request.
Instructions
Perform multiple searches in one request
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| searches | Yes | JSON array of search queries, each with indexUid and q fields |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"searches": {
"description": "JSON array of search queries, each with indexUid and q fields",
"type": "string"
}
},
"required": [
"searches"
],
"type": "object"
}
Implementation Reference
- src/tools/search-tools.ts:107-146 (registration)Registration of the 'multi-search' MCP tool, including input schema (JSON string of searches), handler logic (parse/validate JSON, API call to /multi-search), and error handling.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/tools/search-tools.ts:32-34 (schema)Type definition for the input parameters of the multi-search handler.interface MultiSearchParams { searches: string; }
- src/index.ts:66-66 (registration)Invocation of registerSearchTools which includes the registration of the 'multi-search' tool.registerSearchTools(server);