@adcp/sdk API Reference - v7.9.0
    Preparing search index...

    Interface HandlerContext<TAccount>

    Context passed to every handler.

    If the tool has an account ref and resolveAccount is configured, account is the resolved account object (guaranteed non-null — the handler only runs if resolution succeeds).

    If resolveSessionKey is configured, sessionKey is the scoping key derived from the request — usually tenant/brand/publisher-account id. Handlers can pass it to scopedStore(ctx.store, ctx.sessionKey!) to get a session-scoped view that works on any AdcpStateStore implementation.

    interface HandlerContext<TAccount = unknown> {
        account?: TAccount;
        agent?: BuyerAgent;
        sessionKey?: string;
        store: AdcpStateStore;
        authInfo?: ResolvedAuthInfo;
        emitWebhook?: (params: WebhookEmitParams) => Promise<WebhookEmitResult>;
    }

    Type Parameters

    • TAccount = unknown
    Index

    Properties

    account?: TAccount
    agent?: BuyerAgent

    Resolved buyer agent for this request, populated by BuyerAgentRegistry when an agentRegistry is configured on the server (Phase 1 of #1269). Carries the durable commercial relationship — status, billing capabilities, default account terms — distinct from the per-request credential. Undefined when no registry is configured OR when the registry returned null for the request's credential.

    sessionKey?: string

    Session scoping key derived from the request. Populated when resolveSessionKey is configured.

    State store for persisting domain objects (media buys, accounts, creatives).

    authInfo?: ResolvedAuthInfo

    Authentication info for the caller, when ServeOptions.authenticate is configured. Populated from the MCP SDK's extra.authInfo, which serve() sets from the auth principal. Use this to enforce per-principal authorization in handlers.

    Stage 3 of #1269 added the kind-discriminated credential and the operator fields. The legacy token / clientId / scopes are preserved as optional fields through the deprecation cycle; new code should read credential and switch on its kind.

    Buyer-agent identity post-resolution is on ctx.agent (the resolved BuyerAgent record), NOT here — this surface only carries authentication information about the credential, not the registry lookup result.

    emitWebhook?: (params: WebhookEmitParams) => Promise<WebhookEmitResult>

    Emit a signed webhook to a buyer's push_notification_config.url. Populated when AdcpServerConfig.webhooks is configured. Handles RFC 9421 signing, stable idempotency_key across retries, and retry/backoff per adcp#2417 + adcp#2423 + adcp#2478.

    Typical call from inside a completion handler:

    await ctx.emitWebhook({
      url: push_notification_config.url,
      payload: { task: { task_id, status: 'completed', result } },
      operation_id: `create_media_buy.${media_buy_id}`,
    });