You will scaffold an A2A agent with one command, run it, and call it over JSON-RPC, then see how a client discovers it through its Agent Card. Terms: A2A = the agent-to-agent protocol; serve_a2a = the SDK helper that runs the A2A server on port 9000; Agent Card = the JSON that advertises the agent's skills; message/send = the JSON-RPC method to talk to it.
# main.py (generated) from strands import Agent, tool from strands.multiagent.a2a.executor import StrandsA2AExecutor from bedrock_agentcore.runtime import serve_a2a from model.load import load_model @tool def add_numbers(a: int, b: int) -> int: """Return the sum of two numbers.""" return a + b agent = Agent(model=load_model(), system_prompt="You are a helpful assistant.", tools=[add_numbers]) if __name__ == "__main__": serve_a2a(StrandsA2AExecutor(agent)) # A2A server on port 9000
import asyncio, os, httpx from uuid import uuid4 from a2a.client import A2ACardResolver, ClientConfig, ClientFactory from a2a.types import Message, Part, Role, TextPart async def ask(text): headers = {"Authorization": f"Bearer {os.environ['BEARER_TOKEN']}", "X-Amzn-Bedrock-AgentCore-Runtime-Session-Id": str(uuid4())} async with httpx.AsyncClient(headers=headers, timeout=300) as http: card = await A2ACardResolver(httpx_client=http, base_url=os.environ["AGENTCORE_RUNTIME_URL"]).get_agent_card() client = ClientFactory(ClientConfig(httpx_client=http, streaming=False)).create(card) msg = Message(kind="message", role=Role.user, parts=[Part(TextPart(kind="text", text=text))], message_id=uuid4().hex) async for event in client.send_message(msg): print(event) asyncio.run(ask("what is 101 * 11"))