JSON-RPC implementation of MPP.Client.Transport for MCP.
Operates on JSON-RPC request/response maps. Automatic pay-and-retry lives in
MPP.Client.MCP; this transport only detects, parses, and attaches.
Wire format
- Payment-required response: JSON-RPC error code
-32042(MPP.Mcp.payment_required_code/0), orresult._metacarryingorg.paymentauth/payment-required - Challenges:
error.data.challenges(or the payment-required result metadata equivalent), parsed byMPP.Mcp.extract_challenges/1 - Credential attachment:
params._meta["org.paymentauth/credential"]viaMPP.Mcp.attach_credential/2
Detection and parsing accept a full JSON-RPC envelope, a bare error object,
or a result/_meta fragment — the same shapes MPP.Mcp client helpers
already unwrap.
API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
set_credential | 2 | Attach a credential at params._meta["org.paymentauth/credential"]. | request: value, credential: value |
get_challenges | 1 | Parse Payment challenges from a JSON-RPC payment-required message. | response: value |
payment_required? | 1 | Return true if the JSON-RPC message signals payment required. | response: value |
Summary
Functions
Parse Payment challenges from a JSON-RPC payment-required message.
Return true if the JSON-RPC message signals payment required.
Attach a credential at params._meta["org.paymentauth/credential"].
Functions
@spec get_challenges(term()) :: {:ok, [MPP.Challenge.t()]} | {:error, term()}
@spec get_challenges(term()) :: {:error, :malformed_envelope}
Parse Payment challenges from a JSON-RPC payment-required message.
Parameters
response- JSON-RPC response envelope, error object, or result fragment (value)
Returns
{:ok, [challenge]} on success, {:error, reason} otherwise (tagged_tuple)
Errors
:malformed_envelope:no_challenges:invalid_challenge
# descripex:contract
%{
params: %{
response: %{
description: "JSON-RPC response envelope, error object, or result fragment",
kind: :value
}
},
errors: [:malformed_envelope, :no_challenges, :invalid_challenge],
returns: %{
type: :tagged_tuple,
description: "`{:ok, [challenge]}` on success, `{:error, reason}` otherwise"
}
}
Return true if the JSON-RPC message signals payment required.
Parameters
response- JSON-RPC response envelope, error object, or result fragment (value)
Returns
true when the error code is -32042 or payment-required metadata is present (boolean)
# descripex:contract
%{
params: %{
response: %{
description: "JSON-RPC response envelope, error object, or result fragment",
kind: :value
}
},
returns: %{
type: :boolean,
description: "true when the error code is -32042 or payment-required metadata is present"
}
}
@spec set_credential(map(), MPP.Credential.t()) :: map()
Attach a credential at params._meta["org.paymentauth/credential"].
Parameters
request- JSON-RPC request envelope or MCP tool-params map (value)credential- MPP.Credential struct (value)
Returns
Request with the credential in _meta (map)
# descripex:contract
%{
params: %{
request: %{
description: "JSON-RPC request envelope or MCP tool-params map",
kind: :value
},
credential: %{description: "MPP.Credential struct", kind: :value}
},
returns: %{type: :map, description: "Request with the credential in `_meta`"}
}