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:
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. It only states the action without details on permissions, rate limits, idempotency, or effects (e.g., overwriting existing documents). This is inadequate for a mutation tool with zero annotation coverage.

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 a single, efficient sentence with no wasted words. It is front-loaded and directly states the tool's function, making it easy to parse quickly.

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 tool's complexity (a mutation operation with 3 parameters), lack of annotations, and no output schema, the description is incomplete. It fails to address critical aspects like error handling, return values, or behavioral traits, leaving significant gaps for agent understanding.

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%, so the description must compensate by explaining parameters. It mentions 'documents' and 'index' but doesn't clarify what 'documents' should contain, what 'indexUid' refers to, or the optional 'primaryKey' role. This adds minimal value beyond the schema's property names.

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 'Add documents to an index' clearly states the action (add) and target resource (documents to an index), making the purpose understandable. However, it lacks differentiation from potential siblings like 'create-index' or 'update-settings', which could involve similar operations, so it doesn't fully distinguish itself.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. For example, it doesn't specify if this is for bulk additions, initial population, or updates, nor does it mention prerequisites like needing an existing index. This leaves the agent without context for 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