> ## Documentation Index
> Fetch the complete documentation index at: https://docs.webhook.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Drive an AI agent from an endpoint's webhooks

> Subscribe an agent to an endpoint over MCP, then run a loop that acts on verified events at a cadence your agent sets.

Turn an inbound webhook into an agent action. The agent subscribes to an endpoint over MCP and polls `triggers.wait`, which hands back every event past its cursor with the body inline — acting only on events whose signature you verified.

<Note>
  The loop is yours to run. `triggers.wait` returns immediately with whatever is already past your
  cursor, so how quickly your agent reacts is set by how often it calls — nothing is pushed to it.
</Note>

<Steps>
  <Step title="Create an endpoint and verify its source">
    Register the provider secret so the agent can trust what it acts on. An event that fails verification should never drive a tool call.

    ```sh theme={null}
    wbhk endpoints create github-agent
    wbhk endpoints add-provider-secret <endpoint-id> --provider github
    ```
  </Step>

  <Step title="Create a trigger over MCP">
    From your agent's MCP client, call `triggers.create` with the endpoint id. It returns a `triggerId` and creates no outbound egress — it only consumes events you can already read.

    ```json theme={null}
    // tool: triggers.create
    { "endpointId": "<endpoint-id>", "name": "issue-triage" }
    ```
  </Step>

  <Step title="Loop on triggers.wait">
    `triggers.wait` is a short-poll: it returns events past your cursor (with an inline body), then you pass the returned `nextCursor` back to continue. Delivery is at least once, acked by cursor — so make the agent's action idempotent.

    ```json theme={null}
    // tool: triggers.wait  (repeat, threading nextCursor)
    { "triggerId": "<trigger-id>", "cursor": "<nextCursor>" }
    ```

    Gate the action on `verificationState`: act on `verified` / `authenticated`, skip `unattempted`, never on `failed`.
  </Step>
</Steps>

For the full agent loop, ack semantics, and inline-body caps, see [agent triggers](/mcp/agent-triggers).
