Skip to main content
Glama

chroma_create_collection

Create a new Chroma collection with customizable HNSW parameters, embedding functions, and optional metadata to organize and manage AI-generated or user-input data efficiently.

Instructions

Create a new Chroma collection with configurable HNSW parameters.

Args:
    collection_name: Name of the collection to create
    embedding_function_name: Name of the embedding function to use. Options: 'default', 'cohere', 'openai', 'jina', 'voyageai', 'ollama', 'roboflow'
    metadata: Optional metadata dict to add to the collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_nameYes
embedding_function_nameNodefault
metadataNo

Implementation Reference

  • The handler function for 'chroma_create_collection' tool. It creates a new ChromaDB collection with the specified embedding function and metadata using the global Chroma client.
    @mcp.tool()
    async def chroma_create_collection(
        collection_name: str,
        embedding_function_name: str = "default",
        metadata: Dict | None = None,
    ) -> str:
        """Create a new Chroma collection with configurable HNSW parameters.
        
        Args:
            collection_name: Name of the collection to create
            embedding_function_name: Name of the embedding function to use. Options: 'default', 'cohere', 'openai', 'jina', 'voyageai', 'ollama', 'roboflow'
            metadata: Optional metadata dict to add to the collection
        """
        client = get_chroma_client()
        
        embedding_function = mcp_known_embedding_functions[embedding_function_name]
        
        configuration=CreateCollectionConfiguration(
            embedding_function=embedding_function()
        )
        
        try:
            client.create_collection(
                name=collection_name,
                configuration=configuration,
                metadata=metadata
            )
            config_msg = f" with configuration: {configuration}"
            return f"Successfully created collection {collection_name}{config_msg}"
        except Exception as e:
            raise Exception(f"Failed to create collection '{collection_name}': {str(e)}") from e
  • Dictionary of known embedding functions used by the chroma_create_collection handler to select the appropriate embedding function based on the input parameter.
    mcp_known_embedding_functions: Dict[str, EmbeddingFunction] = {
        "default": DefaultEmbeddingFunction,
        "cohere": CohereEmbeddingFunction,
        "openai": OpenAIEmbeddingFunction,
        "jina": JinaEmbeddingFunction,
        "voyageai": VoyageAIEmbeddingFunction,
        "roboflow": RoboflowEmbeddingFunction,
    }

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/chroma-core/chroma-mcp'

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