Skip to content

Commit f9432a3

Browse files
bokelleyclaude
andauthored
feat: add missing AdCP protocol methods to CLI and client (#71)
* feat: add list_tools command to CLI dispatch table Adds support for the list_tools protocol introspection command in the CLI. Previously, list_tools was available as a client method but was not exposed through the CLI tool dispatch system. Changes: - Add list_tools to TOOL_DISPATCH table in __main__.py - Handle list_tools specially since it takes no parameters and returns list[str] - Fix TaskResult success field to be False when status is FAILED - Add comprehensive tests for list_tools dispatch and invalid tool names Fixes issue where CLI did not expose the list_tools introspection method that is available on the ADCPClient class. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: add missing AdCP protocol methods to client and CLI Adds four missing AdCP protocol methods that had schemas but were not implemented in the Python client: - preview_creative (existed in client, now added to CLI) - create_media_buy (new to both client and CLI) - update_media_buy (new to both client and CLI) - build_creative (new to both client and CLI) Changes: - Add missing request/response type imports to client.py - Implement create_media_buy, update_media_buy, build_creative in ADCPClient - Add abstract methods to base protocol adapter - Implement methods in MCP and A2A adapters - Add all four tools to CLI TOOL_DISPATCH table with lazy type initialization All 14 AdCP protocol tools are now fully supported in both the client API and CLI interface. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: trigger CI after PR title fix * test: add coverage for new protocol methods - Add assertions for preview_creative, create_media_buy, update_media_buy, build_creative in test_all_client_methods - Document that complex schema methods are tested separately - Ensures all 4 new client methods are verified to exist Addresses code review feedback on test coverage. * docs: enhance docstrings for media buy and creative methods - Add detailed contextual descriptions for create_media_buy, update_media_buy, and build_creative - Include comprehensive parameter explanations with field breakdowns - Add usage examples demonstrating typical patterns - Document response structure and expected data fields - Explain discriminated union usage in update_media_buy Improves developer experience by providing clear guidance on when and how to use these protocol methods. * docs: add comprehensive workflow examples to README - Add 'Workflow Examples' section demonstrating end-to-end usage - Document complete media buy workflow (discovery → create → update) - Document complete creative workflow (list formats → preview → build) - Show integrated multi-agent workflow combining both - Reorganize 'Available Tools' section to group Creative Management methods - Include code examples with clear step-by-step comments Makes it easier for developers to understand typical usage patterns and how different protocol methods work together in real-world scenarios. * fix: update types for schema changes in media buy responses The upstream AdCP schemas changed: - create_media_buy_response and update_media_buy_response now use the canonical Package type instead of defining custom types - get_signals and activate_signal changed 'destinations' field to 'deployments' - New schema types: asset-content-type, format-category Changes: - Remove obsolete AffectedPackage type (replaced by canonical Package) - Remove obsolete CreatedPackageReference alias (schema now uses full Package everywhere) - Update type imports in stable.py, __init__.py, and aliases.py - Regenerate types from latest schemas - Update test data to use 'deployments' instead of 'destinations' - Update package alias tests to reflect unified Package type All 297 tests passing. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0b81324 commit f9432a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+768
-371
lines changed

README.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,12 +466,183 @@ All AdCP tools with full type safety:
466466
- `list_creatives()` - List creative assets
467467
- `get_media_buy_delivery()` - Get delivery performance
468468

469+
**Creative Management:**
470+
- `preview_creative()` - Preview creative before building
471+
- `build_creative()` - Generate production-ready creative assets
472+
469473
**Audience & Targeting:**
470474
- `list_authorized_properties()` - Get authorized properties
471475
- `get_signals()` - Get audience signals
472476
- `activate_signal()` - Activate audience signals
473477
- `provide_performance_feedback()` - Send performance feedback
474478

479+
## Workflow Examples
480+
481+
### Complete Media Buy Workflow
482+
483+
A typical media buy workflow involves discovering products, creating the buy, and managing creatives:
484+
485+
```python
486+
from adcp import ADCPClient, AgentConfig, GetProductsRequest, CreateMediaBuyRequest
487+
from adcp import BrandManifest, PublisherPropertiesAll
488+
489+
# 1. Connect to agent
490+
config = AgentConfig(id="sales_agent", agent_uri="https://...", protocol="mcp")
491+
async with ADCPClient(config) as client:
492+
493+
# 2. Discover available products
494+
products_result = await client.get_products(
495+
GetProductsRequest(brief="Premium video inventory for coffee brand")
496+
)
497+
498+
if products_result.success:
499+
product = products_result.data.products[0]
500+
print(f"Found product: {product.name}")
501+
502+
# 3. Create media buy reservation
503+
media_buy_result = await client.create_media_buy(
504+
CreateMediaBuyRequest(
505+
brand_manifest=BrandManifest(
506+
name="Coffee Co",
507+
brand_url="https://coffeeco.com",
508+
logo_url="https://coffeeco.com/logo.png",
509+
# ... additional brand details
510+
),
511+
packages=[{
512+
"package_id": product.packages[0].package_id,
513+
"quantity": 1000000 # impressions
514+
}],
515+
publisher_properties=PublisherPropertiesAll(
516+
selection_type="all" # Target all authorized properties
517+
)
518+
)
519+
)
520+
521+
if media_buy_result.success:
522+
media_buy_id = media_buy_result.data.media_buy_id
523+
print(f"✅ Media buy created: {media_buy_id}")
524+
525+
# 4. Update media buy if needed
526+
from adcp import UpdateMediaBuyPackagesRequest
527+
528+
update_result = await client.update_media_buy(
529+
UpdateMediaBuyPackagesRequest(
530+
media_buy_id=media_buy_id,
531+
packages=[{
532+
"package_id": product.packages[0].package_id,
533+
"quantity": 1500000 # Increase budget
534+
}]
535+
)
536+
)
537+
538+
if update_result.success:
539+
print("✅ Media buy updated")
540+
```
541+
542+
### Complete Creative Workflow
543+
544+
Build and deliver production-ready creatives:
545+
546+
```python
547+
from adcp import ADCPClient, AgentConfig
548+
from adcp import PreviewCreativeFormatRequest, BuildCreativeRequest
549+
from adcp import CreativeManifest, PlatformDeployment
550+
551+
# 1. Connect to creative agent
552+
config = AgentConfig(id="creative_agent", agent_uri="https://...", protocol="mcp")
553+
async with ADCPClient(config) as client:
554+
555+
# 2. List available formats
556+
formats_result = await client.list_creative_formats()
557+
558+
if formats_result.success:
559+
format_id = formats_result.data.formats[0].format_id
560+
print(f"Using format: {format_id.id}")
561+
562+
# 3. Preview creative (test before building)
563+
preview_result = await client.preview_creative(
564+
PreviewCreativeFormatRequest(
565+
target_format_id=format_id.id,
566+
inputs={
567+
"headline": "Fresh Coffee Daily",
568+
"cta": "Order Now"
569+
},
570+
output_format="url" # Get preview URL
571+
)
572+
)
573+
574+
if preview_result.success:
575+
preview_url = preview_result.data.renders[0].url
576+
print(f"Preview at: {preview_url}")
577+
578+
# 4. Build production creative
579+
build_result = await client.build_creative(
580+
BuildCreativeRequest(
581+
manifest=CreativeManifest(
582+
format_id=format_id,
583+
brand_url="https://coffeeco.com",
584+
# ... creative content
585+
),
586+
target_format_id=format_id.id,
587+
deployment=PlatformDeployment(
588+
type="platform",
589+
platform_id="google_admanager"
590+
)
591+
)
592+
)
593+
594+
if build_result.success:
595+
vast_url = build_result.data.assets[0].url
596+
print(f"✅ Creative ready: {vast_url}")
597+
```
598+
599+
### Integrated Workflow: Media Buy + Creatives
600+
601+
Combine both workflows for a complete campaign setup:
602+
603+
```python
604+
from adcp import ADCPMultiAgentClient, AgentConfig
605+
from adcp import GetProductsRequest, CreateMediaBuyRequest, BuildCreativeRequest
606+
607+
# Connect to both sales and creative agents
608+
async with ADCPMultiAgentClient(
609+
agents=[
610+
AgentConfig(id="sales", agent_uri="https://sales-agent.com", protocol="mcp"),
611+
AgentConfig(id="creative", agent_uri="https://creative-agent.com", protocol="mcp"),
612+
]
613+
) as client:
614+
615+
# 1. Get products from sales agent
616+
sales_agent = client.agent("sales")
617+
products = await sales_agent.simple.get_products(
618+
brief="Premium video inventory"
619+
)
620+
621+
# 2. Get creative formats from creative agent
622+
creative_agent = client.agent("creative")
623+
formats = await creative_agent.simple.list_creative_formats()
624+
625+
# 3. Build creative asset
626+
creative_result = await creative_agent.build_creative(
627+
BuildCreativeRequest(
628+
manifest=creative_manifest,
629+
target_format_id=formats.formats[0].format_id.id
630+
)
631+
)
632+
633+
# 4. Create media buy with creative
634+
media_buy_result = await sales_agent.create_media_buy(
635+
CreateMediaBuyRequest(
636+
brand_manifest=brand_manifest,
637+
packages=[{"package_id": products.products[0].packages[0].package_id}],
638+
publisher_properties=publisher_properties,
639+
creative_urls=[creative_result.data.assets[0].url]
640+
)
641+
)
642+
643+
print(f"✅ Campaign live: {media_buy_result.data.media_buy_id}")
644+
```
645+
475646
## Property Discovery (AdCP v2.2.0)
476647

477648
Build agent registries by discovering properties agents can sell:

0 commit comments

Comments
 (0)