Skip to main content
Glama
meilisearch

Meilisearch MCP Server

Official
by meilisearch

search

Query and retrieve data from Meilisearch indices with flexibility. Specify an index or search across all indices, apply filters, sorting, and pagination for precise results.

Instructions

Search through Meilisearch indices. If indexUid is not provided, it will search across all indices.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNo
indexUidNo
limitNo
offsetNo
queryYes
sortNo

Implementation Reference

  • MCP server handler for the 'search' tool: extracts arguments, calls MeilisearchClient.search, formats results as JSON, and returns as TextContent.
    elif name == "search":
        search_results = self.meili_client.search(
            query=arguments["query"],
            index_uid=arguments.get("indexUid"),
            limit=arguments.get("limit"),
            offset=arguments.get("offset"),
            filter=arguments.get("filter"),
            sort=arguments.get("sort"),
        )
    
        # Format the results for better readability
        formatted_results = json.dumps(
            search_results, indent=2, default=json_serializer
        )
        return [
            types.TextContent(
                type="text",
                text=f"Search results for '{arguments['query']}':\n{formatted_results}",
            )
        ]
  • Input schema definition and tool registration for 'search' in the list_tools() handler.
    types.Tool(
        name="search",
        description="Search through Meilisearch indices. If indexUid is not provided, it will search across all indices.",
        inputSchema={
            "type": "object",
            "properties": {
                "query": {"type": "string"},
                "indexUid": {"type": "string"},
                "limit": {"type": "integer"},
                "offset": {"type": "integer"},
                "filter": {"type": "string"},
                "sort": {
                    "type": "array",
                    "items": {"type": "string"},
                },
            },
            "required": ["query"],
            "additionalProperties": False,
        },
    ),
  • Core implementation of search logic in MeilisearchClient: supports single-index or multi-index search using the Meilisearch library, handles parameters and errors.
    def search(
        self,
        query: str,
        index_uid: Optional[str] = None,
        limit: Optional[int] = 20,
        offset: Optional[int] = 0,
        filter: Optional[str] = None,
        sort: Optional[List[str]] = None,
        **kwargs,
    ) -> Dict[str, Any]:
        """
        Search through Meilisearch indices.
        If index_uid is provided, search in that specific index.
        If not provided, search across all available indices.
        """
        try:
            # Prepare search parameters, removing None values
            search_params = {
                "limit": limit if limit is not None else 20,
                "offset": offset if offset is not None else 0,
            }
    
            if filter is not None:
                search_params["filter"] = filter
            if sort is not None:
                search_params["sort"] = sort
    
            # Add any additional parameters
            search_params.update({k: v for k, v in kwargs.items() if v is not None})
    
            if index_uid:
                # Search in specific index
                index = self.client.index(index_uid)
                return index.search(query, search_params)
            else:
                # Search across all indices
                results = {}
                indexes = self.client.get_indexes()
    
                for index in indexes["results"]:
                    try:
                        search_result = index.search(query, search_params)
                        if search_result["hits"]:  # Only include indices with matches
                            results[index.uid] = search_result
                    except Exception as e:
                        logger.warning(f"Failed to search index {index.uid}: {str(e)}")
                        continue
    
                return {"multi_index": True, "query": query, "results": results}
    
        except Exception as e:
            raise Exception(f"Search failed: {str(e)}")
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. It mentions the default behavior for missing 'indexUid' (search across all indices), which is useful context. However, it lacks critical details such as whether this is a read-only operation, potential rate limits, authentication requirements, or what the search results look like (e.g., format, pagination). For a search tool with 6 parameters, this is a significant gap in transparency.

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 appropriately sized and front-loaded, consisting of two clear sentences. The first sentence directly states the tool's purpose, and the second adds essential parameter context without redundancy. Every sentence earns its place by providing value, making it efficient and well-structured.

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?

Given the complexity (6 parameters, 1 required), no annotations, and no output schema, the description is incomplete. It covers the basic purpose and one parameter's default behavior but misses details on other parameters, behavioral traits like safety or performance, and expected outputs. For a search tool in this context, more comprehensive information is needed to guide effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning none of the 6 parameters have descriptions in the schema. The description only addresses one parameter ('indexUid') by explaining its default behavior when omitted. It doesn't add meaning for other parameters like 'filter', 'limit', 'offset', 'query', or 'sort', leaving most semantics undocumented. This fails to compensate for the low schema coverage.

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 tool's purpose as 'Search through Meilisearch indices' with a specific verb ('Search') and resource ('Meilisearch indices'). It distinguishes from siblings like 'get-documents' or 'list-indexes' by focusing on search functionality rather than retrieval or listing. However, it doesn't explicitly differentiate from potential search alternatives within the sibling set.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides implied usage guidance by stating 'If indexUid is not provided, it will search across all indices,' which suggests when to omit this parameter. However, it doesn't offer explicit when-to-use vs. when-not-to-use advice or name alternatives among siblings like 'get-documents' for specific document retrieval. The guidance is limited to parameter behavior rather than tool selection.

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

Related 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/meilisearch/meilisearch-mcp'

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