get_webhook_secret
Retrieve the signing secret to verify webhook requests from Replicate API, ensuring secure validation of incoming notifications for image generation workflows.
Instructions
Get the signing secret for verifying webhook requests.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The primary MCP tool handler for 'get_webhook_secret'. Registers the tool and implements the logic by calling the ReplicateClient's get_webhook_secret method.@mcp.tool() async def get_webhook_secret() -> str: """Get the signing secret for verifying webhook requests.""" async with ReplicateClient(api_token=os.getenv("REPLICATE_API_TOKEN")) as client: return await client.get_webhook_secret()
- The ReplicateClient helper method that performs the actual HTTP GET request to /webhooks/default/secret to retrieve the webhook signing secret.async def get_webhook_secret(self) -> str: """Get the signing secret for the default webhook endpoint. This secret is used to verify that webhook requests are coming from Replicate. Returns: The webhook signing secret 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("/webhooks/default/secret") response.raise_for_status() data = response.json() return data["key"] except httpx.HTTPError as err: logger.error(f"HTTP error getting webhook secret: {str(err)}") raise Exception(f"Failed to get webhook secret: {str(err)}") from err except Exception as err: logger.error(f"Failed to get webhook secret: {str(err)}") raise Exception(f"Failed to get webhook secret: {str(err)}") from err
- Stub/placeholder handler in webhook_tools.py (possibly unused or alternative implementation). Raises NotImplementedError.@mcp.tool( name="get_webhook_secret", description="Get the signing secret for verifying webhook requests.", ) async def get_webhook_secret() -> str: """Get webhook signing secret.""" raise NotImplementedError