A2A PHP SDK - PHP implementation of the AI A2A (Agent-to-Agent) Protocol (v0.2.5-0.3.0)
a2a-php is an early-stage PHP project in the AI payments / x402 ecosystem, focused on a2a, a2a-protocol, agent-to-agent, ai. It currently has 3 GitHub stars and 1 forks, and sits alongside related tools like a2a-go, capiscio-sdk-python, capiscio-python, a2a-elixir, snap-protocol, nexus.
A PHP implementation of the A2A (Agent-to-Agent) Protocol (v0.3.0). The repository includes the unofficial library implementation and a fully compliant sample server, strict JSON-RPC validation logic, task management utilities, streaming support, and push notification handling.
# Install dependencies
composer install
# Start the reference server
php -S localhost:8081 examples/complete_a2a_server.php
# (Optional) expose an authenticated extended card
export A2A_DEMO_AUTH_TOKEN="example-secret"
# (Optional, recommended in production) restrict push webhook hosts
export A2A_WEBHOOK_ALLOWLIST="hooks.example.com,callbacks.example.com"
The server exposes the JSON-RPC endpoint at http://localhost:8081/ and publishes the agent card at http://localhost:8081/.well-known/agent-card.json.
Verified against the official A2A Test Compatibility Kit
pinned at 0.3.0.beta5 (the latest v0.3.0-era TCK release) — every
category passes:
| Category | Result |
|---|---|
| Mandatory | 32 passed, 0 failed (1 skipped: not applicable) |
| Capability | 39 passed, 0 failed — capability honesty "excellent" |
| Transport equivalence | skipped (single JSON-RPC transport) |
| Quality | 14 passed, 0 failed |
| Features | 15 passed, 0 failed (1 skipped) |
The TCK is re-run on every pull request by CI (.github/workflows/ci.yml);
the pin and upgrade procedure are documented in docs/tck-upgrade.md.
| Env var | Default | Effect |
|---|---|---|
A2A_DEMO_AUTH_TOKEN |
unset | When set, agent/getAuthenticatedExtendedCard requires a matching Authorization: Bearer or X-API-Key credential. Demo-grade gate only. |
A2A_WEBHOOK_ALLOWLIST |
unset (allow all) | Comma-separated hostnames allowed as push notification webhook targets. Enforced when configs are stored and at delivery time (SSRF guard). |
A2A_MODE / A2A_FORCE_HTTPS |
unset | Used only by the demo https_a2a_server.php (see A2A_HTTPS_IMPLEMENTATION.md). |
tasks/resubscribe snapshot feed that replays history before emitting the current task status.A2A_DEMO_AUTH_TOKEN environment variable for demonstration purposes.| Method | Description | Notes |
|---|---|---|
get_agent_card |
Returns the public agent card. | JSON-RPC response. |
agent/getAuthenticatedExtendedCard |
Returns the extended card when Authorization: Bearer or X-API-Key matches A2A_DEMO_AUTH_TOKEN. |
JSON-RPC response. |
message/send |
Processes an inbound message and returns the task snapshot. | Validates message parts and metadata. |
message/stream |
Starts an SSE session for live task updates while processing a streamed message. | Emits JSON-RPC envelopes over SSE. |
tasks/send |
Accepts an explicit task and message payload, ensuring reuse of existing task IDs. | Sets status to working and finalises with handler result. |
tasks/get |
Retrieves the latest task state, history, and artifacts. | Supports the optional historyLength parameter. |
tasks/cancel |
Cancels a running task once and reports an error on repeated cancellation attempts. | Uses TaskManager::cancelTask. |
tasks/resubscribe |
Emits task history and current status over SSE for reconnecting clients. | Utilises stored history snapshots. |
tasks/pushNotificationConfig/set |
Persists a push configuration for a task. | Stores webhook data in shared storage. |
tasks/pushNotificationConfig/get |
Returns the stored configuration for a task. | Null when absent. |
tasks/pushNotificationConfig/list |
Lists all stored configurations, optionally filtered by taskId. |
Returns an array of summary objects. |
tasks/pushNotificationConfig/delete |
Removes the configuration for a task. | Returns null on success. |
ping |
Health-check method. | Returns { "status": "pong" }. |
Refer to docs/api-reference.md for complete request and response schemas.
The reference server streams events from the same JSON-RPC endpoint when the message/stream or tasks/resubscribe methods are invoked. Responses are encoded as JSON-RPC payloads and delivered as SSE events with IDs set to the task or message identifiers. The StreamingServer guarantees that a resubscribe replay includes every stored message history entry before the terminal task status update.
# Full PHPUnit suite (unit + integration + e2e; the e2e suite boots the
# reference server and a webhook receiver on ephemeral ports by itself)
composer test
# Static analysis and coding standard
composer analyse # PHPStan level 8 (baseline-ratcheted)
vendor/bin/phpcs -n # PSR-12
# Official TCK, pinned version (see docs/tck-upgrade.md)
git clone --branch 0.3.0.beta5 https://github.com/a2aproject/a2a-tck.git ../a2a-tck
cd ../a2a-tck && pip install -e . && cd -
php -S localhost:8081 examples/complete_a2a_server.php &
python3 ../a2a-tck/run_tck.py --sut-url http://localhost:8081 --category all
The TCK run exercises JSON-RPC validation, streaming behaviour, push notification management and delivery, and task-state transitions. PHPUnit covers golden-path, edge-case, error-path and end-to-end scenarios for the PHP components.
For reviewing a change or release by hand:
| Step | What to check | Where | Expected outcome |
|---|---|---|---|
| Config | composer validate --strict; env vars in the Configuration table above |
composer.json, this README |
Valid manifest; defaults preserve previous behavior |
| Run | php -S localhost:8081 examples/complete_a2a_server.php, then curl -s -X POST http://localhost:8081/ -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"ping","id":1}' |
examples/ |
{"jsonrpc":"2.0","id":1,"result":{"status":"pong"}} |
| Examples | Run each script under examples/ with php examples/<name>.php (servers run under php -S) |
examples/ |
No PHP warnings/errors in output |
| Tests | composer test, composer analyse, vendor/bin/phpcs -n |
tests/, phpstan.neon.dist, phpcs.xml.dist |
All green, no new PHPStan baseline entries |
| Compliance | TCK procedure above | docs/tck-upgrade.md |
All categories pass at the pinned TCK ref |
| Logs | Inspect a2a_server.log produced by the reference server |
repo root | Structured log lines, no stack traces leaked to clients |
Additional documentation lives in the docs/ directory:
docs/README.md – high-level overview and architecture notes.docs/api-reference.md – detailed method and data model reference.docs/protocol-compliance.md – TCK summary and behavioural guarantees.docs/tck-upgrade.md – TCK version pin and upgrade procedure.docs/UPGRADE-1.0.md – upgrade path to A2A protocol v1.0 (planning doc).docs/adr/ – architecture decision records.For HTTPS deployment details, see A2A_HTTPS_IMPLEMENTATION.md and HTTPS_SUMMARY.md.
Security policy: SECURITY.md. Release history: CHANGELOG.md.
See CONTRIBUTING.md. In short: fork, branch,
composer install, add golden-path/edge/error tests for the change, keep
composer test, composer analyse, vendor/bin/phpcs -n and the pinned
TCK green, then open a PR describing the validation steps.
Distributed under the Apache License 2.0. See LICENSE for the full text.
Golang SDK for A2A Protocol
Runtime security middleware for A2A (Agent-to-Agent) protocol agents. Provides always-on validation, signature verification, and rate limiting for AI agent interactions.
🚀 Access and manage the CapiscIO CLI easily with this Python wrapper, ensuring optimal performance across your system and architecture.
Elixir implementation of the Agent-to-Agent (A2A) protocol (https://a2a-protocol.org).
SNAP - Signed Network Agent Protocol. Secure agent-to-agent (A2A) communication with cryptographic identity, built on Bitcoin Schnorr signatures and Nostr.
The AI-to-AI Protocol Layer that catches unreliable agent outputs before they cost you money. Claim-level verification, escrow, and slashing. 224 tests, 12/12 adversarial patterns caught.
An open SDK for agentic payments. Let AI agents make payments, hold funds, and move money across chains with policy enforcement and human approval built in.
Client SDK for the Vybe x402 API. Pay-per-call USDC over HTTP and prepaid-credit WebSocket streaming for Vybe's Solana analytics API. Built for AI agents.
Rust SDK for the Machine Payments Protocol
Building blocks for Agentic payments (x402, MPP, AP2) for TypeScript, Rust, Go, Python, Ruby, PHP, Lua, Kotlin and Swift.
Opinionated React Native crypto x AI chat app boilerplate with embedded wallet support, conversational AI, and dynamic UI component injection
A fully modular, framework-agnostic, easy-to-extend SDK for building complex X402 payment integrations.