# `A2UIAgent.A2A.Plug`
[🔗](https://github.com/a2ui-elixir/a2ui/blob/v0.1.1/umbrella/apps/a2ui_agent/lib/a2ui_agent/a2a/plug.ex#L2)

Serves an agent over A2A's JSON-RPC binding with
`A2UIAgent.A2A.Server`.

    forward "/a2a", A2UIAgent.A2A.Plug, agent: MyAgent

`MyAgent` implements `A2UIAgent.A2A.Agent`. A `POST` carries a
JSON-RPC request: `message/send` is answered with JSON and
`message/stream` with server-sent events, one JSON-RPC response per
event. A body that is not JSON gets a JSON-RPC parse error (-32700).
A `GET` returns the agent's card, when it has one.

The `X-A2A-Extensions` request header lists the extensions the client
requests. The A2UI extension activated for the request, which must be
one the agent's card advertises, is listed in the same response
header.

The body is read as JSON unless a `Plug.Parsers` before this plug has
already parsed it. This module needs the optional `plug` dependency.

Options: `:agent` (required); `:max_body_length` in bytes (default
8,000,000; a longer body gets status 413).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
