Skip to main content
Glama
meilisearch

Meilisearch MCP Server

Official
by meilisearch

add-documents

Add documents to a Meilisearch index using the MCP server. Specify indexUid and documents array to manage data efficiently for search and retrieval.

Instructions

Add documents to an index

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
documentsYes
indexUidYes
primaryKeyNo

Implementation Reference

  • Registers the 'add-documents' MCP tool with its description and input schema in the server's list_tools handler.
    types.Tool( name="add-documents", description="Add documents to an index", inputSchema={ "type": "object", "properties": { "indexUid": {"type": "string"}, "documents": { "type": "array", "items": { "type": "object", "additionalProperties": True, }, }, "primaryKey": {"type": "string"}, }, "required": ["indexUid", "documents"], "additionalProperties": False, }, ),
  • Input schema definition for the 'add-documents' tool, specifying parameters indexUid (required), documents (required array of objects), and optional primaryKey.
    inputSchema={ "type": "object", "properties": { "indexUid": {"type": "string"}, "documents": { "type": "array", "items": { "type": "object", "additionalProperties": True, }, }, "primaryKey": {"type": "string"}, }, "required": ["indexUid", "documents"], "additionalProperties": False, },
  • Handler implementation for 'add-documents' tool: extracts arguments, invokes DocumentManager.add_documents, and returns the task result as formatted text.
    elif name == "add-documents": result = self.meili_client.documents.add_documents( arguments["indexUid"], arguments["documents"], arguments.get("primaryKey"), ) return [ types.TextContent( type="text", text=f"Added documents: {result}" ) ]
  • Supporting DocumentManager.add_documents method that wraps the underlying Meilisearch Client's index.add_documents call, handling the index lookup and error wrapping.
    def add_documents( self, index_uid: str, documents: List[Dict[str, Any]], primary_key: Optional[str] = None, ) -> Dict[str, Any]: """Add documents to an index""" try: index = self.client.index(index_uid) return index.add_documents(documents, primary_key) except Exception as e:

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