Skip to main content
Glama
gerred

MCP Server Replicate

list_models

Discover available AI models on Replicate for image generation and inference tasks. Filter results by owner to find specific models for your project needs.

Instructions

List available models on Replicate with optional filtering by owner.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerNo

Implementation Reference

  • The main asynchronous handler function that implements the core logic of the 'list_models' tool. It uses ReplicateClient to fetch models filtered by owner and converts the result to a typed ModelList response.
    async def list_models(owner: Optional[str] = None) -> ModelList:
        """List available models on Replicate.
        
        Args:
            owner: Optional owner username to filter models by
            
        Returns:
            ModelList containing the available models and pagination info
            
        Raises:
            RuntimeError: If the Replicate client fails to initialize
            Exception: If the API request fails
        """
        async with ReplicateClient() as client:
            result = client.list_models(owner=owner)
            return ModelList(
                models=[Model(**model) for model in result["models"]],
                next_cursor=result.get("next_cursor"),
                total_count=result.get("total_models")
            )
  • The FastMCP decorator that registers the 'list_models' function as a tool with the specified name and description.
    @mcp.tool(
        name="list_models",
        description="List available models on Replicate with optional filtering by owner.",
    )
  • Pydantic schema defining the output structure of the list_models tool, consisting of a list of Model objects with pagination information.
    class ModelList(BaseModel):
        """Response format for listing models."""
        models: List[Model]
        next_cursor: Optional[str] = None
        total_count: Optional[int] = None 
  • Supporting method in ReplicateClient that performs the actual API call to list models, formats the response, and handles pagination and owner filtering. Called directly by the tool handler.
    def list_models(self, owner: str | None = None, cursor: str | None = None) -> dict[str, Any]:
        """List available models on Replicate with pagination.
    
        Args:
            owner: Optional owner username to filter models
            cursor: Pagination cursor from previous response
    
        Returns:
            Dict containing models list, next cursor, and total count
    
        Raises:
            Exception: If the API request fails
        """
        if not self.client:
            raise RuntimeError("Client not initialized. Check error property for details.")
    
        try:
            # Build params dict only including cursor if provided
            params = {}
            if cursor:
                params["cursor"] = cursor
            
            # Get models collection with pagination
            models = self.client.models.list(**params)
    
            # Get pagination info
            next_cursor = models.next_cursor if hasattr(models, "next_cursor") else None
            total_models = models.total if hasattr(models, "total") else None
    
            # Filter by owner if specified
            if owner:
                models = [m for m in models if m.owner == owner]
    
            # Format models with complete structure
            formatted_models = []
            for model in models:
                model_data = {
                    "id": f"{model.owner}/{model.name}",
                    "owner": model.owner,
                    "name": model.name,
                    "description": model.description,
                    "visibility": model.visibility,
                    "github_url": getattr(model, "github_url", None),
                    "paper_url": getattr(model, "paper_url", None),
                    "license_url": getattr(model, "license_url", None),
                    "run_count": getattr(model, "run_count", None),
                    "cover_image_url": getattr(model, "cover_image_url", None),
                    "default_example": getattr(model, "default_example", None),
                    "featured": getattr(model, "featured", None),
                    "tags": getattr(model, "tags", []),
                }
    
                # Add latest version info if available
                if model.latest_version:
                    model_data["latest_version"] = {
                        "id": model.latest_version.id,
                        "created_at": model.latest_version.created_at,
                        "cog_version": model.latest_version.cog_version,
                        "openapi_schema": model.latest_version.openapi_schema,
                        "model": f"{model.owner}/{model.name}",
                        "replicate_version": getattr(model.latest_version, "replicate_version", None),
                        "hardware": getattr(model.latest_version, "hardware", None),
                    }
    
                formatted_models.append(model_data)
    
            return {
                "models": formatted_models,
                "next_cursor": next_cursor,
                "total_count": total_models,
            }
    
        except Exception as err:
            logger.error(f"Failed to list models: {str(err)}")
            raise Exception(f"Failed to list models: {str(err)}") from err
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 the tool lists models with optional filtering, but it does not cover important aspects such as pagination, rate limits, authentication requirements, or what the output format looks like. This leaves significant gaps in understanding how the tool behaves in practice.

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 and key feature (filtering by owner). It is front-loaded with no unnecessary words, making it highly concise and well-structured for quick understanding.

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 lack of annotations and output schema, the description is incomplete. It does not address behavioral traits like pagination or error handling, and while it mentions filtering, it does not explain the return values or any limitations. For a tool with no structured support, more context is needed to be fully helpful.

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?

The description adds meaning by specifying that the 'owner' parameter is for 'optional filtering', which clarifies its purpose beyond the schema's title 'Owner'. However, with 0% schema description coverage and only one parameter, the description provides basic context but does not fully compensate for the lack of detailed schema documentation, aligning with the baseline for minimal param info.

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 models on Replicate'), making the purpose specific and understandable. However, it does not explicitly distinguish this tool from sibling tools like 'search_available_models' or 'search_models', which might offer similar functionality, so it falls short of a perfect score.

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 mentions 'optional filtering by owner', which provides some implied context for usage, but it does not offer explicit guidance on when to use this tool versus alternatives like 'search_available_models' or 'search_models'. No exclusions or detailed scenarios are provided, resulting in minimal guidance.

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