Skip to main content
Glama
devlimelabs

Meilisearch MCP Server

by devlimelabs

search

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

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 core handler function for the 'search' tool. It takes search parameters and makes a POST request to the Meilisearch /indexes/{indexUid}/search endpoint, returning the JSON response or an error.
    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 schema defining the input parameters for the 'search' tool.
      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'"),
    },
  • Direct registration of the 'search' tool on the MCP server instance within the registerSearchTools 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);
        }
      }
    );
  • src/index.ts:66-66 (registration)
    Top-level call to registerSearchTools, which registers the 'search' tool among others, in the main server initialization.
    registerSearchTools(server);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Search' implies a read-only operation, the description doesn't mention any behavioral traits like pagination behavior, rate limits, authentication requirements, error conditions, or what the response format looks like. For a search tool with 15 parameters, this is a significant gap in behavioral context.

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 that states the core purpose without any wasted words. It's appropriately sized and front-loaded with the essential information.

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?

For a search tool with 15 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns, how results are structured, pagination behavior, or error conditions. The agent would need to rely heavily on the parameter schema alone, missing important contextual information about the tool's behavior and output.

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?

The schema description coverage is 100%, so all parameters are documented in the schema. The description doesn't add any parameter-specific information beyond what's already in the schema descriptions. It doesn't explain parameter relationships, provide usage examples, or clarify which parameters are most commonly used versus advanced options.

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 ('Search for documents') and the resource ('in a Meilisearch index'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from sibling tools like 'facet-search', 'multi-search', or 'vector-search', which are also search-related operations.

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. There are multiple sibling tools with 'search' in their names (facet-search, multi-search, vector-search), but the description doesn't indicate when this basic search tool is appropriate versus those specialized variants.

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

Install Server

Other Tools

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