Negotiate one compact-first media-buy facade for this seller.
Compact tools are preferred when advertised. Established projections are selected before dispatch and expose exact provenance/loss metadata; the coordinator never switches mutation tools after a transport failure.
StaticfromCreate an AgentClient backed by a pre-connected MCP Client instead of
an HTTP endpoint. Useful for in-process compliance testing without spinning
up a loopback HTTP server.
MCP only. This factory wraps an MCP Client from
@modelcontextprotocol/sdk. There is no equivalent in-process bridge for
A2A today — for A2A agents, run them on a loopback HTTP server and use the
standard AgentClient constructor with the agent's agent_uri.
What this gives you over dispatchTestRequest:
All client-side pipeline stages still apply — idempotency key auto-injection,
request/response schema validation hooks, governance middleware, and the typed
TaskResult<T> discriminated-union response shape. None of these apply when
calling dispatchTestRequest() directly.
Usage:
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
import { AgentClient } from '@adcp/sdk';
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
const mcpClient = new Client({ name: 'test', version: '1.0.0' });
await Promise.all([
mcpClient.connect(clientTransport),
adcpServer.connect(serverTransport),
]);
const agent = AgentClient.fromMCPClient(mcpClient, {
validation: { requests: 'strict' },
});
const result = await agent.createMediaBuy({ ... });
Unsupported methods on in-process instances: resolveCanonicalUrl,
getWebhookUrl, registerWebhook, unregisterWebhook — these require HTTP
and will throw Error with a descriptive message. Use getAgentId() /
getAgentName() for identification instead.
An already-connected MCP Client (see example above).
Optional narrowed config. HTTP-only fields are excluded.
Handle webhook from agent (async task completion or notifications)
Webhook payload from agent
Task type (e.g create_media_buy) from url param or url part of the webhook delivery
Operation id (e.g used for client app to track the operation) from the param or url part of the webhook delivery
Optionalsignature: WebhookHeaderValueOptional signature for verification (X-ADCP-Signature)
Optionaltimestamp: WebhookHeaderValueOptional timestamp for verification (X-ADCP-Timestamp)
OptionalrawBody: string | Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike>Whether webhook was handled successfully
Verify and normalize an inbound webhook without dispatching handlers.
Create a trusted-route HTTP receiver for this specific agent.
Verify webhook signature using HMAC-SHA256 per AdCP spec.
Prefer passing the raw HTTP body string for correct cross-language interop. Passing a parsed object still works but re-serializes with JSON.stringify, which may not match the sender's byte representation.
Raw HTTP body string (preferred) or parsed payload object (deprecated)
X-ADCP-Signature header value (format: "sha256=...")
X-ADCP-Timestamp header value (Unix timestamp)
true if signature is valid
Discover available advertising products.
Response products expose only canonical format_options[], regardless of
the seller's negotiated wire version. The SDK performs any required legacy
translation below this public boundary.
Projection failures surface portably on result.data.errors[] and are
also mirrored on result.data.projection.diagnostics (structured
source: 'sdk' markers; codes mirror the spec's error-code
vocabulary plus three SDK-local codes — see the projection
module's ProjectionDiagnostic type for the full set).
Protocol tooling that must inspect raw seller emission uses the explicit
deprecated getProductsLegacy() method.
OptionalinputHandler: InputHandlerOptionaloptions: CanonicalProjectionTaskOptionsDiscover products through the compact AdCP 3.2 catalog task.
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsRequest one or more compact AdCP 3.2 proposals.
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsDecline outstanding proposals.
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsBuy explicit products through the compact AdCP 3.2 lifecycle.
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsAccept a proposal through the compact AdCP 3.2 lifecycle.
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsApply a compact lifecycle control to an existing media buy.
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsRecord a governance-plan adjustment with idempotent 3.2 semantics.
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsDeclaratively replace agent-anchored notification subscriptions.
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsRevise or atomically finalize compact AdCP proposals.
The SDK validates batch/cardinality rules and any explicit seller capability declaration before transport, and auto-generates the idempotency key when omitted.
OptionalinputHandler: InputHandlerOptionaloptions: ProposalRefinementTaskOptionsOptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsOptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsOptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsCreate a new media buy.
Discover canonical format_options[] with getProducts(), select a
format_option_id, and send only canonical package and creative fields.
Compatibility translation for an older seller happens below this method.
const { data: { products } } = await agent.getProducts({ brief: '...' });
const product = products[0];
const format = product.format_options[0];
await agent.createMediaBuy({
packages: [{
package_id: 'pkg-1',
product_id: product.product_id,
pricing_option_id: product.pricing_options[0].pricing_option_id,
format_option_refs: [{
scope: 'product',
format_option_id: format.format_option_id
}],
creatives: [{
creative_id: 'hero',
format_kind: format.format_kind,
format_option_ref: {
scope: 'product',
format_option_id: format.format_option_id
},
assets: { image: { url: 'https://cdn.example/hero.png' } }
}],
budget: { currency: 'USD', total: 5000 },
}],
// ...
});
Inline creative fallback. Sellers that do not advertise a creative
library (supportsSyncCreatives(await agent.getCapabilities()) === false)
can still accept package-scoped creative uploads when they advertise
caps.features.inlineCreativeManagement. Use
inlineCreativesForPackages(packages, creatives, { assignments }) to
project sync_creatives-style creative assets into create-media-buy
package payloads without rewriting a raw sync_creatives call. If using
assignments for create payloads, give each package a stable key such as
context.buyer_ref, or pass a custom packageId resolver.
Existing applications that still hold old named-format payloads must opt
into createMediaBuyLegacy() explicitly.
OptionalinputHandler: InputHandlerOptionaloptions: CreativeDeliveryTaskOptionsOptionalinputHandler: InputHandlerOptionaloptions: CreativeDeliveryTaskOptionsUpdate an existing media buy.
For sellers without a creative library but with
caps.features.inlineCreativeManagement, post-create creative replacement
can be represented as package-scoped inline packages[].creatives on this
request. Build the package patch with inlineCreativesForPackages() and
preflight it with preflightUpdateMediaBuy(currentBuy, patch) so
available_actions[] allows replace_creative before dispatch.
Use format_kind and format_option_ref for every creative in the patch;
the SDK handles any negotiated compatibility conversion.
OptionalinputHandler: InputHandlerOptionaloptions: CreativeDeliveryTaskOptionsOptionalinputHandler: InputHandlerOptionaloptions: CreativeDeliveryTaskOptionsSync creative assets into the seller's reusable creative library.
This is library-scoped: assignments can reference packages, but a raw
sync_creatives request does not contain enough media-buy context for the
SDK to safely rewrite it into inline package creatives. When the seller
lacks creative.has_creative_library but does advertise
media_buy.features.inline_creative_management, use
inlineCreativesForPackages() with explicit package/media-buy context and
send a separate create_media_buy or update_media_buy request with its
own idempotency key. If neither capability is advertised, creative upload
is not available through this SDK helper surface.
A sync request does not carry product declarations. When compatibility
translation needs seller selection metadata, pass
options.creativeFormatProjection.selectorContainers with the routed
package/product selectors. Assignments scope each creative to its package.
OptionalinputHandler: InputHandlerOptionaloptions: SyncCreativesTaskOptionsOptionalinputHandler: InputHandlerOptionaloptions: SyncCreativesTaskOptionsList creative assets
OptionalinputHandler: InputHandlerOptionaloptions: CanonicalProjectionTaskOptionsReturn the unprojected list_creatives wire response.
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsGet media buy status, creative approvals, and optional delivery snapshots
OptionalinputHandler: InputHandlerOptionaloptions: CanonicalReadTaskOptionsGet media buy delivery information
OptionalinputHandler: InputHandlerOptionaloptions: CanonicalReadTaskOptionsRetrieve canonical creative-level and variant-level delivery metrics.
OptionalinputHandler: InputHandlerOptionaloptions: CanonicalProjectionTaskOptionsProvide performance feedback
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsGet audience signals
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsActivate audience signals
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsGet AdCP capabilities (v3 tool call)
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsGet normalized capabilities with v2/v3 fallback
For v3 servers: calls get_adcp_capabilities tool For v2 servers: builds synthetic capabilities from tool list
Optionaloptions: Pick<TaskOptions, "signal" | "transport">Return the seller's declared adcp.idempotency.replay_ttl_seconds, or
throw when a v3 seller omits the (required) declaration.
Returns undefined for v2 agents — v2 pre-dates the idempotency envelope.
Assert that the seller's capabilities corroborate this client's pinned
AdCP major (per getAdcpVersion()). Throws VersionUnsupportedError
otherwise. Set ADCP_ALLOW_V2=1 to bypass.
Deprecated alias for requireSupportedMajor.
Preview a creative using canonical capability or creative-library identity.
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsOptionaladcp_version?: stringRelease-precision AdCP version (VERSION.RELEASE, e.g. "3.0", "3.1", "3.1-beta"). On a request: the buyer's release pin — the seller validates against its supported_versions and returns VERSION_UNSUPPORTED on cross-major mismatch, or downshifts to the highest supported release within the same major. On a response: the release the seller actually served — clients SHOULD validate the response against that release's schema, not against their pin. Patches are not negotiated; surface them as build_version on capabilities for operational visibility. When omitted, falls back to adcp_major_version (deprecated) or server default. Buyers SHOULD emit both adcp_version and adcp_major_version through 3.x to remain compatible with sellers that only read the legacy field. NORMALIZATION: SDKs that read full-semver values from bundle metadata (e.g. ComplianceIndex.published_version = "3.1.0-beta.1") MUST normalize to release-precision ("3.1-beta.1") before emitting on the wire — meta-field values are NOT valid wire values.
Optionaladcp_major_version?: numberDEPRECATED in favor of adcp_version (release-precision string). Servers MUST continue to honor this field through 3.x. Removed in 4.0. Original semantics: the AdCP major version the buyer's payloads conform to. Sellers validate against their supported major_versions and return VERSION_UNSUPPORTED if unsupported. When omitted, the seller assumes its highest supported version.
Preview mode. 'single' previews one creative manifest. 'batch' previews multiple creatives in one call. 'variant' replays a post-flight variant by ID.
Optionalcreative_manifest?: LegacyCreativeManifestOptionaltarget_capability_id?: stringCanonical preview-operation selector. Identifies one get_adcp_capabilities creative.supported_formats[].capability_id entry whose operations contains preview. In single mode it selects the renderer for this request; in batch mode it is the default for items that omit their own target_capability_id. When omitted, the agent MAY resolve the renderer only if exactly one advertised preview capability satisfies the manifest's canonical declaration; zero matches or multiple matches MUST be rejected with FORMAT_NOT_SUPPORTED rather than choosing nondeterministically. Mutually exclusive with deprecated format_id.
Optionalformat_id?: LegacyFormatReferenceStructuredObjectOptionalinputs?: {Array of input sets for generating multiple preview variants. Each input set defines macros and context values for one preview rendering. Used in single mode.
Optionaltemplate_id?: stringSpecific template ID for custom format rendering. Used in single mode.
Optionalquality?: CreativeQualityOptionaloutput_format?: PreviewOutputFormatOptionalitem_limit?: numberMaximum number of catalog items to render per preview variant. Used in single mode. Creative agents SHOULD default to a reasonable sample when omitted and the catalog is large.
Optionalrequests?: {Array of preview requests (1-50 items). Required when request_type is 'batch'. Each item follows the single request structure.
Optionalvariant_id?: stringPlatform-assigned variant identifier from get_creative_delivery response. Required when request_type is 'variant'.
Optionalcreative_id?: stringCreative-library identifier. In single mode, previews the stored canonical creative without requiring the caller to reconstruct its manifest. Also available as context in variant mode.
Optionalallow_async?: booleanOpt in to an asynchronous preview response. When true, the creative agent MAY return status 'submitted' with a task_id only when rendering has been handed to a queue or external renderer and will continue after the request connection is released. Active processing on an open connection uses working progress instead. The buyer polls get_task_status for completion. When false or absent, the agent MUST return a synchronous preview response or a terminal protocol error; it MUST NOT return the submitted shape. This field applies to preview_creative only; build_creative already defines its own async lifecycle.
Optionalpush_notification_config?: PushNotificationConfigOptionalcontext?: ContextObjectOptionalext?: ExtensionObjectOptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsOptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsList accounts
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsSync accounts
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsSync audiences
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsCreate a property list
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsGet a property list
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsUpdate a property list
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsList property lists
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsDelete a property list
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsList content standards
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsGet content standards
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsCalibrate content against standards
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsValidate content delivery
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsGet an SI offering
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsInitiate an SI session
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsSend a message in an SI session
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsTerminate an SI session
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsContinue the conversation with a natural language message
Natural language message to send to the agent
OptionalinputHandler: InputHandlerHandler for any clarification requests
Optionaloptions: TaskOptionsGet the full conversation history
Clear the conversation context (start fresh).
Equivalent to resetContext() — clears both the retained contextId
and any pending server-side taskId, and drops cached history.
Reset conversation state. Call with no args to start a fresh conversation; pass a seed to rehydrate a persisted session id (e.g., across a process restart).
Always clears the retained pending-task handle — a persisted contextId
places the next send into the same server-side session, but any old
taskId is stale.
Optionalseed: stringGet the current conversation context ID
Get the pending server-side taskId from the last non-terminal
response, if any. Populated when the server returned
input-required / working / submitted / auth-required;
cleared when the task reaches a terminal state.
Persist this alongside getContextId() if you need to resume a
specific task (not just a conversation) across a process restart.
Set a specific conversation context ID
Get the agent configuration
Get the agent ID
Get the agent name
Get the agent protocol
Get the canonical base URL for this agent
Returns the canonical URL if already resolved, or computes it synchronously. For guaranteed canonical URL (especially for A2A), use resolveCanonicalUrl() first.
Resolve and return the canonical base URL for this agent
For A2A: Fetches the agent card and uses its 'url' field For MCP: Performs endpoint discovery and strips /mcp suffix
Not supported on in-process instances (created via fromMCPClient).
Use getAgentId() / getAgentName() for identification instead.
Check if this agent is the same as another agent by canonical URL
Async version that resolves canonical URLs first for more accurate comparison
Get the fully resolved agent configuration with canonical URL
Get agent information including capabilities
Optionaloptions: Pick<TaskOptions, "signal" | "transport">Check if there's an active conversation
Get active tasks for this agent
Execute any ADCP task by name with full type safety
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptions// ✅ TYPE-SAFE: Automatic response type inference
const result = await agent.executeTask('get_products', params);
// result is TaskResult<CanonicalGetProductsResponse> - no casting needed!
// ✅ CUSTOM TYPES: For non-standard tasks
const customResult = await agent.executeCustomTask<MyCustomResponse>('custom_task', params);
Execute an extension task that is not part of the standard AdCP task set.
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsExplicit raw-task compatibility escape hatch for conformance and migration tooling.
OptionalinputHandler: InputHandlerOptionaloptions: TaskOptionsList all tasks for this agent
Get detailed information about a specific task
Subscribe to task notifications for this agent
Subscribe to all task events
Generate webhook URL for a specific task and operation.
Not supported on in-process instances (created via fromMCPClient).
In-process clients have no HTTP listener to receive webhook callbacks.
Register webhook for task notifications.
Not supported on in-process instances (created via fromMCPClient).
OptionaltaskTypes: string[]Unregister webhook notifications.
Not supported on in-process instances (created via fromMCPClient).
Returns the AdCP protocol version this client speaks. Mirrors
SingleAgentClient.getAdcpVersion(). See SingleAgentClientConfig.adcpVersion.