Skip to main content

llama-index-tools-a2a

PyPI version License: MIT Python Support Build Status

A2A (Agent-to-Agent) Protocol integration for LlamaIndex

Enable your LlamaIndex agents to discover and invoke other A2A-compatible agents as tools. Implements Google's A2A protocol specification for universal agent interoperability.

Why?

Agents are becoming composable building blocks, and the A2A (Agent-to-Agent) protocol is the emerging standard for letting independently built agents discover and call each other. This package provides an integration for LlamaIndex — covering both outbound client (connecting to remote A2A agents) and inbound server (exposing LlamaIndex Workflows as A2A agents) with FunctionTool conversion, partial parameter support, and multi-turn conversation handling.

Note: The inbound server is limited to A2A v0.3 due to the underlying a2a-sdk 0.3.26. The outbound client experimentally supports v1.0 method names for future compatibility.

Features

  • Outbound Client: Connect to any A2A agent via its AgentCard URL
  • Skill Discovery: Automatically discover available tools/skills from remote agents
  • Skill-to-tool Conversion: Converts AgentCard skill metadata (name, description, examples) to LlamaIndex FunctionTools
  • Inbound Server: Expose any LlamaIndex Workflow as an A2A-capable agent
  • Async Support: Full async/await support for non-blocking operation
  • Partial Params: Support for pre-filling common parameters across tools
  • Multi-turn Conversations: contextId propagation for stateful agent interactions

Installation

pip install llama-index-tools-a2a

Or with uv:

uv add llama-index-tools-a2a

With dev dependencies:

pip install "llama-index-tools-a2a[dev]"

Quick Start

Discovering Tools from an A2A Agent

from llama_index.tools.a2a_tools import aget_tools_from_a2a_card

# Connect to a remote A2A agent and get its tools
tools = await aget_tools_from_a2a_card(
    "https://weather-agent.example.com/.well-known/agent-card.json"
)

# Use tools in your LlamaIndex workflow (FunctionAgent is recommended over deprecated ReActAgent)
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

llm = OpenAI(model="gpt-4o-mini")
agent = FunctionAgent(tools=tools, llm=llm)
result = await agent.run("What's the weather in Tokyo?")

Filtering Specific Tools

# Only use specific skills
tools = await aget_tools_from_a2a_card(
    "https://agent.example.com/.well-known/agent-card.json",
    allowed_tools=["search_web", "calculate"],
)

Pre-filling Common Parameters

# Apply default parameters across all tools
tools = await aget_tools_from_a2a_card(
    "https://agent.example.com/.well-known/agent-card.json",
    global_partial_params={"api_key": "my-secret-key"},
)

Exposing a Workflow as an A2A Agent (Inbound)

from llama_index.core.workflow import Workflow, StartEvent, StopEvent, step
from llama_index.tools.a2a_tools import workflow_as_a2a


class MyStartEvent(StartEvent):
    query: str


class MyWorkflow(Workflow):
    @step
    async def run(self, start_event: MyStartEvent) -> StopEvent:
        return StopEvent(result=f"Processed: {start_event.query}")


# Create the A2A-compatible FastAPI app
app = workflow_as_a2a(MyWorkflow())

# Run with uvicorn: uvicorn my_module:app --host 0.0.0.0 --port 8000
# The agent will be discoverable at http://localhost:8000/.well-known/agent-card.json

Architecture

This integration mirrors the existing llama-index-tools-mcp pattern:

Concept MCP Equivalent A2A v0.3 A2A v1.0
Tool discovery list_tools() AgentCard.skills[] AgentCard.skills[]
Tool invocation call_tool(name, args) message/send + tasks/get SendMessage + GetTask
Inbound server MCPServer ASGI app (workflow_as_a2a()) ASGI app (workflow_as_a2a())
Workflow wrapping workflow_as_mcp() workflow_as_a2a() workflow_as_a2a()

Protocol Version

Important: The inbound server currently supports v0.3 only due to a2a-sdk 0.3.26 limitations.

  • Outbound client (BasicA2AClient): Auto-detects version from AgentCard supportedInterfaces field (wire format). Sends A2A-Version: 1.0 header for v1.0 servers, uses v1.0 method names (SendMessage, GetTask), falls back to v0.3 methods (message/send, tasks/get) for compatibility. Force a version with protocol_version="0.3" or "1.0" constructor argument.
    • v1.0 client paths are experimental — they are tested against mocked responses but not against real v1.0 reference servers.
  • Inbound server (workflow_as_a2a): Generates v0.3 AgentCard only (protocol_version parameter removed). The underlying a2a-sdk 0.3.26 request handler only processes v0.3 method names (message/send, tasks/get). Passing protocol_version="1.0" raises NotImplementedError.
  • Models: Includes v1.0 types (AgentInterface, Task, TaskStatus, Artifact, SendMessageResult) with discriminated union Part types (no kind field) for outbound client v1.0 support.

Based on a2a-sdk==0.3.26 with v1.0 wire protocol additions for the outbound client. See CHANGELOG for version history.

