common

package
v0.0.0-...-797c7bc Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Encode

func Base64Encode(input string) string

Base64Encode encodes the input string to Base64 format

func ContainsStatusCode

func ContainsStatusCode(codes []int, statusCode int) bool

func ExtractParams

func ExtractParams(request mcp.CallToolRequest, params_list []string) map[string]string

ExtractParams extracts params key from the tool call request and convert them into a map

func FormatCywareToken

func FormatCywareToken(rawToken string) string

func GenerateAuthParams

func GenerateAuthParams(accessID, secretKey string) map[string]string

GenerateAuthParams generates authentication parameters

func GetDomain

func GetDomain(baseURL string) string

GetDomain extracts and returns the scheme and host (i.e., domain) from the given base URL. For example, "https://example.com/api" -> "https://example.com".

func GetRestyClient

func GetRestyClient(retryHook func(r *resty.Response, err error)) *resty.Client

func JsonifyResponse

func JsonifyResponse(obj any) any

func MCPToolResponse

func MCPToolResponse(resp *APIResponse, expected_status_code []int, err error) (*mcp.CallToolResult, error)

Types

type APIClient

type APIClient struct {
	Client   *resty.Client
	BASE_URL string
}

func (*APIClient) MakeRequest

func (a *APIClient) MakeRequest(method string, endpoint string, queryParams map[string]string, result any, payload any, headers map[string]string) (*resty.Response, error)

type APIResponse

type APIResponse struct {
	RawResponse     *resty.Response
	FilteredReponse any
}

type Application

type Application struct {
	BASE_URL string `mapstructure:"base_url"`
	Auth     Auth   `mapstructure:"auth"`
}

Application defines the configuration for an external application, including its base URL and authentication credentials.

type Auth

type Auth struct {
	Type      string `mapstructure:"type"`
	Username  string `mapstructure:"username,omitempty"`
	Password  string `mapstructure:"password,omitempty"`
	Token     string `mapstructure:"token,omitempty"`
	AccessID  string `mapstructure:"access_id,omitempty"`
	SecretKey string `mapstructure:"secret_key,omitempty"`
}

Auth defines the authentication configuration for an application. It supports different auth types like "basic", "token".

type Config

type Config struct {
	Applications map[string]Application `mapstructure:"applications"`
	Server       Server                 `mapstructure:"server"`
}

Config holds the top-level configuration structure loaded from a YAML file. It includes all application definitions and the server settings.

func Load

func Load(path string) (*Config, error)

Load reads and parses the YAML config file at the given path, and returns a populated Config struct. It returns an error if the file can't be read or parsed.

type Server

type Server struct {
	MCPMode string `mapstructure:"mcp_mode"`
	Port    string `mapstructure:"port"`
}

Server holds configuration settings for the MCP server, including the mode (e.g., "stdio", "sse") and the port it listens on.

Jump to

Keyboard shortcuts

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