adcp 1.0.4__py3-none-any.whl → 1.0.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
adcp/__init__.py CHANGED
@@ -46,7 +46,7 @@ from adcp.types.generated import (
46
46
  UpdateMediaBuyResponse,
47
47
  )
48
48
 
49
- __version__ = "1.0.4"
49
+ __version__ = "1.0.5"
50
50
 
51
51
  __all__ = [
52
52
  # Client classes
adcp/__main__.py CHANGED
@@ -23,37 +23,38 @@ from adcp.types.core import AgentConfig, Protocol
23
23
 
24
24
  def print_json(data: Any) -> None:
25
25
  """Print data as JSON."""
26
- print(json.dumps(data, indent=2, default=str))
26
+ from pydantic import BaseModel
27
+
28
+ # Handle Pydantic models
29
+ if isinstance(data, BaseModel):
30
+ print(data.model_dump_json(indent=2, exclude_none=True))
31
+ else:
32
+ print(json.dumps(data, indent=2, default=str))
27
33
 
28
34
 
29
35
  def print_result(result: Any, json_output: bool = False) -> None:
30
36
  """Print result in formatted or JSON mode."""
31
37
  if json_output:
32
- print_json(
33
- {
34
- "status": result.status.value,
35
- "success": result.success,
36
- "data": result.data,
37
- "error": result.error,
38
- "metadata": result.metadata,
39
- "debug_info": (
40
- {
41
- "request": result.debug_info.request,
42
- "response": result.debug_info.response,
43
- "duration_ms": result.debug_info.duration_ms,
44
- }
45
- if result.debug_info
46
- else None
47
- ),
48
- }
49
- )
38
+ # Match JavaScript client: output just the data for scripting
39
+ if result.success and result.data:
40
+ print_json(result.data)
41
+ else:
42
+ # On error, output error info
43
+ print_json({"error": result.error, "success": False})
50
44
  else:
51
- print(f"\nStatus: {result.status.value}")
45
+ # Pretty output with message and data (like JavaScript client)
52
46
  if result.success:
47
+ print("\nSUCCESS\n")
48
+ # Show protocol message if available
49
+ if hasattr(result, "message") and result.message:
50
+ print("Protocol Message:")
51
+ print(result.message)
52
+ print()
53
53
  if result.data:
54
- print("\nResult:")
54
+ print("Response:")
55
55
  print_json(result.data)
56
56
  else:
57
+ print("\nFAILED\n")
57
58
  print(f"Error: {result.error}")
58
59
 
59
60
 
adcp/protocols/base.py CHANGED
@@ -49,6 +49,7 @@ class ProtocolAdapter(ABC):
49
49
  return TaskResult[T](
50
50
  status=raw_result.status,
51
51
  data=None,
52
+ message=raw_result.message,
52
53
  success=False,
53
54
  error=raw_result.error or "No data returned from adapter",
54
55
  metadata=raw_result.metadata,
@@ -66,6 +67,7 @@ class ProtocolAdapter(ABC):
66
67
  return TaskResult[T](
67
68
  status=raw_result.status,
68
69
  data=parsed_data,
70
+ message=raw_result.message, # Preserve human-readable message from protocol
69
71
  success=raw_result.success,
70
72
  error=raw_result.error,
71
73
  metadata=raw_result.metadata,
@@ -76,6 +78,7 @@ class ProtocolAdapter(ABC):
76
78
  return TaskResult[T](
77
79
  status=TaskStatus.FAILED,
78
80
  error=f"Failed to parse response: {e}",
81
+ message=raw_result.message,
79
82
  success=False,
80
83
  debug_info=raw_result.debug_info,
81
84
  )
adcp/protocols/mcp.py CHANGED
@@ -239,25 +239,49 @@ class MCPAdapter(ProtocolAdapter):
239
239
  # Call the tool using MCP client session
240
240
  result = await session.call_tool(tool_name, params)
241
241
 
242
- # Serialize MCP SDK types to plain dicts at protocol boundary
243
- serialized_content = self._serialize_mcp_content(result.content)
242
+ # This SDK requires MCP tools to return structuredContent
243
+ # The content field may contain human-readable messages but the actual
244
+ # response data must be in structuredContent
245
+ if not hasattr(result, "structuredContent") or result.structuredContent is None:
246
+ raise ValueError(
247
+ f"MCP tool {tool_name} did not return structuredContent. "
248
+ f"This SDK requires MCP tools to provide structured responses. "
249
+ f"Got content: {result.content if hasattr(result, 'content') else 'none'}"
250
+ )
251
+
252
+ # Extract the structured data (required)
253
+ data_to_return = result.structuredContent
254
+
255
+ # Extract human-readable message from content (optional)
256
+ # This is typically a status message like "Found 42 creative formats"
257
+ message_text = None
258
+ if hasattr(result, "content") and result.content:
259
+ # Serialize content using the same method used for backward compatibility
260
+ serialized_content = self._serialize_mcp_content(result.content)
261
+ if isinstance(serialized_content, list):
262
+ for item in serialized_content:
263
+ is_text = isinstance(item, dict) and item.get("type") == "text"
264
+ if is_text and item.get("text"):
265
+ message_text = item["text"]
266
+ break
244
267
 
245
268
  if self.agent_config.debug and start_time:
246
269
  duration_ms = (time.time() - start_time) * 1000
247
270
  debug_info = DebugInfo(
248
271
  request=debug_request,
249
272
  response={
250
- "content": serialized_content,
273
+ "data": data_to_return,
274
+ "message": message_text,
251
275
  "is_error": result.isError if hasattr(result, "isError") else False,
252
276
  },
253
277
  duration_ms=duration_ms,
254
278
  )
255
279
 
256
- # MCP tool results contain a list of content items
257
- # For AdCP, we expect the data in the content
280
+ # Return both the structured data and the human-readable message
258
281
  return TaskResult[Any](
259
282
  status=TaskStatus.COMPLETED,
260
- data=serialized_content,
283
+ data=data_to_return,
284
+ message=message_text,
261
285
  success=True,
262
286
  debug_info=debug_info,
263
287
  )
adcp/types/core.py CHANGED
@@ -127,6 +127,7 @@ class TaskResult(BaseModel, Generic[T]):
127
127
 
128
128
  status: TaskStatus
129
129
  data: T | None = None
130
+ message: str | None = None # Human-readable message from agent (e.g., MCP content text)
130
131
  submitted: SubmittedInfo | None = None
131
132
  needs_input: NeedsInputInfo | None = None
132
133
  error: str | None = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: adcp
3
- Version: 1.0.4
3
+ Version: 1.0.5
4
4
  Summary: Official Python client for the Ad Context Protocol (AdCP)
5
5
  Author-email: AdCP Community <maintainers@adcontextprotocol.org>
6
6
  License: Apache-2.0
@@ -1,22 +1,22 @@
1
- adcp/__init__.py,sha256=3ARviLlJxnjYaDMIRFLceNsaES6z9ft81qKRYeq6Eq4,2512
2
- adcp/__main__.py,sha256=4rjwH3i52Dsy-Pb0hw5hapQuEG8-bW2tTKKB0HsVsSs,12716
1
+ adcp/__init__.py,sha256=e7jeHMFSk_DxjaIWgRGqCR3A0fTOKtE-sMgulASLCWM,2512
2
+ adcp/__main__.py,sha256=Avy_C71rruh2lOuojvuXDj09tkFOaek74nJ-dbx25Sw,12838
3
3
  adcp/client.py,sha256=iIZUy5j25H48gGYlR_VuVsB9zP6SF1HtRssdPs2VJkc,24232
4
4
  adcp/config.py,sha256=Vsy7ZPOI8G3fB_i5Nk-CHbC7wdasCUWuKlos0fwA0kY,2017
5
5
  adcp/exceptions.py,sha256=dNRMKV23DlkGKyB9Xmt6MtlhvDu1crjzD_en4nAEwDY,4399
6
6
  adcp/protocols/__init__.py,sha256=6UFwACQ0QadBUzy17wUROHqsJDp8ztPW2jzyl53Zh_g,262
7
7
  adcp/protocols/a2a.py,sha256=TN26ac98h2NUZTTs39Tyd6pVoS3k-sASuLKhLpdYV-A,12255
8
- adcp/protocols/base.py,sha256=Tdxg1hefWVDvRP7q3yYbtPlIfUr01luPG0oT773qi30,4906
9
- adcp/protocols/mcp.py,sha256=JNJdouaDQ66H9pUtsaZtV8FWoLGf28QM29tOLESDxsk,14664
8
+ adcp/protocols/base.py,sha256=CGqUilQv_ymhnfdowBV_HJhIxYUDM3sRO7ahW-kRB0M,5087
9
+ adcp/protocols/mcp.py,sha256=iQTr5QkZbUj42cc_ca7esvcV4EgcOpI8IT6akut9-UA,16028
10
10
  adcp/types/__init__.py,sha256=3E_TJUXqQQFcjmSZZSPLwqBP3s_ijsH2LDeuOU-MP30,402
11
- adcp/types/core.py,sha256=w6CLD2K0riAHUnrktYmQV7qnkO-6Ab4-CN67YSagAE4,4731
11
+ adcp/types/core.py,sha256=BO6188PI8lIiVjpiSR0pmsCuXq3Tg9KlkHC5N2fXFxw,4824
12
12
  adcp/types/generated.py,sha256=KoILEa5Gg0tsjMYoqDEWulKvPzS0333L3qj75AHr4yI,50855
13
13
  adcp/types/tasks.py,sha256=Ae9TSwG2F7oWXTcl4TvLhAzinbQkHNGF1Pc0q8RMNNM,23424
14
14
  adcp/utils/__init__.py,sha256=uetvSJB19CjQbtwEYZiTnumJG11GsafQmXm5eR3hL7E,153
15
15
  adcp/utils/operation_id.py,sha256=wQX9Bb5epXzRq23xoeYPTqzu5yLuhshg7lKJZihcM2k,294
16
16
  adcp/utils/response_parser.py,sha256=NQTLlbvmnM_tE4B5w3oB1Wshny1p-Uh8IWbghlwoNJc,4057
17
- adcp-1.0.4.dist-info/licenses/LICENSE,sha256=PF39NR3Ae8PLgBhg3Uxw6ju7iGVIf8hfv9LRWQdii_U,629
18
- adcp-1.0.4.dist-info/METADATA,sha256=ahZm1ty9AJ28PK5cC5_lrjkXPacgO3-3VMYn5ncfzJ4,12724
19
- adcp-1.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
- adcp-1.0.4.dist-info/entry_points.txt,sha256=DQKpcGsJX8DtVI_SGApQ7tNvqUB4zkTLaTAEpFgmi3U,44
21
- adcp-1.0.4.dist-info/top_level.txt,sha256=T1_NF0GefncFU9v_k56oDwKSJREyCqIM8lAwNZf0EOs,5
22
- adcp-1.0.4.dist-info/RECORD,,
17
+ adcp-1.0.5.dist-info/licenses/LICENSE,sha256=PF39NR3Ae8PLgBhg3Uxw6ju7iGVIf8hfv9LRWQdii_U,629
18
+ adcp-1.0.5.dist-info/METADATA,sha256=pmJWpMYNFVbyME-LpWm_Q9xFe3adBpivni17xNE2yaY,12724
19
+ adcp-1.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
+ adcp-1.0.5.dist-info/entry_points.txt,sha256=DQKpcGsJX8DtVI_SGApQ7tNvqUB4zkTLaTAEpFgmi3U,44
21
+ adcp-1.0.5.dist-info/top_level.txt,sha256=T1_NF0GefncFU9v_k56oDwKSJREyCqIM8lAwNZf0EOs,5
22
+ adcp-1.0.5.dist-info/RECORD,,
File without changes