Skip to main content
Glama
avarant

Typesense MCP Server

list_collections

Fetch a list of all collections in the Typesense server to manage and access schemas or handle errors with ease. Supports efficient database organization and retrieval.

Instructions

Retrieves a list of all collections in the Typesense server.

Args:
    ctx (Context): The MCP context.

Returns:
    list | str: A list of collection schemas or an error message string.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • main.py:118-140 (handler)
    Handler function for the 'list_collections' tool. It uses the Typesense client from the context to retrieve all collections and returns the list or an error message.
    @mcp.tool()
    async def list_collections(ctx: Context) -> list | str:
        """
        Retrieves a list of all collections in the Typesense server.
    
        Args:
            ctx (Context): The MCP context.
    
        Returns:
            list | str: A list of collection schemas or an error message string.
        """
        try:
            client: typesense.Client = ctx.request_context.lifespan_context.client
            collections = client.collections.retrieve()
            # The response is expected to be a list of dictionaries
            return collections
        except typesense.exceptions.TypesenseClientError as e:
            print(f"Error listing collections: {e}")
            return f"Error listing collections: {e}"
        except Exception as e:
            print(f"An unexpected error occurred while listing collections: {e}")
            return f"An unexpected error occurred: {e}"
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