Skip to main content
Glama
gerred

MCP Server Replicate

get_prediction

Retrieve the status and results of AI model predictions from the Replicate API. Use this tool to monitor inference progress and access generated outputs.

Instructions

Get the status and results of a prediction.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
prediction_idYes
waitNo
max_retriesNo

Implementation Reference

  • The main asynchronous handler function that executes the get_prediction tool. It retrieves the prediction status from the ReplicateClient and constructs a Prediction object.
    async def get_prediction(prediction_id: str) -> Prediction:
        """Get the current status and results of a prediction.
        
        Args:
            prediction_id: The ID of the prediction to retrieve
            
        Returns:
            Prediction object containing the current status and results
            
        Raises:
            RuntimeError: If the Replicate client fails to initialize
            ValueError: If the prediction is not found
            Exception: If the status check fails
        """
        async with ReplicateClient() as client:
            result = client.get_prediction_status(prediction_id)
            return Prediction(**result)
  • The @mcp.tool decorator that registers the get_prediction function as an MCP tool with the specified name and description.
    @mcp.tool(
        name="get_prediction",
        description="Get the current status and results of a prediction.",
    )
  • Pydantic BaseModel defining the output schema for the get_prediction tool response.
    class Prediction(BaseModel):
        """A prediction (model run) on Replicate."""
        id: str = Field(..., description="Unique identifier for this prediction")
        version: str = Field(..., description="Model version used for this prediction")
        status: PredictionStatus = Field(..., description="Current status of the prediction")
        input: Dict[str, Any] = Field(..., description="Input parameters used for the prediction")
        output: Optional[Any] = Field(None, description="Output from the prediction if completed")
        error: Optional[str] = Field(None, description="Error message if prediction failed")
        logs: Optional[str] = Field(None, description="Execution logs from the prediction")
        created_at: datetime
        started_at: Optional[datetime] = None
        completed_at: Optional[datetime] = None
        urls: Dict[str, str] = Field(..., description="Related API URLs for this prediction")
        metrics: Optional[Dict[str, float]] = Field(None, description="Performance metrics if available")
        stream_url: Optional[str] = Field(None, description="URL for streaming output if requested") 
  • Helper method in ReplicateClient that fetches and formats the raw prediction data from the Replicate API, used by the get_prediction tool.
    def get_prediction_status(self, prediction_id: str) -> dict[str, Any]:
        """Get the status of a prediction.
    
        Args:
            prediction_id: ID of the prediction to check
    
        Returns:
            Dict containing current status and output of the prediction
    
        Raises:
            ValueError: If the prediction is not found
            Exception: If the API request fails
        """
        if not self.client:
            raise RuntimeError("Client not initialized. Check error property for details.")
    
        try:
            # Get prediction
            prediction = self.client.predictions.get(prediction_id)
            if not prediction:
                raise ValueError(f"Prediction not found: {prediction_id}")
    
            # Return prediction status and output
            return {
                "id": prediction.id,
                "status": prediction.status,
                "output": prediction.output,
                "error": prediction.error,
                "created_at": prediction.created_at.isoformat() if prediction.created_at else None,
                "started_at": prediction.started_at.isoformat() if prediction.started_at else None,
                "completed_at": prediction.completed_at.isoformat() if prediction.completed_at else None,
                "urls": prediction.urls,
                "metrics": prediction.metrics,
            }
    
        except ValueError as err:
            logger.error(f"Validation error: {str(err)}")
            raise
        except Exception as err:
            logger.error(f"Failed to get prediction status: {str(err)}")
            raise Exception(f"Failed to get prediction status: {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 mentions 'status and results' and implies a retrieval operation, but doesn't describe key behaviors: whether it's idempotent, if it polls or waits (hinted by 'wait' parameter but not explained), error handling, or response format. For a tool with parameters like 'wait' and 'max_retries', this is a significant gap in transparency.

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 a single, efficient sentence that states the core purpose without unnecessary words. It's appropriately sized for a simple tool, though it could be more informative. The structure is front-loaded with the main action, but it lacks elaboration that might be needed given the tool's complexity.

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 has 3 parameters (with 0% schema coverage), no annotations, and no output schema, the description is incomplete. It doesn't explain the retrieval process, handle potential states (e.g., pending, completed), or detail the results format. For a prediction status tool, this leaves critical gaps in understanding how to use it effectively.

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?

Schema description coverage is 0%, so the schema provides no parameter descriptions. The description adds no information about the three parameters (prediction_id, wait, max_retries) beyond what's inferred from their names. It doesn't explain what prediction_id refers to, how wait affects behavior, or what max_retries controls. This fails to compensate for the low schema coverage.

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

Purpose3/5

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

The description states the tool's purpose ('Get the status and results of a prediction'), which is clear but vague. It specifies the verb 'Get' and resource 'prediction', but doesn't distinguish it from siblings like 'create_prediction' or 'cancel_prediction' beyond the basic action. The purpose is understandable but lacks specificity about what kind of prediction or context.

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., needing a prediction_id from create_prediction), exclusions, or comparisons to siblings like cancel_prediction. Without such context, an agent might struggle to select this tool appropriately in a workflow.

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