Skip to main content
Glama
avarant

Typesense MCP Server

delete_document

Remove a specific document by its ID from a collection in Typesense databases to manage and maintain accurate data storage and organization.

Instructions

Deletes a single document by its ID from a specific collection.

Args:
    ctx (Context): The MCP context.
    collection_name (str): The name of the collection.
    document_id (str): The ID of the document to delete.

Returns:
    dict | str: The deleted document dictionary or an error message string.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_nameYes
document_idYes

Implementation Reference

  • main.py:704-736 (handler)
    The handler function for the 'delete_document' tool, decorated with @mcp.tool() which also serves as registration. It deletes a document by ID from a Typesense collection using the client, with error handling for not found cases and other exceptions.
    @mcp.tool()
    async def delete_document(ctx: Context, collection_name: str, document_id: str) -> dict | str:
        """
        Deletes a single document by its ID from a specific collection.
    
        Args:
            ctx (Context): The MCP context.
            collection_name (str): The name of the collection.
            document_id (str): The ID of the document to delete.
    
        Returns:
            dict | str: The deleted document dictionary or an error message string.
        """
        if not collection_name:
            return "Error: collection_name parameter is required."
        if not document_id:
            return "Error: document_id parameter is required."
    
        try:
            client: typesense.Client = ctx.request_context.lifespan_context.client
            # NOTE: Assuming document delete is synchronous based on collection delete pattern.
            deleted_doc = client.collections[collection_name].documents[document_id].delete()
            return deleted_doc
        except typesense.exceptions.ObjectNotFound:
            # Could be collection or document not found
            return f"Error: Collection '{collection_name}' or Document ID '{document_id}' not found."
        except typesense.exceptions.TypesenseClientError as e:
            print(f"Error deleting document '{document_id}' from '{collection_name}': {e}")
            return f"Error deleting document '{document_id}' from '{collection_name}': {e}"
        except Exception as e:
            print(f"An unexpected error occurred while deleting document '{document_id}' from '{collection_name}': {e}")
            return f"An unexpected error occurred: {e}"
Behavior2/5

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

No annotations are provided, so the description carries the full burden. While 'Deletes' clearly indicates a destructive operation, the description doesn't disclose whether this requires specific permissions, whether the deletion is permanent/reversible, what happens to related data, or any rate limits. The return value description adds some context but doesn't fully address behavioral traits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with a clear purpose statement followed by parameter and return value documentation. The Args/Returns sections are well-structured, though the inclusion of 'ctx (Context)' in Args is unnecessary since it's an MCP implementation detail not relevant to tool selection.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive operation with no annotations and no output schema, the description provides basic purpose and parameter information but lacks important context about permissions, permanence, side effects, and error handling. The return value description helps but doesn't fully compensate for the missing behavioral transparency.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates by clearly explaining both parameters: 'collection_name' identifies the specific collection, and 'document_id' identifies the exact document to delete. The description adds meaningful context beyond the bare schema, though it doesn't specify format requirements or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Deletes'), resource ('a single document by its ID'), and scope ('from a specific collection'). It distinguishes from sibling tools like 'delete_collection' (which deletes entire collections) and 'truncate_collection' (which removes all documents from a collection).

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

Usage Guidelines3/5

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

The description implies usage for deleting individual documents by ID from collections, but doesn't explicitly state when to use this vs alternatives like 'delete_collection' or 'truncate_collection'. No guidance on prerequisites or error conditions is provided.

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/avarant/typesense-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server