Skip to main content
Glama

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
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states the tool creates a new collection but doesn't disclose whether it copies documents/metadata from the source, requires specific permissions, has side effects on the original collection, or what happens if the new name already exists. This leaves critical behavioral traits undocumented for a mutation operation.

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

Conciseness4/5

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

The description is front-loaded with the core purpose in the first sentence, followed by a structured parameter list. It avoids unnecessary elaboration, though the parameter section could be more integrated with the main description. Every sentence adds value, but the formatting as a code-like block slightly disrupts flow.

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 the tool's complexity (a mutation with 2+ parameters), lack of annotations, and no output schema, the description is incomplete. It misses behavioral details like what 'fork' entails (e.g., copying data), error conditions, and return values. For a tool that modifies system state, this leaves significant gaps for an AI agent to operate safely and effectively.

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

Parameters3/5

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

Schema description coverage is 0%, so the schema provides only basic typing. The description adds meaningful context by explaining that 'collection_name' is the source and 'new_collection_name' is the target, and mentions an optional 'metadata' parameter not in the schema. However, it doesn't fully compensate for the coverage gap—e.g., no details on metadata structure or name constraints.

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 clearly states the verb ('Fork') and resource ('a Chroma collection'), making the purpose immediately understandable. It distinguishes from siblings like 'chroma_create_collection' by specifying it creates a copy from an existing collection rather than a new empty one. However, it doesn't explicitly contrast with all siblings like 'chroma_modify_collection'.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., the source collection must exist), when not to use it, or compare it to similar tools like 'chroma_create_collection' for creating new collections from scratch or 'chroma_modify_collection' for altering existing ones.

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

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

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