1+ // Package server provides MCP server integration for x402 payment gating.
2+ // It enables payment-gated AI tools via the Model Context Protocol.
13package server
24
35import (
@@ -10,7 +12,9 @@ import (
1012 "github.com/mark3labs/x402-go/http"
1113)
1214
13- // Facilitator interface for payment verification and settlement
15+ // Facilitator defines the interface for payment verification and settlement.
16+ // Implementations communicate with an x402 facilitator service to verify
17+ // payment authorizations and execute settlements on the blockchain.
1418type Facilitator interface {
1519 // Verify verifies a payment without settling it
1620 Verify (ctx context.Context , payment * x402.PaymentPayload , requirement x402.PaymentRequirement ) (* facilitator.VerifyResponse , error )
@@ -19,12 +23,14 @@ type Facilitator interface {
1923 Settle (ctx context.Context , payment * x402.PaymentPayload , requirement x402.PaymentRequirement ) (* x402.SettlementResponse , error )
2024}
2125
22- // HTTPFacilitator implements Facilitator using the http.FacilitatorClient
26+ // HTTPFacilitator implements the Facilitator interface using the http.FacilitatorClient.
27+ // It communicates with an x402 facilitator service over HTTP to verify and settle payments.
2328type HTTPFacilitator struct {
2429 client * http.FacilitatorClient
2530}
2631
27- // HTTPFacilitatorOption configures an HTTPFacilitator
32+ // HTTPFacilitatorOption is a functional option for configuring an HTTPFacilitator.
33+ // Use WithAuthorization or WithAuthorizationProvider to set authentication.
2834type HTTPFacilitatorOption func (* http.FacilitatorClient )
2935
3036// WithAuthorization sets a static Authorization header value for the facilitator.
@@ -44,7 +50,14 @@ func WithAuthorizationProvider(provider http.AuthorizationProvider) HTTPFacilita
4450 }
4551}
4652
47- // NewHTTPFacilitator creates a new HTTP facilitator client
53+ // NewHTTPFacilitator creates a new HTTP facilitator client with the given URL and options.
54+ // The facilitator is used to verify and settle payments for payment-gated MCP tools.
55+ //
56+ // Example:
57+ //
58+ // facilitator := NewHTTPFacilitator("https://api.x402.coinbase.com",
59+ // WithAuthorization("Bearer my-api-key"),
60+ // )
4861func NewHTTPFacilitator (facilitatorURL string , opts ... HTTPFacilitatorOption ) * HTTPFacilitator {
4962 timeouts := x402 .DefaultTimeouts
5063 client := & http.FacilitatorClient {
0 commit comments