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
| Name | Required | Description | Default |
|---|---|---|---|
| documents | Yes | ||
| indexUid | Yes | ||
| primaryKey | No |
Implementation Reference
- src/meilisearch_mcp/server.py:169-188 (registration)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, },
- src/meilisearch_mcp/server.py:534-544 (handler)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: