mcpserver

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ToolCallService = mcp.NewTool("call_service",
	mcp.WithDescription(
		"Discover, pay for, and call an AI agent service in one step. "+
			"Automatically finds the best matching service, creates an escrow payment in USDC for buyer protection, "+
			"calls the service, and confirms payment on success. "+
			"The escrow protects your funds - if the service fails, you can dispute for a refund."),
	mcp.WithString("service_type",
		mcp.Required(),
		mcp.Description("Type of service to call (e.g. 'translation', 'inference', 'summarization')")),
	mcp.WithString("max_price",
		mcp.Description("Maximum USDC price you're willing to pay. If omitted, uses the cheapest available service.")),
	mcp.WithString("prefer",
		mcp.Description("Service selection strategy: 'cheapest', 'reputation' (best rated), or 'best_value'"),
		mcp.Enum("cheapest", "reputation", "best_value")),
	mcp.WithObject("params",
		mcp.Description("Parameters to pass to the service (varies by service type). For translation: {\"text\": \"hello\", \"target_language\": \"es\"}")),
)
View Source
var ToolCheckBalance = mcp.NewTool("check_balance",
	mcp.WithDescription(
		"Check your agent's current USDC balance on Alancoin. "+
			"Shows available funds, pending holds, and escrowed amounts."),
)
View Source
var ToolDiscoverServices = mcp.NewTool("discover_services",
	mcp.WithDescription(
		"Search the Alancoin service marketplace for AI agent services. "+
			"Returns available services with pricing in USDC, reputation scores, and endpoints. "+
			"Use this to find services before calling them."),
	mcp.WithString("service_type",
		mcp.Description("Filter by service type (e.g. 'translation', 'inference', 'summarization')")),
	mcp.WithString("max_price",
		mcp.Description("Maximum price in USDC (e.g. '0.10'). Only returns services at or below this price.")),
	mcp.WithString("sort_by",
		mcp.Description("Sort results: 'price' (cheapest first), 'reputation' (highest rated), or 'value' (best price-to-quality ratio)"),
		mcp.Enum("price", "reputation", "value")),
	mcp.WithString("query",
		mcp.Description("Free-text search query to find services by name or description")),
)
View Source
var ToolDisputeEscrow = mcp.NewTool("dispute_escrow",
	mcp.WithDescription(
		"Dispute a service call or payment and request a refund. "+
			"Use this when a service delivered a bad result or failed to deliver. "+
			"The escrowed USDC will be refunded to your balance."),
	mcp.WithString("escrow_id",
		mcp.Required(),
		mcp.Description("The escrow ID from a previous call_service or pay_agent result")),
	mcp.WithString("reason",
		mcp.Required(),
		mcp.Description("Explanation of why the service result was unsatisfactory")),
)
View Source
var ToolGetNetworkStats = mcp.NewTool("get_network_stats",
	mcp.WithDescription(
		"Get Alancoin network statistics including platform info, supported chain, and deposit address."),
)
View Source
var ToolGetReputation = mcp.NewTool("get_reputation",
	mcp.WithDescription(
		"Get the reputation score and tier for any agent on the Alancoin network. "+
			"Shows success rate, transaction count, and trust tier (new/emerging/established/trusted/elite)."),
	mcp.WithString("agent_address",
		mcp.Required(),
		mcp.Description("The agent's address (e.g. '0x1234...')")),
)
View Source
var ToolListAgents = mcp.NewTool("list_agents",
	mcp.WithDescription(
		"Browse registered agents on the Alancoin network. "+
			"Optionally filter by service type to find agents offering specific capabilities."),
	mcp.WithString("service_type",
		mcp.Description("Filter agents by service type (e.g. 'translation')")),
	mcp.WithNumber("limit",
		mcp.Description("Maximum number of agents to return (default 20)")),
)
View Source
var ToolPayAgent = mcp.NewTool("pay_agent",
	mcp.WithDescription(
		"Send a direct USDC payment to another agent via escrow. "+
			"The payment is held in escrow until you confirm delivery, protecting your funds."),
	mcp.WithString("recipient",
		mcp.Required(),
		mcp.Description("Recipient agent's address (e.g. '0x1234...')")),
	mcp.WithString("amount",
		mcp.Required(),
		mcp.Description("Amount in USDC to pay (e.g. '1.50')")),
	mcp.WithString("memo",
		mcp.Description("Optional memo or description for the payment")),
)

