Skip to main content
Glama

create_webhook

Set up automated notifications for repository events like pushes, pull requests, and comments by creating a webhook that triggers HTTP calls to a specified URL.

Instructions

Create a webhook for a repository.

Args:
    repo_slug: Repository slug
    url: URL to call when events occur
    events: List of events to trigger on. Common events:
            - repo:push (code pushed)
            - pullrequest:created, pullrequest:updated, pullrequest:merged
            - pullrequest:approved, pullrequest:unapproved
            - pullrequest:comment_created
    description: Webhook description (optional)
    active: Whether webhook is active (default: True)

Returns:
    Created webhook info with UUID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_slugYes
urlYes
eventsYes
descriptionNo
activeNo

Implementation Reference

  • MCP tool handler function 'create_webhook' decorated with @mcp.tool(). Calls BitbucketClient.create_webhook and formats the response.
    @mcp.tool()
    @handle_bitbucket_error
    @formatted
    def create_webhook(
        repo_slug: str,
        url: str,
        events: list,
        description: str = "",
        active: bool = True,
    ) -> dict:
        """Create a webhook for a repository.
    
        Args:
            repo_slug: Repository slug
            url: URL to call when events occur
            events: List of events to trigger on. Common events:
                    - repo:push (code pushed)
                    - pullrequest:created, pullrequest:updated, pullrequest:merged
                    - pullrequest:approved, pullrequest:unapproved
                    - pullrequest:comment_created
            description: Webhook description (optional)
            active: Whether webhook is active (default: True)
    
        Returns:
            Created webhook info with UUID
        """
        client = get_client()
        result = client.create_webhook(
            repo_slug=repo_slug,
            url=url,
            events=events,
            description=description,
            active=active,
        )
        return {
            "uuid": result.get("uuid"),
            "url": result.get("url"),
            "events": result.get("events"),
            "active": result.get("active"),
        }
  • BitbucketClient helper method that performs the actual API POST request to create the webhook.
    def create_webhook(
        self,
        repo_slug: str,
        url: str,
        events: list[str],
        description: str = "",
        active: bool = True,
    ) -> dict[str, Any]:
        """Create a webhook.
    
        Args:
            repo_slug: Repository slug
            url: Webhook URL to call
            events: List of events to trigger on
                    e.g., ["repo:push", "pullrequest:created", "pullrequest:merged"]
            description: Webhook description
            active: Whether webhook is active
    
        Returns:
            Created webhook info
        """
        payload = {
            "url": url,
            "events": events,
            "active": active,
        }
        if description:
            payload["description"] = description
    
        result = self._request(
            "POST",
            self._repo_path(repo_slug, "hooks"),
            json=payload,
        )
        return self._require_result(result, "create webhook")
  • Pydantic model WebhookSummary used for validating and formatting webhook data in list_webhooks and get_webhook tools.
    class WebhookSummary(BaseModel):
        """Webhook info for list responses."""
    
        uuid: str
        url: str
        description: str = ""
        events: list[str] = []
        active: bool = True
        created: Optional[str] = None
    
        @field_validator("created", mode="before")
        @classmethod
        def truncate_ts(cls, v: Any) -> Optional[str]:
            return truncate_timestamp(v)
    
        @classmethod
        def from_api(cls, data: dict) -> "WebhookSummary":
            return cls(
                uuid=data.get("uuid", ""),
                url=data.get("url", ""),
                description=data.get("description", ""),
                events=data.get("events", []),
                active=data.get("active", True),
                created=data.get("created_at"),
            )

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/JaviMaligno/mcp-server-bitbucket'

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