Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion examples/basic_mcp_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@

Usage:
python examples/basic_mcp_usage.py

Set SELLER_BASE_URL to use a server other than http://localhost:8000.
"""

import asyncio
import os

from ad_buyer.clients import Protocol, UnifiedClient

SELLER_BASE_URL = os.getenv("SELLER_BASE_URL", "http://localhost:8000")


async def main():
# MCP mode - direct tool calls (faster, deterministic)
async with UnifiedClient(protocol=Protocol.MCP) as client:
async with UnifiedClient(base_url=SELLER_BASE_URL, protocol=Protocol.MCP) as client:
# List available products
result = await client.list_products()
print(f"Products: {result.data}")
Expand Down
9 changes: 7 additions & 2 deletions examples/dsp_deal_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
cd ad_buyer_system
pip install -e .
python examples/dsp_deal_discovery.py

Set SELLER_BASE_URL to use a server other than http://localhost:8000.
"""

import asyncio
import os
import sys

SELLER_BASE_URL = os.getenv("SELLER_BASE_URL", "http://localhost:8000")

try:
from ad_buyer.clients.unified_client import UnifiedClient
from ad_buyer.models.buyer_identity import (
Expand Down Expand Up @@ -110,7 +115,7 @@ async def demo_dsp_workflow():
print(f" Premium Access: {buyer_context.can_access_premium_inventory()}")

# Connect to IAB Tech Lab server
async with UnifiedClient(buyer_identity=identity) as client:
async with UnifiedClient(base_url=SELLER_BASE_URL, buyer_identity=identity) as client:
print("\n" + "-" * 40)
print("Step 1: Discover Inventory")
print("-" * 40)
Expand Down Expand Up @@ -192,7 +197,7 @@ async def demo_unified_client_dsp_methods():
)

# Create client with identity
async with UnifiedClient(buyer_identity=identity) as client:
async with UnifiedClient(base_url=SELLER_BASE_URL, buyer_identity=identity) as client:
print(f"\nAccess Tier: {client.get_access_tier()}")

# Discover inventory
Expand Down
9 changes: 7 additions & 2 deletions examples/individual_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,25 @@

Usage:
python examples/individual_clients.py

Set SELLER_BASE_URL to use a server other than http://localhost:8000.
"""

import asyncio
import os

from ad_buyer.clients import A2AClient, IABMCPClient

SELLER_BASE_URL = os.getenv("SELLER_BASE_URL", "http://localhost:8000")


async def mcp_example():
"""Direct MCP client usage."""
print("=" * 50)
print("MCP Client - Direct Tool Access")
print("=" * 50)

async with IABMCPClient() as client:
async with IABMCPClient(base_url=SELLER_BASE_URL) as client:
# See all available tools
print(f"Available tools: {len(client.tools)}")
for tool in client.tools[:5]: # Show first 5
Expand All @@ -42,7 +47,7 @@ async def a2a_example():
print("A2A Client - Natural Language")
print("=" * 50)

async with A2AClient() as client:
async with A2AClient(base_url=SELLER_BASE_URL) as client:
# Send natural language messages
response = await client.send_message("List available products")
print(f"Response text: {response.text}")
Expand Down
7 changes: 6 additions & 1 deletion examples/natural_language_a2a.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@

Usage:
python examples/natural_language_a2a.py

Set SELLER_BASE_URL to use a server other than http://localhost:8000.
"""

import asyncio
import os

from ad_buyer.clients import Protocol, UnifiedClient

SELLER_BASE_URL = os.getenv("SELLER_BASE_URL", "http://localhost:8000")


async def main():
async with UnifiedClient(protocol=Protocol.A2A) as client:
async with UnifiedClient(base_url=SELLER_BASE_URL, protocol=Protocol.A2A) as client:
# Natural language queries
result = await client.send_natural_language(
"Find CTV inventory with household targeting under $30 CPM"
Expand Down
7 changes: 6 additions & 1 deletion examples/protocol_switching.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@

Usage:
python examples/protocol_switching.py

Set SELLER_BASE_URL to use a server other than http://localhost:8000.
"""

import asyncio
import os

from ad_buyer.clients import Protocol, UnifiedClient

SELLER_BASE_URL = os.getenv("SELLER_BASE_URL", "http://localhost:8000")


async def main():
async with UnifiedClient(protocol=Protocol.MCP) as client:
async with UnifiedClient(base_url=SELLER_BASE_URL, protocol=Protocol.MCP) as client:
# Connect to both protocols
await client.connect_both()
print("Connected to both MCP and A2A protocols")
Expand Down
Loading