Limitations

  • Authentication: No built-in auth handling — relies on caller to supply headers/tokens via BasicA2AClient constructor.
  • Streaming: Inbound server declares streaming: false (correct) — actual SSE/event streaming is not implemented in WorkflowAgentExecutor.
  • Task polling: call_skill uses SendMessage (v1.0) or message/send (v0.3) — fire-and-forget; no automatic polling for long-running tasks. Use get_task() to retrieve results.
  • Error handling: Error responses from agents are wrapped in TaskResult.error but not systematically classified.
  • Testing: 38 tests — integration tests use ASGITransport against local v0.3 server; v1.0 client paths are tested against mocked responses only (no external v1.0 reference server tests).
  • Multi-turn: contextId is passed through but conversation state management is caller responsibility (use A2AToolSpec.context_id property).
  • Skill schemas: A2A v1.0 skills do not include JSON input schemas; tools accept natural language message parameter (pass JSON in text for structured input).
  • Underlying SDK: Uses a2a-sdk==0.3.26 — inbound server handles only v0.3 method names regardless of AgentCard format version.

Usage Examples

See examples/a2a.ipynb for a full end-to-end Jupyter notebook demonstrating:

  • Creating an inbound A2A agent with workflow_as_a2a()
  • Connecting as an outbound client via BasicA2AClient
  • Converting skills to LlamaIndex FunctionTools with A2AToolSpec
  • Using A2A tools inside a LlamaIndex FunctionAgent (ReActAgent is deprecated in LlamaIndex 0.13+)
  • Filtering skills and pre-filling partial parameters

Run the example server standalone:

python examples/a2a_server.py --port 8000
# Then visit http://localhost:8000/.well-known/agent-card.json

Project Status

  • v0.1.4 (2026-11-16): Fixed A2A protocol compliance — v1.0 client method names (SendMessage, GetTask), discriminated union Part types (no kind), contextId on Message object, skill name embedded in message text, proper task state handling (input-required, failed, canceled), v0.3 method name fixes (message/send, not tasks/send/messages/send), removed v1.0 server support (a2a-sdk 0.3.26 limitation), 38 tests passing ✅
  • v0.1.3 (2026-11-15): A2A v1.0 dual-version support (experimental), multi-turn contextId, honest feature naming, FunctionAgent examples ✅
  • v0.1.2 (2026-11-14): CI stability — strict asyncio mode, debug output, protocol version docs ✅
  • v0.1.1 (2026-11-12): PyPI publishing fix — version alignment, CI workflow reliability ✅
  • v0.1.0 (2026-11-12): Initial release — Outbound client, inbound server, tool spec conversion, 13 passing tests ✅

API Reference

Outbound Client

  • BasicA2AClient(agent_card_url, protocol_version=None) — Connect to an A2A agent
    • get_agent_card() — Discover agent metadata
    • list_skills() — List available skills
    • call_skill(name, arguments) — Invoke a skill (v1.0: SendMessage, v0.3: message/send)
    • send_message(message, context_id) — Send natural language message (v1.0: SendMessage, v0.3: message/send)
    • get_task(task_id) — Get task status/result (v1.0: GetTask, v0.3: tasks/get)
    • protocol_version property — Get detected protocol version ("0.3" or "1.0")

Tool Conversion

  • A2AToolSpec(client) — Convert A2A skills to LlamaIndex FunctionTools
    • context_id property — Get/set context ID for multi-turn conversations
    • reset_context() — Clear context ID for new conversation
  • aget_tools_from_a2a_card(url) — Async convenience function
  • get_tools_from_a2a_card(url) — Sync convenience function

Inbound Server

  • workflow_as_a2a(workflow) — Expose a Workflow as an A2A agent (v0.3 only)
  • create_agent_card(workflow) — Create AgentCard from a Workflow (v0.3 only)

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details.

This project is an independent implementation of the A2A integration approach proposed in LlamaIndex issue #24104. It is maintained as a standalone package per LlamaIndex's integration policy.

License

MIT License - see LICENSE file for details.

Acknowledgments

  • Google A2A Team for designing and publishing the open A2A protocol specification
  • LlamaIndex community for the MCP integration pattern this builds upon

Disclaimer: This is an independent community implementation. It is not affiliated with, endorsed by, or developed in collaboration with Google or the A2A team.

Built with

Developed with Claude Code.

Metadata

Release files for llama-index-tools-a2a 0.1.4

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

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-tools-a2a 0.1.4
File Interpreter ABI Platform Actions
llama_index_tools_a2a-0.1.4-py3-none-any.whl Python 3 none any Details for llama_index_tools_a2a-0.1.4-py3-none-any.whl

Release files / llama_index_tools_a2a-0.1.4-py3-none-any.whl

Download URL llama_index_tools_a2a-0.1.4-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d8defa5e3613e4d3ac08f7ae7bf8c055ee523bc41fc4e256856f19a13d9f851e
BLAKE2b-256 checksum
How to use checksums
084fed8e5ed151fa446386096d8e4e8cd3f27aad422b4c037414e724a6d793fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for llama-index-tools-a2a 0.1.4

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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