diff --git a/examples/basic_mcp_usage.py b/examples/basic_mcp_usage.py index 0534fba9..a9d66609 100644 --- a/examples/basic_mcp_usage.py +++ b/examples/basic_mcp_usage.py @@ -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}") diff --git a/examples/dsp_deal_discovery.py b/examples/dsp_deal_discovery.py index 42761d84..018dc416 100644 --- a/examples/dsp_deal_discovery.py +++ b/examples/dsp_deal_discovery.py @@ -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 ( @@ -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) @@ -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 diff --git a/examples/individual_clients.py b/examples/individual_clients.py index 1872f67b..52f08c9b 100644 --- a/examples/individual_clients.py +++ b/examples/individual_clients.py @@ -9,12 +9,17 @@ 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.""" @@ -22,7 +27,7 @@ async def mcp_example(): 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 @@ -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}") diff --git a/examples/natural_language_a2a.py b/examples/natural_language_a2a.py index f01b35ac..69349a2f 100644 --- a/examples/natural_language_a2a.py +++ b/examples/natural_language_a2a.py @@ -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" diff --git a/examples/protocol_switching.py b/examples/protocol_switching.py index 55c74961..ccc19bb0 100644 --- a/examples/protocol_switching.py +++ b/examples/protocol_switching.py @@ -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")