Skip to main content

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. Returns A2ARequest or ValidationError.

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. Implement on_request(), call run(). 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/*

Metadata

Release files for a2a-over-mqtt 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for a2a-over-mqtt 0.1.0
File Size Uploaded
a2a_over_mqtt-0.1.0.tar.gz 48.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for a2a-over-mqtt 0.1.0
File Interpreter ABI Platform
a2a_over_mqtt-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 68.6 kB

Release files / a2a_over_mqtt-0.1.0.tar.gz

Download URL a2a_over_mqtt-0.1.0.tar.gz
Size 48.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9e75a8ae1e9930f03641f874d96e0f66845320ea878200143aa522ff6662d534
BLAKE2b-256 checksum
How to use checksums
c2eaf8c62bbf7b7db3de243c7d47f27a0a7d13744959c81d497ac866640f03de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 9, 2026.

Transparency log

Release files / a2a_over_mqtt-0.1.0-py3-none-any.whl

Download URL a2a_over_mqtt-0.1.0-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6f1dd95fe3ba9b46375793c27789cbc9e395ffe9a3b1023fc8c63fd5dcf2539
BLAKE2b-256 checksum
How to use checksums
9109ddaae71162e3cc22758d2c6a5e037149f60955508f453f3b4511bff88e52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page