Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion e2e/servers/mcp-go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,34 @@ go 1.24.0
toolchain go1.24.1

require (
github.com/x402-foundation/x402/go v0.0.0
github.com/modelcontextprotocol/go-sdk v1.3.0
github.com/x402-foundation/x402/go v0.0.0
)

require (
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20251001021608-1fe7b43fc4d6 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/bits-and-blooms/bitset v1.20.0 // indirect
github.com/consensys/gnark-crypto v0.18.0 // indirect
github.com/crate-crypto/go-eth-kzg v1.4.0 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/ethereum/c-kzg-4844/v2 v2.1.5 // indirect
github.com/ethereum/go-ethereum v1.16.7 // indirect
github.com/ethereum/go-verkle v0.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/google/jsonschema-go v0.4.2 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/holiman/uint256 v1.3.2 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/supranational/blst v0.3.16-0.20250831170142-f48500c1fdbe // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
golang.org/x/crypto v0.46.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
Expand Down
114 changes: 114 additions & 0 deletions e2e/servers/mcp-go/go.sum

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions e2e/servers/mcp-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/modelcontextprotocol/go-sdk/mcp"
x402 "github.com/x402-foundation/x402/go"
"github.com/x402-foundation/x402/go/extensions/bazaar"
x402http "github.com/x402-foundation/x402/go/http"
mcp402 "github.com/x402-foundation/x402/go/mcp"
evm "github.com/x402-foundation/x402/go/mechanisms/evm/exact/server"
Expand Down Expand Up @@ -96,6 +97,29 @@ func main() {
os.Exit(1)
}

// Declare bazaar MCP discovery extension for weather tool
weatherInputSchema := map[string]any{
"type": "object",
"properties": map[string]any{
"city": map[string]any{
"type": "string",
"description": "The city name to get weather for",
},
},
"required": []string{"city"},
}
bazaarExtension, err := bazaar.DeclareMcpDiscoveryExtension(bazaar.DeclareMcpDiscoveryConfig{
ToolName: "get_weather",
Description: "Get current weather for a city. Requires payment of $0.001.",
Transport: bazaar.TransportSSE,
InputSchema: weatherInputSchema,
Example: map[string]any{"city": "San Francisco"},
})
if err != nil {
fmt.Printf("❌ Failed to declare bazaar extension: %v\n", err)
os.Exit(1)
}

// Create payment wrapper using the x402 MCP SDK
paymentWrapper := mcp402.NewPaymentWrapper(resourceServer, mcp402.PaymentWrapperConfig{
Accepts: weatherAccepts,
Expand All @@ -104,6 +128,9 @@ func main() {
Description: "Get current weather for a city",
MimeType: "application/json",
},
Extensions: map[string]interface{}{
bazaar.BAZAAR.Key(): bazaarExtension,
},
})

// Create MCP server using the official SDK
Expand Down
Loading
Loading