Skip to content

feat(webhooks)!: replace domain kwarg with typed protocol (AdcpProtocol enum)#637

Merged
bokelley merged 2 commits intomainfrom
claude/issue-607-followup-protocol-field
May 10, 2026
Merged

feat(webhooks)!: replace domain kwarg with typed protocol (AdcpProtocol enum)#637
bokelley merged 2 commits intomainfrom
claude/issue-607-followup-protocol-field

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

Follow-up to #632. The schema's mcp-webhook-payload.json defines a typed protocol field (AdcpProtocol enum: media-buy | signals | governance | creative | brand | sponsored-intelligence); the builder was instead accepting an undocumented domain string and stuffing it into the wire body via extra='allow'. The JS reference implementation (buildTaskWebhookPayload in from-platform.ts) sets payload.protocol and never sets domain — so the Python SDK was the outlier.

Summary

  • create_mcp_webhook_payload(..., domain=...)create_mcp_webhook_payload(..., protocol=...)
  • WebhookSender.send_mcp(..., domain=...)WebhookSender.send_mcp(..., protocol=...)
  • protocol accepts AdcpProtocol | str | None; unknown values raise ValidationError at construction.
  • AdcpProtocol is now publicly exported from adcp.types.

Why a clean break (no domain deprecation alias)

Cross-SDK alignment

Verified in adcontextprotocol/adcp-client (the JS SDK):

  • buildTaskWebhookPayload sets payload.protocol = protocolForTool(opts.tool) (same AdcpProtocol 6-value enum).
  • The closed 20-value TaskType is enforced as SPEC_WEBHOOK_TASK_TYPES at the emitTaskWebhook dispatch layer (skip-with-warning vs. our raise-at-construction — both spec-conformant; different surfaces).

Follow-up worth filing

The JS SDK auto-derives protocol from the tool name (protocolForTool(opts.tool)). Our Python builder leaves protocol as a manual kwarg. A future enhancement could mirror the JS behavior — caller passes only task_type, builder fills in protocol from a TaskType → AdcpProtocol mapping. Out of scope here; flagging.

BREAKING CHANGE: domain kwarg removed. Migrate to protocol.

Test plan

  • pytest tests/ — 4211 passed (added 1 new test for the protocol kwarg accepting enum/string and rejecting unknowns)
  • mypy src/adcp/ — clean
  • ruff + black — clean
  • public_api_snapshot.json regenerated to include AdcpProtocol
  • Cross-SDK enum source verified (Python's TaskType is auto-generated from schemas/cache/enums/task-type.json; same source the JS SPEC_WEBHOOK_TASK_TYPES derives from)

🤖 Generated with Claude Code

bokelley and others added 2 commits May 10, 2026 10:21
Follow-up to #632. The schema's `mcp-webhook-payload.json` defines a
typed `protocol` field (`AdcpProtocol` enum: `media-buy | signals |
governance | creative | brand | sponsored-intelligence`); the builder
was instead accepting an undocumented `domain` string and stuffing it
into the wire body via `extra='allow'`. The JS reference implementation
(`buildTaskWebhookPayload` in `from-platform.ts`) sets `payload.protocol`
and never sets `domain` — so the Python SDK was the outlier.

Replaces `create_mcp_webhook_payload(..., domain=...)` and
`WebhookSender.send_mcp(..., domain=...)` with `protocol=...`. The kwarg
accepts either an `AdcpProtocol` enum value or a kebab-case string;
unknown values raise `ValidationError` at construction. `AdcpProtocol`
is now publicly exported from `adcp.types`.

Zero in-repo callers passed `domain=`; verified by grep before the swap.
The kwarg was added in #632's same migration window so the breaking-
change cycle is bundled.

BREAKING CHANGE: `domain` kwarg removed from `create_mcp_webhook_payload`
and `WebhookSender.send_mcp`. Migrate to `protocol` (kebab-case string
or `AdcpProtocol` enum value).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Caller now passes only `task_type` and the builder fills `protocol`
from the canonical `TaskType` → `AdcpProtocol` mapping. Mirrors
`protocolForTool` in `adcontextprotocol/adcp-client:src/lib/server/
decisioning/runtime/protocol-for-tool.ts` so cross-SDK webhook bodies
classify operations identically.

The mapping covers all 20 spec values; explicit `protocol=` passed by
the caller still wins.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bokelley bokelley merged commit fdd4053 into main May 10, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant