Payment-aware MCP client orchestration.
Wraps a JSON-RPC send function: if the response is payment-required
(-32042 or payment-required result metadata), selects a challenge through
MPP.Client.SelectionPolicy, asks on_payment_required for approval, pays
via MPP.Client.MultiProvider, and retries the original request once with
the credential attached.
Approval runs after challenge selection and before payment — matching
refs/mppx/src/mcp/client/McpClient.ts. A declined approval neither pays nor
retries.
client = MPP.Client.MCP.new(provider: my_provider)
MPP.Client.MCP.call(client, request, &MyTransport.send/1)API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
call | 4 | Send a JSON-RPC request, paying and retrying once if payment is required. | client: value, request: value, send_fun: value, opts: value |
new | 1 | Build a payment-aware MCP client from provider and policy options. | opts: value |
Summary
Functions
Send request through send_fun, paying and retrying once on payment required.
Build a payment-aware MCP client.
Types
@type approval() :: (MPP.Challenge.t() -> boolean())
@type t() :: %MPP.Client.MCP{ on_payment_required: approval() | nil, provider: MPP.Client.MultiProvider.t(), selection: MPP.Client.SelectionPolicy.t() }
Functions
Send request through send_fun, paying and retrying once on payment required.
send_fun receives the JSON-RPC request map and must return a JSON-RPC
response map. Per-call :on_payment_required overrides the client hook;
pass nil to bypass it (mppx onPaymentRequired: null).
Build a payment-aware MCP client.
Options
:provider— required. AnMPP.Client.MultiProvider, a{module, config}tuple, or a provider module:selection—MPP.Client.SelectionPolicy.t(). Defaults to:server_order, or{:accept_payment, entries}when:accept_paymentis set:accept_payment— preference entries used as the default ranking policy:on_payment_required—(MPP.Challenge.t() -> boolean())invoked after challenge selection and before payment. Omitted ornilauto-approves.