Skip to main content
Glama
avarant

Typesense MCP Server

describe_collection

Retrieve the schema and metadata of a specified collection to understand its structure and properties. Use this tool to manage and analyze collections in Typesense MCP Server efficiently.

Instructions

Retrieves the schema and metadata for a specific collection.

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

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_nameYes

Implementation Reference

  • main.py:142-167 (handler)
    This is the handler function for the 'describe_collection' tool. It is decorated with @mcp.tool() for registration and implements the logic to retrieve the schema and metadata of a Typesense collection by name, handling various errors.
    @mcp.tool()
    async def describe_collection(ctx: Context, collection_name: str) -> dict | str:
        """
        Retrieves the schema and metadata for a specific collection.
    
        Args:
            ctx (Context): The MCP context.
            collection_name (str): The name of the collection to describe.
    
        Returns:
            dict | str: The 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
            collection_info = client.collections[collection_name].retrieve()
            return collection_info
        except typesense.exceptions.ObjectNotFound:
            return f"Error: Collection '{collection_name}' not found."
        except typesense.exceptions.TypesenseClientError as e:
            print(f"Error describing collection '{collection_name}': {e}")
            return f"Error describing collection '{collection_name}': {e}"
        except Exception as e:
            print(f"An unexpected error occurred while describing collection '{collection_name}': {e}")
            return f"An unexpected error occurred: {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/avarant/typesense-mcp-server'

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