Skip to main content
Glama

DiceDB MCP

by pottekkat
MIT License
5
  • Linux
  • Apple
common.go999 B
// pkg/utils/common.go package utils import ( "fmt" "github.com/dicedb/dicedb-go" "github.com/mark3labs/mcp-go/mcp" ) // CommonURLParam returns the common URL parameter definition used across tools func CommonURLParam() mcp.ToolOption { return mcp.WithString("url", mcp.Description("The URL of the DiceDB server in format 'host:port'"), mcp.DefaultString("localhost:7379"), ) } // GetClientFromRequest creates a DiceDB client from the request parameters func GetClientFromRequest(request mcp.CallToolRequest) (*dicedb.Client, error) { // Get the URL with fallback to default var url string = "localhost:7379" if urlArg, ok := request.Params.Arguments["url"]; ok && urlArg != nil { if urlStr, ok := urlArg.(string); ok && urlStr != "" { url = urlStr } } host, port := parseHostAndPort(url) // Create a new DiceDB client client, err := dicedb.NewClient(host, port) if err != nil { return nil, fmt.Errorf("error connecting to DiceDB: %w", err) } return client, 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/pottekkat/dicedb-mcp'

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