Skip to main content
Glama
chroma-core

Chroma MCP Server

Official
by chroma-core

chroma_fork_collection

Create a new collection by copying an existing one, allowing you to reuse data structures and metadata efficiently within the Chroma MCP Server environment.

Instructions

Fork a Chroma collection.

Args:
    collection_name: Name of the collection to fork
    new_collection_name: Name of the new collection to create
    metadata: Optional metadata dict to add to the new collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_nameYes
new_collection_nameYes

Implementation Reference

  • The main handler function for the 'chroma_fork_collection' tool. It forks an existing Chroma collection into a new one using the Chroma client's fork method. Registered via @mcp.tool() decorator.
    @mcp.tool()
    async def chroma_fork_collection(
        collection_name: str,
        new_collection_name: str,
    ) -> str:
        """Fork a Chroma collection.
        
        Args:
            collection_name: Name of the collection to fork
            new_collection_name: Name of the new collection to create
            metadata: Optional metadata dict to add to the new collection
        """
        client = get_chroma_client()
        try:
            collection = client.get_collection(collection_name)
            collection.fork(new_collection_name)
            return f"Successfully forked collection {collection_name} to {new_collection_name}"
        except Exception as e:
            raise Exception(f"Failed to fork collection '{collection_name}': {str(e)}") from e
  • The @mcp.tool() decorator registers the chroma_fork_collection function as an MCP tool.
    @mcp.tool()
  • Function signature defining input parameters (collection_name, new_collection_name) and return type (str), serving as the tool schema.
    async def chroma_fork_collection(
        collection_name: str,
        new_collection_name: str,
    ) -> str:
  • Helper function to get or initialize the Chroma client instance, used by the tool.
    def get_chroma_client(args=None):
        """Get or create the global Chroma client instance."""
        global _chroma_client
        if _chroma_client is None:
            if args is None:
                # Create parser and parse args if not provided
                parser = create_parser()
                args = parser.parse_args()
            
            # Load environment variables from .env file if it exists
            load_dotenv(dotenv_path=args.dotenv_path)
            if args.client_type == 'http':
                if not args.host:
                    raise ValueError("Host must be provided via --host flag or CHROMA_HOST environment variable when using HTTP client")
                
                settings = Settings()
                if args.custom_auth_credentials:
                    settings = Settings(
                        chroma_client_auth_provider="chromadb.auth.basic_authn.BasicAuthClientProvider",
                        chroma_client_auth_credentials=args.custom_auth_credentials
                    )
                
                # Handle SSL configuration
                try:
                    _chroma_client = chromadb.HttpClient(
                        host=args.host,
                        port=args.port if args.port else None,
                        ssl=args.ssl,
                        settings=settings
                    )
                except ssl.SSLError as e:
                    print(f"SSL connection failed: {str(e)}")
                    raise
                except Exception as e:
                    print(f"Error connecting to HTTP client: {str(e)}")
                    raise
                
            elif args.client_type == 'cloud':
                if not args.tenant:
                    raise ValueError("Tenant must be provided via --tenant flag or CHROMA_TENANT environment variable when using cloud client")
                if not args.database:
                    raise ValueError("Database must be provided via --database flag or CHROMA_DATABASE environment variable when using cloud client")
                if not args.api_key:
                    raise ValueError("API key must be provided via --api-key flag or CHROMA_API_KEY environment variable when using cloud client")
                
                try:
                    _chroma_client = chromadb.HttpClient(
                        host="api.trychroma.com",
                        ssl=True,  # Always use SSL for cloud
                        tenant=args.tenant,
                        database=args.database,
                        headers={
                            'x-chroma-token': args.api_key
                        }
                    )
                except ssl.SSLError as e:
                    print(f"SSL connection failed: {str(e)}")
                    raise
                except Exception as e:
                    print(f"Error connecting to cloud client: {str(e)}")
                    raise
                    
            elif args.client_type == 'persistent':
                if not args.data_dir:
                    raise ValueError("Data directory must be provided via --data-dir flag when using persistent client")
                _chroma_client = chromadb.PersistentClient(path=args.data_dir)
            else:  # ephemeral
                _chroma_client = chromadb.EphemeralClient()
                
        return _chroma_client

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.6/5.0
Behavior2/5

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

No annotations are provided, and the description lacks behavioral details. It does not disclose whether the fork is deep or shallow, if metadata is copied, or if the operation is reversible. The brief description leaves significant ambiguity.

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

Conciseness3/5

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

The description is short but structured as a docstring with repeated 'Args:' lines. It could be more concise, e.g., by combining the purpose and parameter descriptions. Every sentence is functional but not optimally efficient.

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

Completeness2/5

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

Given no output schema and the complexity of a mutation tool, the description is insufficient. It fails to explain what happens to existing data, whether embeddings are copied, or how success is indicated. The tool's behavior remains opaque.

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

Parameters2/5

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

The description adds minimal meaning beyond parameter names: 'Name of the collection to fork' and 'Name of the new collection to create' are largely redundant. It also mentions an optional 'metadata' parameter that is not present in the input schema, creating inconsistency. Schema coverage is 0%, so the description should compensate more.

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

Purpose4/5

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

The description states 'Fork a Chroma collection', which is a specific verb and resource indicating duplication. However, it does not differentiate from sibling tools like chroma_create_collection or chroma_delete_collection, as 'fork' could imply partial copying or aliasing.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives. It does not mention prerequisites, such as the original collection must exist, or contrast with creating a new collection from scratch.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.