Skip to main content
Glama
OrionPotter

Meilisearch MCP Server

by OrionPotter

search

Find documents in a Meilisearch index using queries, filters, sorting, and highlighting to retrieve relevant information.

Instructions

Search for documents in a Meilisearch index

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexUidYesUnique identifier of the index
qYesSearch query
limitNoMaximum number of results to return (default: 20)
offsetNoNumber of results to skip (default: 0)
filterNoFilter query to apply
sortNoAttributes to sort by, e.g. ["price:asc"]
facetsNoFacets to return
attributesToRetrieveNoAttributes to include in results
attributesToCropNoAttributes to crop
cropLengthNoLength at which to crop cropped attributes
attributesToHighlightNoAttributes to highlight
highlightPreTagNoTag to insert before highlighted text
highlightPostTagNoTag to insert after highlighted text
showMatchesPositionNoWhether to include match positions in results
matchingStrategyNoMatching strategy: 'all' or 'last'

Implementation Reference

  • The asynchronous handler function for the 'search' MCP tool. It takes search parameters, makes a POST request to the Meilisearch `/indexes/${indexUid}/search` endpoint using apiClient, returns the JSON response or an error response.
    async ({ indexUid, q, limit, offset, filter, sort, facets, attributesToRetrieve, attributesToCrop, cropLength, attributesToHighlight, highlightPreTag, highlightPostTag, showMatchesPosition, matchingStrategy }: SearchParams) => { try { const response = await apiClient.post(`/indexes/${indexUid}/search`, { q, limit, offset, filter, sort, facets, attributesToRetrieve, attributesToCrop, cropLength, attributesToHighlight, highlightPreTag, highlightPostTag, showMatchesPosition, matchingStrategy, }); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } }
  • Zod input schema defining parameters for the 'search' tool, including indexUid, q (query), limit, offset, filter, sort, facets, cropping options, highlighting options, etc.
    indexUid: z.string().describe('Unique identifier of the index'), q: z.string().describe('Search query'), limit: z.number().min(1).max(1000).optional().describe('Maximum number of results to return (default: 20)'), offset: z.number().min(0).optional().describe('Number of results to skip (default: 0)'), filter: z.string().optional().describe('Filter query to apply'), sort: z.array(z.string()).optional().describe('Attributes to sort by, e.g. ["price:asc"]'), facets: z.array(z.string()).optional().describe('Facets to return'), attributesToRetrieve: z.array(z.string()).optional().describe('Attributes to include in results'), attributesToCrop: z.array(z.string()).optional().describe('Attributes to crop'), cropLength: z.number().optional().describe('Length at which to crop cropped attributes'), attributesToHighlight: z.array(z.string()).optional().describe('Attributes to highlight'), highlightPreTag: z.string().optional().describe('Tag to insert before highlighted text'), highlightPostTag: z.string().optional().describe('Tag to insert after highlighted text'), showMatchesPosition: z.boolean().optional().describe('Whether to include match positions in results'), matchingStrategy: z.string().optional().describe("Matching strategy: 'all' or 'last'"), },
  • MCP server.tool() registration for the 'search' tool, specifying name 'search', description, input schema, and handler function.
    server.tool( 'search', 'Search for documents in a Meilisearch index', { indexUid: z.string().describe('Unique identifier of the index'), q: z.string().describe('Search query'), limit: z.number().min(1).max(1000).optional().describe('Maximum number of results to return (default: 20)'), offset: z.number().min(0).optional().describe('Number of results to skip (default: 0)'), filter: z.string().optional().describe('Filter query to apply'), sort: z.array(z.string()).optional().describe('Attributes to sort by, e.g. ["price:asc"]'), facets: z.array(z.string()).optional().describe('Facets to return'), attributesToRetrieve: z.array(z.string()).optional().describe('Attributes to include in results'), attributesToCrop: z.array(z.string()).optional().describe('Attributes to crop'), cropLength: z.number().optional().describe('Length at which to crop cropped attributes'), attributesToHighlight: z.array(z.string()).optional().describe('Attributes to highlight'), highlightPreTag: z.string().optional().describe('Tag to insert before highlighted text'), highlightPostTag: z.string().optional().describe('Tag to insert after highlighted text'), showMatchesPosition: z.boolean().optional().describe('Whether to include match positions in results'), matchingStrategy: z.string().optional().describe("Matching strategy: 'all' or 'last'"), }, async ({ indexUid, q, limit, offset, filter, sort, facets, attributesToRetrieve, attributesToCrop, cropLength, attributesToHighlight, highlightPreTag, highlightPostTag, showMatchesPosition, matchingStrategy }: SearchParams) => { try { const response = await apiClient.post(`/indexes/${indexUid}/search`, { q, limit, offset, filter, sort, facets, attributesToRetrieve, attributesToCrop, cropLength, attributesToHighlight, highlightPreTag, highlightPostTag, showMatchesPosition, matchingStrategy, }); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } } );
  • TypeScript interface SearchParams defining the types for search parameters used in the handler.
    interface SearchParams { indexUid: string; q: string; limit?: number; offset?: number; filter?: string; sort?: string[]; facets?: string[]; attributesToRetrieve?: string[]; attributesToCrop?: string[]; cropLength?: number; attributesToHighlight?: string[]; highlightPreTag?: string; highlightPostTag?: string; showMatchesPosition?: boolean; matchingStrategy?: string; }
  • src/index.ts:66-66 (registration)
    Call to registerSearchTools(server) in the main server initialization, which registers the 'search' tool among other search tools.
    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