Bridges AI models with Meilisearch using the Model Context Protocol, offering intelligent tool selection, full Meilisearch API access, multiple transport options, and seamless integration with leading AI providers for enhanced search and inference capabilities.
Unlock the full potential of mcp-meilisearch through LangDB's AI Gateway. Get enterprise-grade security, analytics, and seamless integration with zero configuration.
Free tier available • No credit card required
A Model Context Protocol (MCP) server implementation that provides a bridge between AI models and the Meilisearch search engine.
Install the package:
# Using npm npm install mcp-meilisearch # Using yarn yarn add mcp-meilisearch # Using pnpm pnpm add mcp-meilisearch
meilisearchHost
: URL of the Meilisearch instance (Default: "http://localhost:7700")meilisearchApiKey
: API key for authenticating with Meilisearch (Default: "")transport
: Transport type for MCP server ("http" | "stdio") (Default: "http")httpPort
: HTTP port for MCP server (Default: 4995)mcpEndpoint
: MCP endpoint path (Default: "/mcp")sessionTimeout
: Session timeout in milliseconds (Default: 3600000)sessionCleanupInterval
: Session cleanup interval in milliseconds (Default: 60000)aiProviderName
: Name of the AI provider ("openai" | "huggingface" | "openrouter" | "ollama") (Default: "openai")aiProviderApiKey
: AI provider API key for AI inferencellmModel
: AI model to use (Default: "gpt-3.5-turbo")Please be aware that not all models support function calling, which is required for proper AI inference in this package. Make sure to select a model that supports the tools parameter.
Provider | Supported Models |
---|---|
OpenAI | List of supported models |
OpenRouter | List of supported models |
HuggingFace | List of supported models |
Ollama | List of supported models |
await mcpMeilisearchServer({ meilisearchHost: "http://localhost:7700", aiProviderName: "openrouter", aiProviderApiKey: "your_openrouter_api_key", llmModel: "anthropic/claude-3-opus", // Make sure to use a model that supports function calling });
The package exports the MCPClient class for client-side integration:
import { MCPClient } from "mcp-meilisearch/client"; const client = new MCPClient("mcp-meilisearch-client"); await client.connectToServer("http://localhost:4995/mcp"); const result = await client.callTool("global-search", { q: "search kiosco antonio", });
callTool(name, args)
Calls a specific tool on the MCP server with optional arguments.
Parameters:
name
: String - The name of the tool to callargs
: Object (Optional) - Arguments to pass to the toolprocessSummary(query)
Processes data using AI to generate a human-readable summary.
Parameters:
query
: Any - The data to be summarizedcallToolWithAI(query, options)
Processes a user query through AI to determine and execute the most appropriate tool.
Parameters:
query
: String - The user's query or request to be processedoptions
: Object (Optional) - Configuration options
specificTools
: String[] (Optional) - Restricts tool selection to this list of tool namesjustReasoning
: Boolean (Optional) - When set to true
, returns only the AI's reasoning without executing the selected toolprovideSummary
: Boolean (Optional) - When set to true
, generates a concise summary of the search results along with the regular responseYou can start the server programmatically:
import mcpMeilisearchServer from "mcp-meilisearch"; await mcpMeilisearchServer({ meilisearchHost: "http://localhost:7700", meilisearchApiKey: "your_meilisearch_api_key", aiProviderName: "openai", aiProviderApiKey: "your_ai_provider_api_key", llmModel: "gpt-4", });
The MCP server exposes various tools that allow you to interact with Meilisearch functionalities. Each tool corresponds to a specific Meilisearch API endpoint, enabling you to perform operations such as searching, indexing, and managing documents.
indexUid
(string, optional): Unique identifier of the index.limit
(number, optional): Maximum number of tasks to return.from
(number, optional): Task uid from which to start fetching.status
(string, optional): Status of tasks to return.type
(string, optional): Type of tasks to return.indexUids
(string[], optional): UIDs of the indexes on which tasks were performed.statuses
(string[], optional): Statuses of tasks to delete.types
(string[], optional): Types of tasks to delete.indexUids
(string[], optional): UIDs of the indexes on which tasks to delete were performed.uids
(number[], optional): UIDs of the tasks to delete.canceledBy
(number[], optional): UIDs of the tasks that canceled tasks to delete.beforeUid
(number, optional): Delete tasks whose uid is before this value.beforeStartedAt
(string, optional): Delete tasks that started processing before this date (ISO 8601 format).beforeFinishedAt
(string, optional): Delete tasks that finished processing before this date (ISO 8601 format).limit
(number, optional): Maximum number of indexes to return.offset
(number, optional): Number of indexes to skip.indexUid
(string, required): Unique identifier of the index.indexUid
(string, required): Unique identifier for the new index.primaryKey
(string, optional): Primary key for the index.indexUid
(string, required): Unique identifier of the index.primaryKey
(string, required): New primary key for the index.indexUid
(string, required): Unique identifier of the index to delete.indexes
(string, required): JSON array of index pairs to swap, e.g. [["movies", "movies_new"]].indexUid
(string, required): Unique identifier of the index.limit
(number, optional): Maximum number of documents to return (default: 20).offset
(number, optional): Number of documents to skip (default: 0).fields
(string[], optional): Fields to return in the documents.filter
(string, optional): Filter query to apply.indexUid
(string, required): Unique identifier of the index.documentId
(string, required): ID of the document to retrieve.fields
(string[], optional): Fields to return in the document.indexUid
(string, required): Unique identifier of the index.documents
(string, required): JSON array of documents to add.primaryKey
(string, optional): Primary key for the documents.indexUid
(string, required): Unique identifier of the index.documents
(string, required): JSON array of documents to update.primaryKey
(string, optional): Primary key for the documents.indexUid
(string, required): Unique identifier of the index.documentId
(string, required): ID of the document to delete.indexUid
(string, required): Unique identifier of the index.documentIds
(string, required): JSON array of document IDs to delete.indexUid
(string, required): Unique identifier of the index.indexUid
(string, required): Unique identifier of the index.q
(string, required): Search query.limit
(number, optional): Maximum number of results to return (default: 20).offset
(number, optional): Number of results to skip (default: 0).filter
(string, optional): Filter query to apply.sort
(string[], optional): Attributes to sort by, e.g. ["price:asc"].facets
(string[], optional): Facets to return.attributesToRetrieve
(string[], optional): Attributes to include in results.attributesToCrop
(string[], optional): Attributes to crop.cropLength
(number, optional): Length at which to crop cropped attributes.attributesToHighlight
(string[], optional): Attributes to highlight.highlightPreTag
(string, optional): Tag to insert before highlighted text.highlightPostTag
(string, optional): Tag to insert after highlighted text.showMatchesPosition
(boolean, optional): Whether to include match positions in results.matchingStrategy
(string, optional): Matching strategy: 'all' or 'last'.queries
(string, required): JSON array of search queries, each containing the same parameters as the search
tool.q
(string, required): Search query.limit
(number, optional): Maximum number of results to return per index (default: 20).attributesToRetrieve
(string[], optional): Attributes to include in results.indexUid
(string, required): Unique identifier of the index.facetName
(string, required): Name of the facet to search.facetQuery
(string, optional): Query to match against facet values.filter
(string, optional): Filter to apply to the base search.indexUid
(string, required): Unique identifier of the index.indexUid
(string, required): Unique identifier of the index.settings
(string, required): JSON object containing settings to update.indexUid
(string, required): Unique identifier of the index.The following tools retrieve specific settings for a Meilisearch index:
All these tools have the same parameter:
indexUid
(string, required): Unique identifier of the index.The following tools update specific settings for a Meilisearch index:
update-displayed-attributes
indexUid
(string, required): Unique identifier of the index.displayedAttributes
(string, required): JSON array of attributes to display, e.g. ["title", "description"].update-searchable-attributes
indexUid
(string, required): Unique identifier of the index.searchableAttributes
(string, required): JSON array of attributes that can be searched, e.g. ["title", "description"].update-filterable-attributes
indexUid
(string, required): Unique identifier of the index.filterableAttributes
(string, required): JSON array of attributes that can be used as filters, e.g. ["genre", "director"].update-sortable-attributes
indexUid
(string, required): Unique identifier of the index.sortableAttributes
(string, required): JSON array of attributes that can be used for sorting, e.g. ["price", "date"].update-ranking-rules
indexUid
(string, required): Unique identifier of the index.rankingRules
(string, required): JSON array of ranking rules, e.g. ["typo", "words", "proximity", "attribute", "sort", "exactness"].update-stop-words
indexUid
(string, required): Unique identifier of the index.stopWords
(string, required): JSON array of words to ignore in search queries, e.g. ["the", "a", "an"].update-synonyms
indexUid
(string, required): Unique identifier of the index.synonyms
(string, required): JSON object mapping words to their synonyms, e.g. {"movie": ["film"]}.update-typo-tolerance
indexUid
(string, required): Unique identifier of the index.typoTolerance
(string, required): JSON object with typo tolerance configuration, e.g. {"enabled": true, "minWordSizeForTypos": {"oneTypo": 5, "twoTypos": 9}}.update-pagination
indexUid
(string, required): Unique identifier of the index.pagination
(string, required): JSON object with pagination configuration, e.g. {"maxTotalHits": 1000}.update-faceting
indexUid
(string, required): Unique identifier of the index.faceting
(string, required): JSON object with faceting configuration, e.g. {"maxValuesPerFacet": 100}.update-dictionary
indexUid
(string, required): Unique identifier of the index.dictionary
(string, required): JSON array of words to consider as a single word, e.g. ["San Francisco", "New York"].update-proximity-precision
indexUid
(string, required): Unique identifier of the index.proximityPrecision
(string, required): String with proximity precision value, can be 'byWord' or 'byAttribute'.update-separator-tokens
indexUid
(string, required): Unique identifier of the index.separatorTokens
(string, required): JSON array of tokens that should be considered as word separators, e.g. ["-", "_"].update-non-separator-tokens
indexUid
(string, required): Unique identifier of the index.nonSeparatorTokens
(string, required): JSON array of tokens that should not be considered as word separators, e.g. ["@", "."].update-word-dictionary
indexUid
(string, required): Unique identifier of the index.wordDictionary
(string, required): JSON array of custom words to add to the dictionary, e.g. ["cbuilder", "meilisearch"].The following tools reset specific settings for a Meilisearch index to their default values:
All these reset tools have the same parameter:
indexUid
(string, required): Unique identifier of the index.limit
(number, optional): Maximum number of tasks to return.from
(number, optional): Task uid from which to start fetching.statuses
(string[], optional): Statuses of tasks to return.types
(string[], optional): Types of tasks to return.indexUids
(string[], optional): UIDs of the indexes on which tasks were performed.uids
(number[], optional): UIDs of specific tasks to return.taskUid
(number, required): Unique identifier of the task.statuses
(string[], optional): Statuses of tasks to cancel.types
(string[], optional): Types of tasks to cancel.indexUids
(string[], optional): UIDs of the indexes on which tasks to cancel were performed.uids
(number[], optional): UIDs of the tasks to cancel.taskUid
(number, required): Unique identifier of the task to wait for.timeoutMs
(number, optional): Maximum time to wait in milliseconds (default: 5000).intervalMs
(number, optional): Polling interval in milliseconds (default: 500).indexUid
(string, required): Unique identifier of the index.embedders
(string, required): JSON object containing embedder configurations.indexUid
(string, required): Unique identifier of the index.indexUid
(string, required): Unique identifier of the index.indexUid
(string, required): Unique identifier of the index.vector
(string, required): JSON array representing the vector to search for.limit
(number, optional): Maximum number of results to return (default: 20).offset
(number, optional): Number of results to skip (default: 0).filter
(string, optional): Filter to apply (e.g., 'genre = horror AND year > 2020').embedder
(string, optional): Name of the embedder to use (if omitted, a 'vector' must be provided).attributes
(string[], optional): Attributes to include in the vector search.query
(string, optional): Text query to search for (if using 'embedder' instead of 'vector').hybrid
(boolean, optional): Whether to perform a hybrid search (combining vector and text search).hybridRatio
(number, optional): Ratio of vector vs text search in hybrid search (0-1, default: 0.5).Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!