@@ -60,7 +60,7 @@ async def test_get_mcp_toolset_adds_destination_id(
6060 ),
6161 "interfaces" : [{
6262 "url" : "https://mcp.com" ,
63- "protocolBinding" : A2ATransport . jsonrpc ,
63+ "protocolBinding" : "JSONRPC" ,
6464 }],
6565 }
6666 mock_httpx .return_value .__enter__ .return_value .get .return_value = (
@@ -126,7 +126,7 @@ async def test_get_mcp_toolset_handles_missing_destination_id(
126126 # "mcpServerId" is intentionally omitted
127127 "interfaces" : [{
128128 "url" : "https://mcp.com" ,
129- "protocolBinding" : A2ATransport . jsonrpc ,
129+ "protocolBinding" : "JSONRPC" ,
130130 }],
131131 }
132132 mock_httpx .return_value .__enter__ .return_value .get .return_value = (
@@ -176,25 +176,29 @@ def test_get_connection_uri_mcp_interfaces_top_level(self, registry):
176176 {"url" : "https://mcp-v1main.com" , "protocolBinding" : "JSONRPC" }
177177 ]
178178 }
179- uri = registry ._get_connection_uri (
179+ uri , version , binding = registry ._get_connection_uri (
180180 resource_details , protocol_binding = A2ATransport .jsonrpc
181181 )
182182 assert uri == "https://mcp-v1main.com"
183+ assert version is None
184+ assert binding == "JSONRPC"
183185
184186 def test_get_connection_uri_agent_nested_protocols (self , registry ):
185187 resource_details = {
186188 "protocols" : [{
187189 "type" : _ProtocolType .A2A_AGENT ,
188190 "interfaces" : [{
189191 "url" : "https://my-agent.com" ,
190- "protocolBinding" : A2ATransport . jsonrpc ,
192+ "protocolBinding" : "JSONRPC" ,
191193 }],
192194 }]
193195 }
194- uri = registry ._get_connection_uri (
196+ uri , version , binding = registry ._get_connection_uri (
195197 resource_details , protocol_type = _ProtocolType .A2A_AGENT
196198 )
197199 assert uri == "https://my-agent.com"
200+ assert version is None
201+ assert binding == A2ATransport .jsonrpc
198202
199203 def test_get_connection_uri_filtering (self , registry ):
200204 resource_details = {
@@ -207,42 +211,52 @@ def test_get_connection_uri_filtering(self, registry):
207211 "type" : _ProtocolType .A2A_AGENT ,
208212 "interfaces" : [{
209213 "url" : "https://my-agent.com" ,
210- "protocolBinding" : A2ATransport . http_json ,
214+ "protocolBinding" : "HTTP_JSON" ,
211215 }],
212216 },
213217 ]
214218 }
215219 # Filter by type
216- uri = registry ._get_connection_uri (
220+ uri , version , binding = registry ._get_connection_uri (
217221 resource_details , protocol_type = _ProtocolType .A2A_AGENT
218222 )
219223 assert uri == "https://my-agent.com"
224+ assert version is None
225+ assert binding == A2ATransport .http_json
220226
221227 # Filter by binding
222- uri = registry ._get_connection_uri (
228+ uri , version , binding = registry ._get_connection_uri (
223229 resource_details , protocol_binding = A2ATransport .http_json
224230 )
225231 assert uri == "https://my-agent.com"
232+ assert version is None
233+ assert binding == A2ATransport .http_json
226234
227235 # No match
228- uri = registry ._get_connection_uri (
236+ uri , version , binding = registry ._get_connection_uri (
229237 resource_details ,
230238 protocol_type = _ProtocolType .A2A_AGENT ,
231239 protocol_binding = A2ATransport .jsonrpc ,
232240 )
233241 assert uri is None
242+ assert version is None
243+ assert binding is None
234244
235245 def test_get_connection_uri_returns_none_if_no_interfaces (self , registry ):
236246 resource_details = {}
237- uri = registry ._get_connection_uri (resource_details )
247+ uri , version , binding = registry ._get_connection_uri (resource_details )
238248 assert uri is None
249+ assert version is None
250+ assert binding is None
239251
240252 def test_get_connection_uri_returns_none_if_no_url_in_interfaces (
241253 self , registry
242254 ):
243255 resource_details = {"interfaces" : [{"protocolBinding" : "HTTP" }]}
244- uri = registry ._get_connection_uri (resource_details )
256+ uri , version , binding = registry ._get_connection_uri (resource_details )
245257 assert uri is None
258+ assert version is None
259+ assert binding is None
246260
247261 @patch ("httpx.Client" )
248262 def test_list_agents (self , mock_httpx , registry ):
@@ -313,7 +327,7 @@ def test_get_mcp_toolset(self, mock_httpx, registry):
313327 "displayName" : "TestPrefix" ,
314328 "interfaces" : [{
315329 "url" : "https://mcp.com" ,
316- "protocolBinding" : A2ATransport . jsonrpc ,
330+ "protocolBinding" : "JSONRPC" ,
317331 }],
318332 }
319333 mock_response .raise_for_status = MagicMock ()
@@ -335,7 +349,7 @@ def test_get_mcp_toolset_with_auth(self, mock_httpx, registry):
335349 "displayName" : "TestPrefix" ,
336350 "interfaces" : [{
337351 "url" : "https://mcp.com" ,
338- "protocolBinding" : A2ATransport . jsonrpc ,
352+ "protocolBinding" : "JSONRPC" ,
339353 }],
340354 }
341355 mock_response .raise_for_status = MagicMock ()
@@ -370,9 +384,10 @@ def test_get_remote_a2a_agent(self, mock_httpx, registry):
370384 "version" : "1.0" ,
371385 "protocols" : [{
372386 "type" : _ProtocolType .A2A_AGENT ,
387+ "protocolVersion" : "0.4.0" ,
373388 "interfaces" : [{
374389 "url" : "https://my-agent.com" ,
375- "protocolBinding" : A2ATransport . jsonrpc ,
390+ "protocolBinding" : "HTTP_JSON" ,
376391 }],
377392 }],
378393 "skills" : [{"id" : "s1" , "name" : "Skill 1" , "description" : "Desc 1" }],
@@ -393,6 +408,35 @@ def test_get_remote_a2a_agent(self, mock_httpx, registry):
393408 assert agent ._agent_card .version == "1.0"
394409 assert len (agent ._agent_card .skills ) == 1
395410 assert agent ._agent_card .skills [0 ].name == "Skill 1"
411+ assert agent ._agent_card .preferred_transport == A2ATransport .http_json
412+ assert agent ._agent_card .protocol_version == "0.4.0"
413+
414+ @patch ("httpx.Client" )
415+ def test_get_remote_a2a_agent_defaults (self , mock_httpx , registry ):
416+ mock_response = MagicMock ()
417+ mock_response .json .return_value = {
418+ "displayName" : "TestAgent" ,
419+ "description" : "Test Desc" ,
420+ "version" : "1.0" ,
421+ "protocols" : [{
422+ "type" : _ProtocolType .A2A_AGENT ,
423+ "interfaces" : [{
424+ "url" : "https://my-agent.com" ,
425+ }],
426+ }],
427+ }
428+ mock_response .raise_for_status = MagicMock ()
429+ mock_httpx .return_value .__enter__ .return_value .get .return_value = (
430+ mock_response
431+ )
432+
433+ registry ._credentials .token = "token"
434+ registry ._credentials .refresh = MagicMock ()
435+
436+ agent = registry .get_remote_a2a_agent ("test-agent" )
437+ assert isinstance (agent , RemoteA2aAgent )
438+ assert agent ._agent_card .preferred_transport == A2ATransport .http_json
439+ assert agent ._agent_card .protocol_version == "0.3.0"
396440
397441 @patch ("httpx.Client" )
398442 def test_get_remote_a2a_agent_with_card (self , mock_httpx , registry ):
@@ -436,6 +480,57 @@ def test_get_remote_a2a_agent_with_card(self, mock_httpx, registry):
436480 assert len (agent ._agent_card .skills ) == 1
437481 assert agent ._agent_card .skills [0 ].name == "S1"
438482
483+ @patch ("httpx.Client" )
484+ def test_get_remote_a2a_agent_with_httpx_client (self , mock_httpx , registry ):
485+ mock_response = MagicMock ()
486+ mock_response .json .return_value = {
487+ "displayName" : "TestAgent" ,
488+ "description" : "Test Desc" ,
489+ "version" : "1.0" ,
490+ "protocols" : [{
491+ "type" : _ProtocolType .A2A_AGENT ,
492+ "interfaces" : [{
493+ "url" : "https://my-agent.com" ,
494+ }],
495+ }],
496+ }
497+ mock_response .raise_for_status = MagicMock ()
498+ mock_httpx .return_value .__enter__ .return_value .get .return_value = (
499+ mock_response
500+ )
501+
502+ custom_client = httpx .AsyncClient ()
503+ agent = registry .get_remote_a2a_agent (
504+ "test-agent" , httpx_client = custom_client
505+ )
506+ assert agent ._httpx_client is custom_client
507+
508+ @patch ("httpx.Client" )
509+ def test_get_remote_a2a_agent_configures_transports (
510+ self , mock_httpx , registry
511+ ):
512+ mock_response = MagicMock ()
513+ mock_response .json .return_value = {
514+ "displayName" : "TestAgent" ,
515+ "protocols" : [{
516+ "type" : _ProtocolType .A2A_AGENT ,
517+ "interfaces" : [{
518+ "url" : "https://my-agent.com" ,
519+ "protocolBinding" : A2ATransport .jsonrpc ,
520+ }],
521+ }],
522+ }
523+ mock_response .raise_for_status = MagicMock ()
524+ mock_httpx .return_value .__enter__ .return_value .get .return_value = (
525+ mock_response
526+ )
527+
528+ registry ._credentials .token = "token"
529+ registry ._credentials .refresh = MagicMock ()
530+
531+ agent = registry .get_remote_a2a_agent ("test-agent" )
532+ assert agent ._agent_card .preferred_transport == A2ATransport .jsonrpc
533+
439534 def test_get_auth_headers (self , registry ):
440535 registry ._credentials .token = "fake-token"
441536 registry ._credentials .refresh = MagicMock ()
@@ -472,7 +567,7 @@ def test_make_request_raises_request_error(self, mock_httpx, registry):
472567 registry ._credentials .refresh = MagicMock ()
473568
474569 with pytest .raises (
475- RuntimeError , match = "API request failed \(network error\)"
570+ RuntimeError , match = r "API request failed \(network error\)"
476571 ):
477572 registry ._make_request ("test-path" )
478573
0 commit comments