Skip to main content
Glama
gerred

MCP Server Replicate

list_collections

Retrieve available model collections from Replicate to identify AI models for image generation and inference tasks.

Instructions

List available model collections on Replicate.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler function for the list_collections tool, decorated with @mcp.tool() for registration. Calls ReplicateClient to fetch collections and converts to CollectionList.
    @mcp.tool()
    async def list_collections() -> CollectionList:
        """List available model collections on Replicate."""
        async with ReplicateClient(api_token=os.getenv("REPLICATE_API_TOKEN")) as client:
            result = await client.list_collections()
            return CollectionList(collections=[Collection(**collection) for collection in result])
  • Pydantic schema for the return type CollectionList used by the tool.
    class CollectionList(BaseModel):
        """Response format for listing collections."""
        collections: List[Collection]
        next_cursor: Optional[str] = None 
  • ReplicateClient helper method that performs the actual API call to list collections.
    async def list_collections(self) -> list[dict[str, Any]]:
        """Get list of available model collections.
        
        Returns:
            List of collections with their metadata
            
        Raises:
            Exception: If the API request fails
        """
        if not self.client:
            raise RuntimeError("Client not initialized. Check error property for details.")
    
        try:
            response = await self.http_client.get("/collections")
            response.raise_for_status()
            data = response.json()
            
            return [
                {
                    "name": collection["name"],
                    "slug": collection["slug"],
                    "description": collection.get("description"),
                }
                for collection in data.get("results", [])
            ]
    
        except httpx.HTTPError as err:
            logger.error(f"HTTP error listing collections: {str(err)}")
            raise Exception(f"Failed to list collections: {str(err)}") from err
        except Exception as err:
            logger.error(f"Failed to list collections: {str(err)}")
            raise Exception(f"Failed to list collections: {str(err)}") from err
  • Pydantic schema for individual Collection used in CollectionList.
    class Collection(BaseModel):
        """A collection of related models on Replicate."""
        name: str = Field(..., description="Name of the collection")
        slug: str = Field(..., description="URL-friendly identifier for the collection")
        description: Optional[str] = Field(None, description="Description of the collection's purpose")
        models: List[Model] = Field(default_factory=list, description="Models in this collection")
  • Alternative/duplicate handler in collection_tools.py with explicit name parameter.
    @mcp.tool(
        name="list_collections",
        description="List available model collections on Replicate.",
    )
    async def list_collections() -> CollectionList:
        """List available model collections on Replicate.
        
        Returns:
            CollectionList containing available collections
            
        Raises:
            RuntimeError: If the Replicate client fails to initialize
            Exception: If the API request fails
        """
        async with ReplicateClient() as client:
            result = await client.list_collections()
            return CollectionList(collections=[Collection(**collection) for collection in result])
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states it's a list operation, implying read-only behavior, but doesn't add any context beyond that—such as pagination, rate limits, authentication needs, or what 'available' entails. This leaves significant gaps for a tool with zero annotation coverage.

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

Conciseness5/5

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

The description is a single, efficient sentence that directly states the tool's purpose without any wasted words. It's front-loaded and appropriately sized for a simple list tool.

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

Completeness3/5

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

Given the tool's simplicity (0 parameters, no output schema), the description is minimally adequate but lacks depth. Without annotations, it should ideally provide more behavioral context (e.g., response format, limitations). However, for a basic list operation, it meets the minimum threshold without being fully informative.

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

Parameters4/5

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

The tool has 0 parameters, and schema description coverage is 100%, so there's no need for parameter details in the description. The baseline for this case is 4, as the description appropriately avoids redundant information and the schema fully covers the parameter aspect.

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 ('List') and resource ('available model collections on Replicate'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'list_models' or 'list_templates', which also list resources on Replicate, so it doesn't achieve full sibling differentiation.

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. With siblings like 'list_models', 'list_templates', and 'search_available_models', there's no indication of context, prerequisites, or exclusions for selecting this tool over others.

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

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/gerred/mcp-server-replicate'

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