task/migrate-x402-v2 #1
4 changed files with 22 additions and 119 deletions
Remove obsolete types
commit
779ddf981f
|
|
@ -148,8 +148,8 @@ func (s *Server) registerTools() {
|
|||
PayTo: s.x402Wallet,
|
||||
MaxTimeoutSeconds: 60,
|
||||
Extra: map[string]any{
|
||||
"OutputSchema": x402.Schema{
|
||||
Input: x402.InputSchema{
|
||||
"OutputSchema": Schema{
|
||||
Input: InputSchema{
|
||||
Type: "HTTP",
|
||||
Method: "POST",
|
||||
Discoverable: true,
|
||||
|
|
@ -203,8 +203,8 @@ func (s *Server) registerTools() {
|
|||
PayTo: s.x402Wallet,
|
||||
MaxTimeoutSeconds: 60,
|
||||
Extra: map[string]any{
|
||||
"OutputSchema": x402.Schema{
|
||||
Input: x402.InputSchema{
|
||||
"OutputSchema": Schema{
|
||||
Input: InputSchema{
|
||||
Type: "HTTP",
|
||||
Method: "POST",
|
||||
Discoverable: true,
|
||||
|
|
@ -255,8 +255,8 @@ func (s *Server) registerTools() {
|
|||
PayTo: s.x402Wallet,
|
||||
MaxTimeoutSeconds: 60,
|
||||
Extra: map[string]any{
|
||||
"OutputSchema": x402.Schema{
|
||||
Input: x402.InputSchema{
|
||||
"OutputSchema": Schema{
|
||||
Input: InputSchema{
|
||||
Type: "HTTP",
|
||||
Method: "POST",
|
||||
Discoverable: true,
|
||||
|
|
@ -317,8 +317,8 @@ func (s *Server) registerTools() {
|
|||
PayTo: s.x402Wallet,
|
||||
MaxTimeoutSeconds: 60,
|
||||
Extra: map[string]any{
|
||||
"OutputSchema": x402.Schema{
|
||||
Input: x402.InputSchema{
|
||||
"OutputSchema": Schema{
|
||||
Input: InputSchema{
|
||||
Type: "HTTP",
|
||||
Method: "POST",
|
||||
Discoverable: true,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,18 @@ type Bodyfield struct {
|
|||
Required bool `json:"required,omitempty"`
|
||||
}
|
||||
|
||||
type InputSchema struct {
|
||||
BodyFields map[string]any `json:"bodyFields,omitempty"`
|
||||
Discoverable bool `json:"discoverable,omitempty"`
|
||||
Method string `json:"method,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
type Schema struct {
|
||||
Input InputSchema `json:"input"`
|
||||
Output map[string]any `json:"output"`
|
||||
}
|
||||
|
||||
type GetLatestPostsRequest struct {
|
||||
Author string `json:"author" jsonschema_description:"Did or handle of an author"`
|
||||
Limit int `json:"limit" jsonschema_description:"Number of posts to retrieve"`
|
||||
|
|
|
|||
|
|
@ -1,110 +0,0 @@
|
|||
package x402
|
||||
|
||||
type InputSchema struct {
|
||||
BodyFields map[string]any `json:"bodyFields,omitempty"`
|
||||
Discoverable bool `json:"discoverable,omitempty"`
|
||||
Method string `json:"method,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
type Schema struct {
|
||||
Input InputSchema `json:"input"`
|
||||
Output map[string]any `json:"output"`
|
||||
}
|
||||
|
||||
// PaymentRequirement defines payment requirements for a resource/tool
|
||||
// as defined in the x402 specification section 5.1
|
||||
type PaymentRequirement struct {
|
||||
Scheme string `json:"scheme"`
|
||||
Network string `json:"network"`
|
||||
MaxAmountRequired string `json:"maxAmountRequired"`
|
||||
Asset string `json:"asset"`
|
||||
PayTo string `json:"payTo"`
|
||||
Resource string `json:"resource"`
|
||||
Description string `json:"description"`
|
||||
MimeType string `json:"mimeType"`
|
||||
OutputSchema Schema `json:"outputSchema"`
|
||||
MaxTimeoutSeconds int `json:"maxTimeoutSeconds"`
|
||||
Extra map[string]string `json:"extra,omitempty"`
|
||||
}
|
||||
|
||||
// PaymentRequirements402Response is the HTTP 402 response body
|
||||
type PaymentRequirements402Response struct {
|
||||
X402Version int `json:"x402Version"`
|
||||
Error string `json:"error"`
|
||||
Accepts []PaymentRequirement `json:"accepts"`
|
||||
}
|
||||
|
||||
// PaymentPayload represents the X-PAYMENT header content
|
||||
// as defined in the x402 specification section 5.2
|
||||
type PaymentPayload struct {
|
||||
X402Version int `json:"x402Version"`
|
||||
Scheme string `json:"scheme"`
|
||||
Network string `json:"network"`
|
||||
Payload struct {
|
||||
Signature string `json:"signature"`
|
||||
Authorization struct {
|
||||
From string `json:"from"`
|
||||
To string `json:"to"`
|
||||
Value string `json:"value"`
|
||||
ValidAfter string `json:"validAfter"`
|
||||
ValidBefore string `json:"validBefore"`
|
||||
Nonce string `json:"nonce"`
|
||||
} `json:"authorization"`
|
||||
} `json:"payload"`
|
||||
}
|
||||
|
||||
// SettlementResponse is included in X-PAYMENT-RESPONSE header
|
||||
// as defined in the x402 specification section 5.3
|
||||
type SettleResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Transaction string `json:"transaction"`
|
||||
Network string `json:"network"`
|
||||
Payer string `json:"payer"`
|
||||
ErrorReason string `json:"errorReason,omitempty"`
|
||||
}
|
||||
|
||||
// VerifyRequest sent to facilitator /verify endpoint
|
||||
// as defined in the x402 specification section 7.1
|
||||
// Note: x402Version added at root level for facilitator compatibility
|
||||
type VerifyRequest struct {
|
||||
X402Version int `json:"x402Version"`
|
||||
PaymentPayload *PaymentPayload `json:"paymentPayload"`
|
||||
PaymentRequirements *PaymentRequirement `json:"paymentRequirements"`
|
||||
}
|
||||
|
||||
// VerifyResponse from facilitator
|
||||
// as defined in the x402 specification section 7.1
|
||||
type VerifyResponse struct {
|
||||
IsValid bool `json:"isValid"`
|
||||
Payer string `json:"payer"`
|
||||
InvalidReason string `json:"invalidReason,omitempty"`
|
||||
}
|
||||
|
||||
// SettleRequest sent to facilitator /settle endpoint
|
||||
// as defined in the x402 specification section 7.2
|
||||
// Note: x402Version added at root level for facilitator compatibility
|
||||
type SettleRequest struct {
|
||||
X402Version int `json:"x402Version"`
|
||||
PaymentPayload *PaymentPayload `json:"paymentPayload"`
|
||||
PaymentRequirements *PaymentRequirement `json:"paymentRequirements"`
|
||||
}
|
||||
|
||||
// Config for X402Server
|
||||
type Config struct {
|
||||
// FacilitatorURL is the base URL of the x402 facilitator service
|
||||
FacilitatorURL string
|
||||
|
||||
CbApiKey *string
|
||||
CbApiSecret *string
|
||||
// PaymentTools maps tool names to their payment requirements
|
||||
// Each tool can have multiple payment options
|
||||
PaymentTools map[string][]PaymentRequirement
|
||||
AllTools []string
|
||||
|
||||
// VerifyOnly if true, only verifies but doesn't settle payments
|
||||
VerifyOnly bool
|
||||
|
||||
// Verbose if true, logs detailed request and payment information
|
||||
Verbose bool
|
||||
}
|
||||
|
|
@ -4,12 +4,13 @@ After=network.target
|
|||
|
||||
[Service]
|
||||
User=mcpserver
|
||||
Group=www-data
|
||||
Group=mcpserver
|
||||
|
||||
WorkingDirectory=/home/ubuntu/gitSources/mcpServer
|
||||
ExecStart=/home/ubuntu/gitSources/mcpServer/bin/main
|
||||
|
||||
RuntimeDirectory=mcpserver
|
||||
RuntimeDirectoryMode=0750
|
||||
|
||||
Restart=on-failure
|
||||
RestartSec=3s
|
||||
|
|
|
|||
Loading…
Reference in a new issue