Skip to main content
Glama
discovery.go1.87 kB
package tools import ( "context" "fmt" "strings" "github.com/luno/luno-go" "github.com/luno/luno-mcp/internal/config" ) // GetMarketInfo returns a detailed description of the market situation func GetMarketInfo(ctx context.Context, cfg *config.Config, pair string) (string, error) { // First check if the pair is valid by trying to get ticker info ticker, err := cfg.LunoClient.GetTicker(ctx, &luno.GetTickerRequest{Pair: pair}) if err != nil { return "", fmt.Errorf("could not get market info for %s: %w", pair, err) } orderBook, err := cfg.LunoClient.GetOrderBook(ctx, &luno.GetOrderBookRequest{Pair: pair}) if err != nil { return "", fmt.Errorf("got ticker but could not get order book for %s: %w", pair, err) } var marketInfo strings.Builder marketInfo.WriteString(fmt.Sprintf("Market info for %s:\n", pair)) marketInfo.WriteString(fmt.Sprintf("Last trade price: %s\n", ticker.LastTrade.String())) marketInfo.WriteString(fmt.Sprintf("Ask (Sell) price: %s\n", ticker.Ask.String())) marketInfo.WriteString(fmt.Sprintf("Bid (Buy) price: %s\n", ticker.Bid.String())) marketInfo.WriteString(fmt.Sprintf("24-hour volume: %s\n\n", ticker.Rolling24HourVolume.String())) // Add some order book info marketInfo.WriteString("Current Order Book:\n") if len(orderBook.Asks) > 0 { marketInfo.WriteString("Top 3 asks (Sell orders): \n") for i := 0; i < 3 && i < len(orderBook.Asks); i++ { marketInfo.WriteString(fmt.Sprintf(" %s @ %s\n", orderBook.Asks[i].Volume.String(), orderBook.Asks[i].Price.String())) } } if len(orderBook.Bids) > 0 { marketInfo.WriteString("Top 3 bids (Buy orders): \n") for i := 0; i < 3 && i < len(orderBook.Bids); i++ { marketInfo.WriteString(fmt.Sprintf(" %s @ %s\n", orderBook.Bids[i].Volume.String(), orderBook.Bids[i].Price.String())) } } return marketInfo.String(), nil }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/luno/luno-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server