Skip to main content
Glama
avarant

Typesense MCP Server

delete_collection

Remove a specific collection from a Typesense database using its name. This tool permanently deletes the collection schema and all associated data for efficient management of your search infrastructure.

Instructions

Deletes a specific collection.

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

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_nameYes

Implementation Reference

  • main.py:487-514 (handler)
    The core handler function for the 'delete_collection' tool, decorated with @mcp.tool() for automatic registration. It deletes the specified collection using the Typesense client and handles various errors, returning the result or an error message.
    @mcp.tool()
    async def delete_collection(ctx: Context, collection_name: str) -> dict | str:
        """
        Deletes a specific collection.
    
        Args:
            ctx (Context): The MCP context.
            collection_name (str): The name of the collection to delete.
    
        Returns:
            dict | str: The deleted collection schema dictionary or an error message string.
        """
        if not collection_name:
            return "Error: collection_name parameter is required."
    
        try:
            client: typesense.Client = ctx.request_context.lifespan_context.client
            # NOTE: Assuming delete is synchronous based on pattern with retrieve/export/search.
            deleted_info = client.collections[collection_name].delete()
            return deleted_info
        except typesense.exceptions.ObjectNotFound:
            return f"Error: Collection '{collection_name}' not found."
        except typesense.exceptions.TypesenseClientError as e:
            print(f"Error deleting collection '{collection_name}': {e}")
            return f"Error deleting collection '{collection_name}': {e}"
        except Exception as e:
            print(f"An unexpected error occurred while deleting collection '{collection_name}': {e}")
            return f"An unexpected error occurred: {e}"
  • main.py:487-487 (registration)
    The @mcp.tool() decorator registers the delete_collection function as an MCP tool.
    @mcp.tool()

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