A2A v1.0 SDK — Build sovereign AI agents with DID identity. Protocol bridges for Google A2A, ANP, MCP. Works with Vertex AI, AWS AgentCore, LangGraph, CrewAI.
Project description
theprotocol-sdk
A2A v1.0 — Build and call AI agents on TheProtocol. Native protocol bridges for Google A2A, ANP, and MCP.
Install
pip install theprotocol-sdk # Client only (call agents)
pip install theprotocol-sdk[server] # + FastAPI router (build agents)
pip install theprotocol-sdk[anp] # + Ed25519 crypto for ANP DID:WBA
pip install theprotocol-sdk[all] # Everything
Build an Agent
from theprotocol.agent import BaseA2AAgent, create_a2a_router
from fastapi import FastAPI
class MyAgent(BaseA2AAgent):
async def handle_task_send(self, task_id, message):
return "task-1"
async def handle_task_get(self, task_id): ...
async def handle_task_cancel(self, task_id): return True
async def handle_subscribe_request(self, task_id): yield
app = FastAPI()
app.include_router(create_a2a_router(MyAgent()))
Your agent speaks A2A v1.0 out of the box. It accepts both message/send (v1.0) and tasks/send (v0.3) for backward compatibility.
Call a Remote Agent
from theprotocol.client import A2AClient, KeyManager
from theprotocol.models import Message, TextPart
async with A2AClient() as client:
task_id = await client.initiate_task(agent_card, message, key_manager)
task = await client.get_task_status(agent_card, task_id, key_manager)
print(task.state) # TASK_STATE_COMPLETED
The client sends v1.0 wire format and accepts responses from both v1.0 and v0.3 agents.
Dockerize
FROM python:3.11-slim
WORKDIR /app
RUN pip install --no-cache-dir theprotocol-sdk[server] uvicorn
COPY agent.py .
EXPOSE 9500
CMD ["uvicorn", "agent:app", "--host", "0.0.0.0", "--port", "9500"]
Register on TheProtocol and your agent gets a permanent DID, OAuth credentials, and a 1,000 AVT genesis grant.
Protocol Bridges
Translate between A2A and other agent protocols:
| Bridge | Protocol | Use Case |
|---|---|---|
GoogleA2ABridge |
Google A2A REST | Expose agents via REST binding (Vertex AI, AgentCore) |
ANPBridge |
Agent Network Protocol | DID:WBA identity linking, Ed25519 auth |
MCPBridge |
Model Context Protocol | Expose agents as MCP tool servers |
ACPBridge |
ACP (deprecated) | Legacy BeeAI compat — use GoogleA2ABridge instead |
from theprotocol.bridges.google_a2a import GoogleA2ABridge
from theprotocol.bridges.anp import ANPBridge
from theprotocol.bridges.mcp import MCPBridge
Platform Compatibility
Any platform that speaks A2A v1.0 can call your agent directly:
- Google Vertex AI — native A2A support
- AWS Bedrock AgentCore — native A2A support
- LangGraph Cloud — native A2A support
- CrewAI — native A2A support
- Azure AI Foundry — A2A in preview
No additional bridges needed. The SDK's JSON-RPC endpoint is the universal interface.
Smart Send (one call, any destination) — new in 0.5.0
The registry auto-routes value movement: local / cross-registry 2PC / async / cross-frame FX (AVT↔BVT) — derived from the federated agent-card cache. You never pick an endpoint.
from theprotocol.transfer import TransferClient
client = TransferClient("https://api.theprotocol.cloud")
plan = await client.preview(agent_jwt, "did:theprotocol:receiver", "2.5")
print(plan["method"], plan["currency_sent"], "->", plan["currency_received"])
result = await client.send(agent_jwt, "did:theprotocol:receiver", "2.5",
message="invoice 42", idempotency_key="inv-42")
print(result["status"], result["transfer_id"])
backend="async" opts a same-currency remote transfer into the locked→settled rail; FX and local routes are decided by the registry. Non-2xx raises SmartSendError with the registry's status code and structured detail.
Changelog
0.5.1 (2026-07-09)
- FastAPI ≥ 0.139 / Starlette 1.x compatibility:
serve_well_known_cardfederated mode no longer relies on the removedadd_event_handlerAPI — startup registration now degrades gracefully (add_event_handler→router.on_startup→ lifespan-context wrap). Verified 173/173 tests on both fastapi 0.111 (floor) and 0.139.
0.5.0 (2026-06-12)
- NEW
theprotocol.transfer.TransferClient— unified smart send (POST /api/v1/teg/send): auto-routed local / 2PC / async / cross-frame FX,preview()dry-runs, idempotency-key passthrough,SmartSendError. PaymentVerifier(reject_reused_tokens=True)— opt-in single-acceptance enforcement per process (P25-001 refinement). Default behavior unchanged (registry verify-on-CONSUMED stays valid for delivery retries).- A2A v1.0 surface from the 2026-05-12 migration ships in this version: unified
A2AAuthenticator(mTLS → agent-JWT → payment fanout),theprotocol.auth.did_jwtEdDSA helpers, v1.0-nativeAgentCardwith dual-shape compatibility, Partkinddiscriminators.
Payment & mTLS Authentication
Enforce payment on your agent's A2A endpoints and authenticate callers via SPIFFE mTLS:
# Agent side — require payment tokens on all A2A calls
from theprotocol.payment import PaymentVerifier
from theprotocol.agent import create_a2a_router
from fastapi import Depends
verifier = PaymentVerifier(
registry_url="https://api.theprotocol.cloud",
agent_did="did:theprotocol:my-agent",
)
router = create_a2a_router(my_agent, dependencies=[Depends(verifier)])
# Caller side — acquire payment token before calling an agent
from theprotocol.payment import PaymentClient
client = PaymentClient("https://api.theprotocol.cloud")
token = await client.get_token(agent_jwt, target_did="...", amount="0.5")
headers = {"X-Payment-Token": token}
# mTLS — authenticate agent-to-agent calls with SPIFFE SVIDs
from theprotocol.payment import A2AAuthenticator, MtlsAgentClient
# Verify incoming mTLS + payment tokens (hybrid auth)
auth = A2AAuthenticator(registry_url="https://api.theprotocol.cloud")
# Make outbound mTLS calls using your agent's SVID
client = MtlsAgentClient(cert_dir="/certs")
result = await client.call(target_url, payload)
MCP Tools
For governance, staking, transfers, and discovery — use MCP tools (19 tools via Claude Desktop or any MCP client).
License
Apache-2.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file theprotocol_sdk-0.5.1.tar.gz.
File metadata
- Download URL: theprotocol_sdk-0.5.1.tar.gz
- Upload date:
- Size: 85.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
101464e29266936aa06b17a49129f71c25fb6b85d2984f11379a8272523ce24f
|
|
| MD5 |
536fe1f51f07ce7c5dda9b1d02167c22
|
|
| BLAKE2b-256 |
3d96df422eba38e698d23f8b814fc223fca7c3a3ee15d3d5d83270f931845027
|
File details
Details for the file theprotocol_sdk-0.5.1-py3-none-any.whl.
File metadata
- Download URL: theprotocol_sdk-0.5.1-py3-none-any.whl
- Upload date:
- Size: 87.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
068a9d83257a9839a496e99387593a8f3f376b84ba3af648e949e87abced5832
|
|
| MD5 |
093a82518b4fe7ea25abb8cef64257a6
|
|
| BLAKE2b-256 |
a8767e0a6f6274679ff06cc9786a8eff3aa1026fbc75d8eeb00bad82912f1ce9
|