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"),
            )
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses that the tool creates a webhook (implying a write operation) and returns created webhook info with UUID, which adds some behavioral context. However, it lacks details on permissions needed, rate limits, error conditions, or whether the operation is idempotent, leaving gaps for a mutation tool.

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 well-structured with a clear purpose statement followed by Args and Returns sections. It's appropriately sized with no redundant information. Minor deduction because the events list could be slightly more concise, but overall it's efficient and front-loaded.

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?

Given no annotations and no output schema, the description does a good job explaining parameters and return value. It covers the core functionality adequately for a creation tool. However, it lacks some contextual details like authentication requirements or error handling, preventing a perfect score.

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?

Schema description coverage is 0%, so the description must compensate. It provides clear semantics for all 5 parameters: repo_slug, url, events (with examples), description (optional), and active (default). This adds significant value beyond the bare schema, explaining usage and common event types.

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 verb 'create' and resource 'webhook for a repository', making the purpose specific and unambiguous. It distinguishes from sibling tools like 'delete_webhook' and 'list_webhooks' by focusing on creation rather than deletion or listing.

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., repository access), compare with similar tools (e.g., 'update_user_permission' for other configurations), or specify when webhook creation is appropriate versus other notification 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/JaviMaligno/mcp-server-bitbucket'

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