The Mock Adapter is a fully functional in-memory ad server adapter included with the Prebid Sales Agent for testing, development, and demonstration purposes. It implements the complete AdServerAdapter interface without requiring any external ad server, making it the fastest way to explore and validate Sales Agent functionality.
The adapter is identified by adapter_name: "mock" and is implemented at src/adapters/mock_ad_server.py.
The Mock Adapter is appropriate for:
docker compose up. No additional configuration is needed to get started.
The MockConnectionConfig accepts a single setting:
| Setting | Type | Default | Description |
|---|---|---|---|
dry_run |
boolean | false |
When true, all operations are validated but no state is persisted |
The MockProductConfig controls how the mock adapter simulates delivery for products:
| Setting | Type | Default | Description |
|---|---|---|---|
daily_impressions |
integer | Varies | Simulated daily impression volume |
fill_rate |
float | Varies | Simulated fill rate (0.0 to 1.0) |
ctr |
float | Varies | Simulated click-through rate |
viewability |
float | Varies | Simulated viewability percentage |
scenario |
string | null |
Named simulation scenario (e.g., "high_performance", "slow_start") |
dry_run in the JSONB config field:{
"dry_run": false
}
The Mock Adapter supports all major channels for comprehensive testing:
| Channel | Description |
|---|---|
display |
Standard banner and display ads |
olv |
Online video advertising |
streaming_audio |
Audio and streaming audio ads |
social |
Social media advertising |
The Mock Adapter responds to special HTTP headers that control simulation behavior. Pass these headers in your API, MCP, or A2A requests to exercise specific scenarios.
| Header | Value | Description |
|---|---|---|
X-Dry-Run |
true / false |
Test operations without persisting side effects. The adapter validates inputs and returns realistic responses but does not create or modify any state. |
X-Mock-Time |
ISO 8601 datetime (e.g., 2025-01-15T14:30:00Z) |
Set the simulated current time. Useful for testing delivery progression, flight dates, and time-dependent logic without waiting for real time to pass. |
X-Jump-To-Event |
Event name (e.g., "mid_flight", "end_of_campaign") |
Skip the simulation forward to a specific campaign event. The adapter advances delivery metrics to match the requested event state. |
X-Test-Session-ID |
Unique string | Isolate test execution by scoping all mock state to the given session ID. Different session IDs see independent state, enabling parallel test execution. |
X-Auto-Advance |
true / false |
Automatically progress campaign events over successive requests. Each call to get_media_buy_delivery advances the simulation by one time step. |
X-Force-Error |
Error type (e.g., "timeout", "auth_failure", "rate_limit") |
Force the adapter to simulate a specific error condition. Useful for testing error handling and recovery logic in AI buying agents. |
# Create a media buy
uvx adcp http://localhost:8000/mcp/ --auth test-token create_media_buy \
--product-id prod-001 --budget 10000
# Jump to mid-flight and check delivery
uvx adcp http://localhost:8000/mcp/ --auth test-token get_media_buy_delivery \
--media-buy-id mb-001 \
--header "X-Jump-To-Event: mid_flight"
# Force a timeout error to test error handling
uvx adcp http://localhost:8000/mcp/ --auth test-token get_media_buy_delivery \
--media-buy-id mb-001 \
--header "X-Force-Error: timeout"
The Mock Adapter includes a delivery simulator that produces realistic mock delivery data over time. Rather than returning static values, delivery metrics progress naturally based on the product configuration and campaign parameters.
MockProductConfig (daily impressions, fill rate, CTR, viewability).X-Mock-Time), the simulator calculates accumulated impressions, clicks, and spend._simulate_time_progression() method advances the internal clock and updates metrics accordingly.The adapter provides two methods for controlling simulation state:
_is_simulation() — Returns true when the adapter is running in simulation mode (the default). In simulation mode, delivery data is generated algorithmically.set_simulation_time() — Programmatically set the simulation clock, equivalent to passing the X-Mock-Time header.The Mock Adapter supports a strategy system that applies multipliers to simulated delivery metrics, enabling testing of different performance scenarios.
Set the scenario field in MockProductConfig or use the _get_simulation_scenario() method to activate predefined scenarios:
The _apply_strategy_multipliers() method adjusts base delivery metrics according to the active strategy context. This allows testing how AI buying agents respond to different campaign performance patterns.
The uvx adcp CLI tool is the fastest way to interact with the Mock Adapter during development:
# Discover available tools
uvx adcp http://localhost:8000/mcp/ --auth test-token list_tools
# Browse products
uvx adcp http://localhost:8000/mcp/ --auth test-token get_products
# Create a media buy
uvx adcp http://localhost:8000/mcp/ --auth test-token create_media_buy \
--product-id prod-001 --budget 5000 --start-date 2025-02-01 --end-date 2025-02-28
# Check delivery with auto-advance
uvx adcp http://localhost:8000/mcp/ --auth test-token get_media_buy_delivery \
--media-buy-id mb-001 \
--header "X-Auto-Advance: true"
The Mock Adapter is designed for use in automated test suites. The Sales Agent’s test infrastructure uses it extensively.
Use the X-Test-Session-ID header to isolate test state between parallel test executions:
import httpx
async def test_media_buy_creation():
headers = {
"x-adcp-auth": "test-token",
"X-Test-Session-ID": "test-run-abc123"
}
async with httpx.AsyncClient() as client:
response = await client.post(
"http://localhost:8000/api/v1/media-buys",
json={"product_id": "prod-001", "budget": 5000},
headers=headers
)
assert response.status_code == 201
Use X-Force-Error to test error handling paths:
async def test_timeout_recovery():
headers = {
"x-adcp-auth": "test-token",
"X-Force-Error": "timeout"
}
async with httpx.AsyncClient() as client:
response = await client.get(
"http://localhost:8000/api/v1/media-buys/mb-001/delivery",
headers=headers
)
assert response.status_code == 504
Enable dry run mode to validate request payloads without creating any state:
async def test_media_buy_validation():
headers = {
"x-adcp-auth": "test-token",
"X-Dry-Run": "true"
}
async with httpx.AsyncClient() as client:
response = await client.post(
"http://localhost:8000/api/v1/media-buys",
json={"product_id": "prod-001", "budget": -100},
headers=headers
)
# Validation error returned without creating anything
assert response.status_code == 422
When you are ready to move from the Mock Adapter to a production ad server, the transition is straightforward: