meilisearch-hybrid-search-mcp

meilisearch-hybrid-search-mcp

11

The Meilisearch Hybrid Search MCP Server facilitates hybrid searches, seamlessly integrating keyword and semantic searches in Meilisearch indices. It allows customization via environment variables and is adaptable across multiple operating systems.

Meilisearch Hybrid Search MCP Server

This MCP (Model Control Protocol) server provides a tool for performing hybrid searches on a Meilisearch index. It allows combining keyword-based search with semantic vector search.

Environment Variables

Set the following environment variables before running the server:

export MEILI_HOST="http://your-meilisearch-instance:7700" # Meilisearch host URL
export MEILI_API_KEY="your_api_key"                     # Meilisearch API key (if required)
export MEILI_INDEX="your_index_name"                    # The name of the index to search in
export MEILI_EMBEDDER="your_embedder_name"              # The name of the embedder configured in Meilisearch (e.g., 'default', 'myOpenai')
export MEILI_FILTERABLE_ATTRIBUTES="attr1,attr2"        # Comma-separated filterable attributes for AI awareness (from index settings)

Building and Running

Build the server:

go build -o meilisearch-hybrid-search-mcp .

# windows
GOOS=windows GOARCH=amd64 go build -o meilisearch-hybrid-search-mcp.exe .
# linux
GOOS=linux GOARCH=amd64 go build -o meilisearch-hybrid-search-mcp .
# mac
GOOS=macos GOARCH=amd64 go build -o meilisearch-hybrid-search-mcp .

Run the server:

./meilisearch-hybrid-search-mcp

The server will listen on standard input/output.

Available Tool: hybrid_search

This tool performs a hybrid search on the configured Meilisearch index.

Description: Hybrid search your documents in Meilisearch index.

Arguments:

  • keywords (string, required): The search query keywords.
  • semantic_ratio (number, optional, default: 0.5): Controls the balance between keyword and semantic search.
    • 0.0: Pure keyword search.
    • 1.0: Pure semantic search.
    • 0.5: Balanced keyword and semantic search.
  • filterable_attribute (string, optional): The attribute name to filter results on (e.g., "genre", "author"). Requires filter_word.
  • filter_word (string, optional): The value to filter the specified filterable_attribute by (e.g., "Drama", "Tolkien"). Requires filterable_attribute.