Python SDK for the A2A-over-MQTT protocol
Project description
A2A-over-MQTT Python SDK
Python SDK for the A2A-over-MQTT protocol: build agents and clients that communicate via MQTT using the A2A (Agent-to-Agent) protocol.
Install
pip install a2a-over-mqtt
Or with uv:
uv add a2a-over-mqtt
Quick start
Build a responder (agent)
import asyncio
from a2a_over_mqtt import MqttConfig, TopicSpace, Responder, build_card, A2ARequest
class MyAgent(Responder):
async def on_request(self, request: A2ARequest, stream) -> str:
await stream("thinking...")
return f"You said: {request.text}"
async def main():
mqtt = MqttConfig(host="localhost", port=1883)
topics = TopicSpace(org="myorg", unit="default")
card = build_card(
name="Echo Agent",
description="Echoes back whatever you send",
url="mqtt://localhost:1883",
)
agent = MyAgent(
agent_id="echo",
mqtt=mqtt,
topics=topics,
card=card,
)
await agent.run()
asyncio.run(main())
Send a request (client)
import asyncio
from a2a_over_mqtt import MqttConfig, TopicSpace, Requester, A2ARequest
async def main():
mqtt = MqttConfig(host="localhost", port=1883)
topics = TopicSpace(org="myorg", unit="default")
requester = Requester(mqtt, topics)
req = A2ARequest(text="Hello, agent!", request_id="req-1")
async for kind, content in requester.stream("echo", req.to_json(), "corr-1"):
print(f"{kind}: {content}")
asyncio.run(main())
API overview
Configuration
MqttConfig(host, port, tls, username, password): MQTT broker connection parameters. Frozen dataclass.TopicSpace(org, unit): A2A topic namespace. Provides.request(),.reply(),.discovery(),.event()methods.
Protocol (pure, no I/O)
A2ARequest/A2AResponse: JSON-RPC 2.0 message types with serialization.make_status_event()/make_artifact_event(): Build streaming response messages.classify_reply(data): Parse a reply into(kind, content)tuples.validate_a2a_request(payload, response_topic, correlation): Validate inbound requests. ReturnsA2ARequestorValidationError.
Discovery
build_card(name, description, url, ...): Build a spec-conformant A2A Agent Card.parse_card(payload): Parse a card from JSON bytes or string.
High-level
Requester: Send requests and stream replies with configurable retry/timeout.Responder: Abstract base class for agents. Implementon_request(), callrun(). Handles the full protocol lifecycle: ack, streaming, artifact, terminal status, deduplication, cancellation, and LWT.
Development
uv sync
uv run python -m pytest tests/ -v
Build and publish
uv run python -m build
uv run twine upload dist/*
Project details
Release history Release notifications | RSS feed
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 a2a_over_mqtt-0.1.0.tar.gz.
File metadata
- Download URL: a2a_over_mqtt-0.1.0.tar.gz
- Upload date:
- Size: 48.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e75a8ae1e9930f03641f874d96e0f66845320ea878200143aa522ff6662d534
|
|
| MD5 |
b196a4fb426846923269aba577cd11d6
|
|
| BLAKE2b-256 |
c2eaf8c62bbf7b7db3de243c7d47f27a0a7d13744959c81d497ac866640f03de
|
Provenance
The following attestation bundles were made for a2a_over_mqtt-0.1.0.tar.gz:
Publisher:
sdk-python-publish.yml on emqx/mqtt-for-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
a2a_over_mqtt-0.1.0.tar.gz -
Subject digest:
9e75a8ae1e9930f03641f874d96e0f66845320ea878200143aa522ff6662d534 - Sigstore transparency entry: 1260771274
- Sigstore integration time:
-
Permalink:
emqx/mqtt-for-ai@b9612c9a15ae7d003835abb1bc22dbb19290ace9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/emqx
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-python-publish.yml@b9612c9a15ae7d003835abb1bc22dbb19290ace9 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file a2a_over_mqtt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: a2a_over_mqtt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6f1dd95fe3ba9b46375793c27789cbc9e395ffe9a3b1023fc8c63fd5dcf2539
|
|
| MD5 |
6bd5e25ceab2f45c49caa82fac89b057
|
|
| BLAKE2b-256 |
9109ddaae71162e3cc22758d2c6a5e037149f60955508f453f3b4511bff88e52
|
Provenance
The following attestation bundles were made for a2a_over_mqtt-0.1.0-py3-none-any.whl:
Publisher:
sdk-python-publish.yml on emqx/mqtt-for-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
a2a_over_mqtt-0.1.0-py3-none-any.whl -
Subject digest:
b6f1dd95fe3ba9b46375793c27789cbc9e395ffe9a3b1023fc8c63fd5dcf2539 - Sigstore transparency entry: 1260771346
- Sigstore integration time:
-
Permalink:
emqx/mqtt-for-ai@b9612c9a15ae7d003835abb1bc22dbb19290ace9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/emqx
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-python-publish.yml@b9612c9a15ae7d003835abb1bc22dbb19290ace9 -
Trigger Event:
workflow_dispatch
-
Statement type: