StaticfromCreate client by auto-discovering agent configuration
Automatically loads agents from:
Optionalconfig: SingleAgentClientConfigOptional client configuration
ADCPMultiAgentClient instance with discovered agents
StaticfromCreate client from environment variables only
Optionalconfig: SingleAgentClientConfigOptional client configuration
ADCPMultiAgentClient instance with environment-loaded agents
StaticfromCreate client from a specific config file
OptionalconfigPath: stringPath to configuration file
Optionalconfig: SingleAgentClientConfigOptional client configuration
ADCPMultiAgentClient instance with file-loaded agents
StaticsimpleCreate a simple client with minimal configuration
Single agent URL
Optional agent and client configuration
ADCPMultiAgentClient instance with single agent
Get a single agent client for individual operations.
This is the primary method for executing operations on a specific agent. Returns an AgentClient instance that provides all AdCP operations.
The unique identifier of the agent to retrieve
Agent client instance for the specified agent
const client = new ADCPMultiAgentClient([
{ id: 'sales_agent', agent_uri: 'https://sales.example.com', protocol: 'a2a' }
]);
// Get specific agent and execute operation
const agent = client.agent('sales_agent');
const result = await agent.getProducts({ brief: 'Premium coffee brands' });
AgentClient for available operations
Get multiple specific agents for parallel operations.
Returns an AgentCollection that executes operations across the specified agents in parallel using Promise.all(). Useful when you want to query specific agents simultaneously and compare results.
Array of agent IDs to include in the collection
Agent collection for parallel operations across specified agents
// Execute across specific agents
const results = await client.agents(['sales_agent_1', 'sales_agent_2']).getProducts({
brief: 'Premium coffee brands'
});
// Process parallel results
results.forEach((result, i) => {
if (result.status === 'completed') {
console.log(`Agent ${i + 1}: ${result.data.products.length} products`);
}
});
AgentCollection for available parallel operations
Get all configured agents for broadcast operations.
Returns an AgentCollection containing all agents in the client configuration. Executes operations across all agents in parallel, useful for market research, price comparison, or discovering capabilities across your entire agent network.
Agent collection for parallel operations across all configured agents
const client = new ADCPMultiAgentClient([
{ id: 'agent1', agent_uri: 'https://agent1.com', protocol: 'a2a' },
{ id: 'agent2', agent_uri: 'https://agent2.com', protocol: 'mcp' },
{ id: 'agent3', agent_uri: 'https://agent3.com', protocol: 'a2a' }
]);
// Query all agents simultaneously
const allResults = await client.allAgents().getProducts({
brief: 'Premium coffee brands'
});
// Find best options across all agents
const successfulResults = allResults.filter(r => r.status === 'completed');
console.log(`Got products from ${successfulResults.length} agents`);
AgentCollection for available parallel operations
Add an agent to the client
Agent configuration to add
Remove an agent from the client
ID of agent to remove
True if agent was removed, false if not found
Get individual agent client by ID
ID of agent to retrieve
AgentClient instance
Check if an agent exists
Get all configured agent IDs
Get all agent configurations
Filter agents by protocol
Find agents that support a specific task This is a placeholder - in a full implementation, you'd query agent capabilities
Get all active tasks across all agents
Get tasks for specific agents
Array of agent IDs to get tasks for
Promise resolving to array of tasks from specified agents
Get task information by ID from any agent
ID of the task to find
Promise resolving to task information or null if not found
Subscribe to task events from all agents
Event callbacks for different task events
Unsubscribe function that removes all subscriptions
Subscribe to task updates from all agents
Function to call when any task status changes
Unsubscribe function
Register webhooks for all agents
Base webhook URL (will append agent ID)
OptionaltaskTypes: string[]Optional array of task types to watch
Unregister webhooks for all agents
Generate webhook URL for a specific agent, task type, and operation
ID of the agent
Type of task (e.g., 'get_products', 'media_buy_delivery')
Operation ID for this request
Full webhook URL with macros replaced
Handle webhook from any agent (async task completion or notifications)
Automatically routes webhook to the correct agent based on agent_id in payload.
Webhook payload from agent (must contain agent_id or operation_id)
Optionalsignature: stringOptional signature for verification (X-ADCP-Signature)
Optionaltimestamp: string | numberOptional timestamp for verification (X-ADCP-Timestamp)
OptionaltaskType: stringWhether webhook was handled successfully
app.post('/webhook', async (req, res) => {
const signature = req.headers['x-adcp-signature'];
const timestamp = req.headers['x-adcp-timestamp'];
try {
const handled = await client.handleWebhook(req.body, signature, timestamp);
res.status(200).json({ received: handled });
} catch (error) {
res.status(401).json({ error: error.message });
}
});
Create a creative agent client
URL of the creative agent
Protocol to use (defaults to 'mcp')
OptionalauthToken: stringOptional authentication token
CreativeAgentClient instance
Get the standard AdCP creative agent
Protocol to use (defaults to 'mcp')
CreativeAgentClient instance for standard agent
Discover creative formats from standard creative agent
Convenience method to quickly get formats from the standard AdCP creative agent
Promise resolving to array of creative formats
Find creative formats by type
Format type to filter by
Promise resolving to matching formats
Find creative formats by dimensions
Width in pixels
Height in pixels
Promise resolving to matching formats
Main multi-agent AdCP client providing unified access to multiple advertising protocol agents.
This is the primary entry point for the @adcp/client library. It provides flexible access patterns for working with one or multiple AdCP agents (MCP or A2A protocols).
Key Features
agent(id)- for individual operationsagents([ids])- for parallel execution across specific agentsallAgents()- for parallel execution across all configured agentsfromConfig(),fromEnv(),fromFile())Basic Usage
Example: Single agent operation
Example: Multi-agent parallel execution
Example: Auto-configuration from environment
Available Operations
All standard AdCP operations are available:
getProducts()- Discover advertising productslistCreativeFormats()- Get supported creative formatscreateMediaBuy()- Create new media buyupdateMediaBuy()- Update existing media buysyncCreatives()- Upload/sync creative assetslistCreatives()- List creative assetsgetMediaBuyDelivery()- Get delivery performancelistAuthorizedProperties()- Get authorized propertiesgetSignals()- Get audience signalsactivateSignal()- Activate audience signalsprovidePerformanceFeedback()- Send performance feedbackSee