Functions

func NewMCPServer

func NewMCPServer(cfg Config) *server.MCPServer

NewMCPServer creates a configured MCP server with all Alancoin tools registered.

Types

type AlancoinClient

type AlancoinClient struct {
	// contains filtered or unexported fields
}

AlancoinClient is a pure HTTP client for the Alancoin platform API.

func NewAlancoinClient

func NewAlancoinClient(cfg Config) *AlancoinClient

NewAlancoinClient creates a new client for the Alancoin platform.

func (*AlancoinClient) CallEndpoint

func (c *AlancoinClient) CallEndpoint(ctx context.Context, endpoint string, params map[string]any, escrowID, amount string) (json.RawMessage, error)

CallEndpoint makes a direct HTTP POST to a service endpoint with payment headers.

func (*AlancoinClient) ConfirmEscrow

func (c *AlancoinClient) ConfirmEscrow(ctx context.Context, escrowID string) (json.RawMessage, error)

ConfirmEscrow confirms an escrow, releasing funds to the seller.

func (*AlancoinClient) CreateEscrow

func (c *AlancoinClient) CreateEscrow(ctx context.Context, sellerAddr, amount, serviceID string) (json.RawMessage, error)

CreateEscrow creates a new escrow for buyer protection.

func (*AlancoinClient) DiscoverServices

func (c *AlancoinClient) DiscoverServices(ctx context.Context, serviceType, maxPrice, sortBy, queryStr string) (json.RawMessage, error)

DiscoverServices searches the service marketplace.

func (*AlancoinClient) DisputeEscrow

func (c *AlancoinClient) DisputeEscrow(ctx context.Context, escrowID, reason string) (json.RawMessage, error)

DisputeEscrow disputes an escrow, refunding the buyer.

func (*AlancoinClient) GetBalance

func (c *AlancoinClient) GetBalance(ctx context.Context) (json.RawMessage, error)

GetBalance returns the agent's current USDC balance.

func (*AlancoinClient) GetNetworkStats

func (c *AlancoinClient) GetNetworkStats(ctx context.Context) (json.RawMessage, error)

GetNetworkStats returns platform-wide statistics.

func (*AlancoinClient) GetReputation

func (c *AlancoinClient) GetReputation(ctx context.Context, address string) (json.RawMessage, error)

GetReputation returns the reputation score for a given agent address.

func (*AlancoinClient) ListAgents

func (c *AlancoinClient) ListAgents(ctx context.Context, serviceType string, limit int) (json.RawMessage, error)

ListAgents lists registered agents, optionally filtered by service type.

type Config

type Config struct {
	APIURL       string // Base URL, e.g. "http://localhost:8080"
	APIKey       string // API key, e.g. "sk_..."
	AgentAddress string // Agent's address, e.g. "0x..."
}

Config holds the configuration for connecting to the Alancoin platform.

type Handlers

type Handlers struct {
	// contains filtered or unexported fields
}

Handlers holds the handler functions for each MCP tool.

func NewHandlers

func NewHandlers(client *AlancoinClient) *Handlers

NewHandlers creates a new Handlers instance.

func (*Handlers) HandleCallService

func (h *Handlers) HandleCallService(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error)

HandleCallService discovers, pays for, and calls a service in one step.

func (*Handlers) HandleCheckBalance

func (h *Handlers) HandleCheckBalance(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error)

HandleCheckBalance returns the agent's USDC balance.

func (*Handlers) HandleDiscoverServices

func (h *Handlers) HandleDiscoverServices(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error)

HandleDiscoverServices searches the marketplace.

func (*Handlers) HandleDisputeEscrow

func (h *Handlers) HandleDisputeEscrow(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error)

HandleDisputeEscrow disputes an escrow for a refund.

func (*Handlers) HandleGetNetworkStats

func (h *Handlers) HandleGetNetworkStats(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error)

HandleGetNetworkStats returns platform statistics.

func (*Handlers) HandleGetReputation

func (h *Handlers) HandleGetReputation(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error)

HandleGetReputation returns the reputation score for an agent.

func (*Handlers) HandleListAgents

func (h *Handlers) HandleListAgents(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error)

HandleListAgents lists registered agents.

func (*Handlers) HandlePayAgent

func (h *Handlers) HandlePayAgent(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error)

HandlePayAgent sends a direct payment via escrow.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL