Skip to main content
Glama
gerred

MCP Server Replicate

verify_webhook

Validate webhook requests from Replicate using HMAC-SHA256 to ensure authenticity and prevent unauthorized access to your system.

Instructions

Verify that a webhook request came from Replicate using HMAC-SHA256.

    Args:
        payload: The webhook payload to verify
        signature: The signature from the X-Replicate-Signature header
        secret: The webhook signing secret from get_webhook_secret

    Returns:
        True if signature is valid, False otherwise
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
payloadYes
signatureYes
secretYes

Implementation Reference

  • Core handler function for the 'verify_webhook' tool. Computes the expected HMAC-SHA256 signature from the serialized payload and secret, then compares it securely to the provided signature.
    @mcp.tool()
    def verify_webhook(payload: WebhookPayload, signature: str, secret: str) -> bool:
        """Verify that a webhook request came from Replicate using HMAC-SHA256.
    
        Args:
            payload: The webhook payload to verify
            signature: The signature from the X-Replicate-Signature header
            secret: The webhook signing secret from get_webhook_secret
    
        Returns:
            True if signature is valid, False otherwise
        """
        if not signature or not secret:
            return False
    
        # Convert payload to canonical JSON string
        payload_str = json.dumps(payload.model_dump(), sort_keys=True)
    
        # Calculate expected signature
        expected = hmac.new(secret.encode(), payload_str.encode(), hashlib.sha256).hexdigest()
    
        # Compare signatures using constant-time comparison
        return hmac.compare_digest(signature, expected)
  • Pydantic model defining the structure of the 'payload' input parameter for verify_webhook tool.
    class WebhookPayload(BaseModel):
        """The full payload of a webhook request."""
        event: WebhookEvent
        prediction: Dict[str, Any] = Field(..., description="Full prediction object at time of event") 
  • The @mcp.tool() decorator registers the verify_webhook function with the FastMCP server using the default name based on the function name.
    @mcp.tool()
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It explains the cryptographic verification process and return value (True/False), which is helpful. However, it doesn't mention error conditions, performance characteristics, or security implications beyond the basic verification logic.

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 perfectly structured and efficient: a clear purpose statement followed by well-organized Args and Returns sections. Every sentence earns its place by providing essential information without redundancy. The formatting with indentation enhances readability.

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

Completeness4/5

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

For a verification tool with 3 parameters and no output schema, the description provides excellent coverage of the tool's purpose, parameters, and return value. The main gap is the lack of error handling information, but given the tool's straightforward boolean return and the detailed parameter explanations, this is a minor omission.

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

Parameters5/5

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

The description adds significant value beyond the input schema, which has 0% description coverage. It clearly explains each parameter's purpose: 'payload' is the webhook payload to verify, 'signature' comes from the X-Replicate-Signature header, and 'secret' should be obtained from get_webhook_secret. This provides essential context not present in the schema.

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

Purpose5/5

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

The description clearly states the specific action ('verify that a webhook request came from Replicate') and the technical method used ('using HMAC-SHA256'). It distinguishes this tool from all sibling tools, which focus on predictions, models, collections, and webhook management rather than verification.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool (verifying webhook authenticity from Replicate) and references a related tool ('get_webhook_secret') for obtaining the secret parameter. However, it doesn't explicitly state when NOT to use it or name alternative verification methods.

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