Testing AdCP via MCP
You can test AdCP tasks using the CLI tools or by chatting with Addie, the AgenticAdvertising.org assistant.Tool Call Patterns
Basic Tool Invocation
Tool Call with Filters
Tool Call with Application-Level Context
MCP Response Format
Normative: AdCP MCP responses use a flat structure — envelope fields (status, context_id, context, task_id, timestamp, replayed, adcp_error, governance_context) and task-body fields appear as siblings at the root of the tool response. The payload object defined on core/protocol-envelope.json is a documentary grouping construct, NOT a serialized wire key: body fields are NOT nested under a payload: key on MCP. This matches MCP’s native structuredContent convention.
payload: key is non-conformant — receivers parse from the flat root, and a nested representation breaks every shipping SDK.
Receiver rule. MCP tool consumers MUST parse envelope and body fields from the flat root of the tool response. Receivers MUST NOT require a nested payload: key; the schema’s payload is documentation, not a wire requirement. When status is absent on the response (legacy or transport-native state carrier), receivers MUST default to completed for non-error responses and inspect adcp_error for error envelopes.
context_id vs context — semantically orthogonal.
context_idis a server-managed session identifier for tracking related operations across multiple tool invocations. The server issues it; the caller MAY echo it on subsequent calls to thread a session. Distinct from MCP’s transport-level session.contextis a caller-supplied opaque echo object (core/context.json) — the agent preserves it byte-for-byte without parsing. Used for buyer-side correlation (UI session IDs, trace IDs, custom metadata).- Both MAY appear on the same response. They are NOT aliases.
Available Tools
All AdCP tasks are available as MCP tools:Protocol Tools
Media Buy Tools
Signals Tools
Async Operations via MCP Tasks
AdCP uses MCP Tasks for long-running operations over MCP. This removes the LLM from the polling path — the client handles task lifecycle at the protocol level, and the model only sees the final result. :::warning Client support is limited Most chat-based MCP clients (Claude Desktop, Cursor) do not yet support MCP Tasks. If your client doesn’t support task-augmented tool calls, use webhooks or polling viatasks/get instead — these work with any MCP client. See Async Operations and Push Notifications for transport-independent patterns.
MCP Tasks are the right choice when you control the MCP client (e.g., building your own orchestrator with @modelcontextprotocol/sdk) or when client support matures.
:::
SDK Implementation
If you use the@modelcontextprotocol/sdk package, MCP Tasks support requires minimal code. Pass an InMemoryTaskStore (or your own TaskStore implementation) to the Server constructor — the SDK auto-registers handlers for tasks/get, tasks/result, tasks/list, and tasks/cancel:
tools/call handler, check for the task field and use the store:
_meta injection for tasks/result responses. InMemoryTaskStore is non-persistent — for production, implement a TaskStore backed by your database.
If you use McpServer instead of Server, register task-capable tools with server.experimental.tasks.registerToolTask() — the higher-level API enforces this for tools that declare taskSupport.
:::warning Production task isolation
InMemoryTaskStore does not scope tasks by session — any client that knows a task ID can read, cancel, or list it. For production, implement a TaskStore that filters by sessionId on every operation. Also clamp client-provided TTL values server-side and enforce rate limits on task creation.
:::
Server Capabilities
AdCP MCP servers declaretasks in their capabilities:
Tool-Level Task Support
Each tool declares whether it supports task-augmented execution viaexecution.taskSupport:
| Tool | taskSupport | Rationale |
|---|---|---|
get_products | optional | Complex searches, HITL clarification |
create_media_buy | optional | External systems, approval workflows |
update_media_buy | optional | External system updates |
build_creative | optional | Human creative review, long production renders |
sync_creatives | optional | Asset processing and transcoding |
get_signals | optional | Complex audience discovery |
activate_signal | optional | Platform deployment |
sync_plans | optional | Governance plan processing |
check_governance | optional | External policy evaluation |
report_plan_outcome | optional | External system updates |
acquire_rights | optional | Approval workflows |
update_rights | optional | External updates |
get_rights | optional | External lookups |
get_adcp_capabilities | forbidden | Instant, static |
list_creative_formats | forbidden | Instant catalog lookup |
preview_creative | forbidden | Renders existing manifest |
list_creatives | forbidden | Session state lookup |
get_media_buys | forbidden | Session state lookup |
get_media_buy_delivery | forbidden | Session state lookup |
get_creative_delivery | forbidden | Session state lookup |
get_plan_audit_logs | forbidden | Session state lookup |
get_brand_identity | forbidden | Instant lookup |
taskSupport: "optional" can be called either way:
- Without
taskfield: Synchronous — returns the result directly - With
taskfield: Returns aCreateTaskResultimmediately; poll viatasks/get, retrieve the result viatasks/result
Invoking a Tool as a Task
Include thetask field in your tools/call request:
tasks/get (respecting pollInterval) until the task reaches a terminal state (completed, failed, or cancelled), then retrieves the CallToolResult via tasks/result. To abort a running task, send tasks/cancel with the taskId.
AdCP Status Mapping
AdCP uses a richer set of statuses than MCP Tasks. When serving over MCP, AdCP statuses map to MCP Task statuses:| AdCP Status | MCP Task Status | Notes |
|---|---|---|
working | working | Direct mapping |
submitted | working | Use statusMessage to indicate queued state |
input-required | input_required | Server moves task to input_required, sends elicitation via tasks/result |
completed | completed | Direct mapping |
failed | failed | Direct mapping |
rejected | failed | Use statusMessage for rejection reason |
canceled | cancelled | Spelling difference (AdCP uses American, MCP uses British) |
auth-required | input_required | Elicitation requests credentials |
Webhooks for Long-Lived Operations
MCP Tasks handles polling within the MCP session, but some AdCP operations outlive a single session (e.g., a media buy that takes 24 hours for publisher approval). For these, combine MCP Tasks withpush_notification_config:
Context Management (MCP-Specific)
Critical: MCP requires manual context management. You must passcontext_id to maintain conversation state.
Context Session Pattern
Usage Examples
Basic Session with Context
Async Operations with MCP Tasks
For tools withtaskSupport: "optional", pass the task option to use MCP Tasks:
operation_id (and task_type) from the payload body, not by parsing the webhook URL. Buyers MAY embed operation_id in the URL path or query for their own server-side routing convenience (the URL structure is opaque to the seller and entirely buyer-defined), but the seller never parses that URL — the seller echoes the buyer-supplied operation_id it was given at registration, and the wire-level source of truth for correlation is the payload field. See mcp-webhook-payload.json and Webhooks — Operation IDs.
The result field contains the AdCP data payload. For completed/failed statuses, this is the full task response (e.g., create-media-buy-response.json). For other statuses, use the status-specific schemas (e.g., create-media-buy-async-response-working.json).
MCP Webhook Envelope Fields
Themcp-webhook-payload.json envelope includes:
Required fields:
idempotency_key— Per-fire transport dedup key (see schema for full semantics)operation_id— Buyer-supplied correlation identifier echoed verbatim by the seller. Receivers use this — not the URL path — to route notifications to the originating task. Sellers MUST NOT derive this by parsing the URL; the URL structure is implementation-defined from the seller’s point of view.task_id— Unique task identifier for correlationtask_type— Task name (e.g.,create_media_buy,sync_creatives) for routing to per-task handlersstatus— Current task status (completed, failed, working, input-required, etc.)timestamp— ISO 8601 timestamp when webhook was generated
notification_id— Event-layer stable id for re-emission tracking (see schema)protocol— AdCP protocol family (media-buyorsignals)context_id— Conversation/session identifiermessage— Human-readable context about the status change
result— Task-specific AdCP payload (see Data Schema Validation below)
Webhook Trigger Rules
Webhooks are sent when all of these conditions are met:- Task type supports async (e.g.,
create_media_buy,sync_creatives,get_products) pushNotificationConfigis provided in the request- Task runs asynchronously — initial response is
workingorsubmitted
completed, failed, rejected), no webhook is sent—you already have the result.
Status changes that trigger webhooks:
working→ Progress update (task actively processing)input-required→ Human input neededcompleted→ Final result availablefailed→ Error details
Data Schema Validation
Theresult field in MCP webhooks uses status-specific schemas:
| Status | Schema | Contents |
|---|---|---|
completed | [task]-response.json | Full task response (success branch) |
failed | [task]-response.json | Full task response (error branch) |
working | [task]-async-response-working.json | Progress info (percentage, step) |
input-required | [task]-async-response-input-required.json | Requirements, approval data |
submitted | [task]-async-response-submitted.json | Acknowledgment (usually minimal) |
async-response-data.json
Webhook Handler Example
Task Management and Polling
Context Expiration Handling
Handling Async Operations
When a task returnsworking or submitted status, you need a way to receive the result. This applies whether or not your MCP client supports MCP Tasks — the patterns below work with any client.
| Approach | Best For | Trade-offs |
|---|---|---|
| Webhooks | Production systems, any task duration | Handles hours/days, but requires a public endpoint |
| Polling | Simple integrations, short tasks | Easy to implement, but inefficient for long waits |
| MCP Tasks | Custom clients using the MCP SDK | Protocol-native, but requires client support |
Option 1: Webhooks (recommended)
Configure a webhook URL and the server will POST the result when the operation completes. This is the right approach forsubmitted operations that are blocked on external dependencies (publisher approval, human review).
Option 2: Polling (backup)
Usetasks/get as a backup for submitted operations, or when you can’t expose a webhook endpoint:
Handling different statuses
Integration Example
MCP-Specific Considerations
Server-side tool wrappers MUST tolerate envelope fields
Buyer SDKs send envelope-level fields (idempotency_key, context_id, context, governance_context, push_notification_config) uniformly across all AdCP tool calls — including read-only tools that don’t consume them. MCP tool implementations MUST accept these fields and ignore the ones they don’t use; they MUST NOT reject a call because an envelope field is present. Common traps:
- FastMCP / Pydantic strict signatures — declare
idempotency_key: str | None = None(and the other envelope fields) as accept-and-ignore optionals, or use**kwargsto swallow unknowns.model_config = ConfigDict(extra='allow')on input models if you control them. - Zod / valibot with
.strict()on input schemas — drop.strict()or use a passthrough variant. - OpenAPI codegen that injects
additionalProperties: falseinto input models — fix the generator config; the spec’s request schemas declareadditionalProperties: true.
unexpected_keyword_argument on idempotency_key will fail compliance against any buyer SDK that follows the envelope contract. See security.mdx > Server-side tool wrapper conformance for the normative rule.
Tool Discovery
AdCP Extension via MCP Server Card
Recommended: Use
get_adcp_capabilities for runtime capability discovery. The server card extension provides static metadata for tool catalogs and registries./.well-known/mcp.json (or /.well-known/server.json). AdCP-specific metadata goes in the _meta field using the adcontextprotocol.org namespace.
- Clients can discover AdCP capabilities without making test calls
- Declare which protocol domains you implement (media_buy, creative, signals)
- Declare which typed extensions you support (see Context & Sessions)
- Enable compatibility checks based on version
adcp_version field in server card metadata is a v2 convention and is not part of the v3 spec. For v3 version negotiation, the buyer sends release-precision adcp_version (e.g., "3.1") on every request, and the seller advertises supported releases via adcp.supported_versions on get_adcp_capabilities and echoes adcp_version at the envelope root on every response. The legacy integer-only adcp_major_version field is still accepted for backwards compatibility. See versioning.mdx § Version negotiation for the full contract.
:::
Note: The _meta field uses reverse DNS namespacing per the MCP server.json spec. AdCP servers should support both /.well-known/mcp.json and /.well-known/server.json locations.
Parameter Validation
Error Handling
AdCP errors are returned as tool-level responses withisError: true and the error in structuredContent.adcp_error. For the full extraction logic and JSON-RPC transport codes, see Transport Error Mapping.
Best Practices
- Use session wrapper for automatic context management
- Check status field before processing response data
- Handle context expiration gracefully with retries
- Reference Core Concepts for status handling patterns
- Validate parameters using MCP tool schemas when available
Next Steps
- Core Concepts: Read Task Lifecycle for status handling and workflows
- Task Reference: See Media Buy Tasks and Signals
- Protocol Comparison: Compare with A2A integration
- Examples: Find complete workflow examples in Core Concepts