Documentation
¶
Overview ¶
Package payment holds the MCP payment flow shared by the MCP SDK and raw JSON-RPC server integrations: reading the Credential from _meta, running the charge, and building the payment error.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authorization ¶
Authorization reads the Credential from meta and formats it as a Payment Authorization value. It returns empty when meta carries no Credential, and a malformed-credential error when the Credential does not survive the canonical wire format (like mppx's McpCredential.parse).
Types ¶
type Outcome ¶
type Outcome struct {
// Challenged is true when the call must be answered with a payment error.
Challenged bool
// Challenges are the offers in the payment error.
Challenges []*mpp.Challenge
// Err is the payment error, nil when payment is simply required.
Err error
// Credential and Receipt are set on success.
Credential *mpp.Credential
Receipt *mpp.Receipt
}
Outcome is the result of a charge over MCP: either a payment error to return, or a verified (Credential, Receipt) pair.
func Charge ¶
func Charge(ctx context.Context, payment *server.Mpp, meta map[string]any, params server.ChargeParams) (*Outcome, error)
Charge runs payment.Charge with the Credential in meta.
func Compose ¶
func Compose(ctx context.Context, meta map[string]any, configs ...server.ComposeConfig) (*Outcome, error)
Compose runs server.Compose with the Credential in meta.
func (*Outcome) Error ¶
func (o *Outcome) Error() (int64, string, json.RawMessage)
Error returns the JSON-RPC error code, message and data for a challenged outcome. Like mppx, the data always carries the problem details.
func (*Outcome) MCPReceipt ¶
func (o *Outcome) MCPReceipt() (mpp.MCPReceipt, bool)
MCPReceipt returns the MCP receipt for a successful outcome.