Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterConfiguredAPIs ¶
func RegisterConfiguredAPIs() error
RegisterConfiguredAPIs loads API configuration and registers tools
func ResolveEnvVar ¶
ResolveEnvVar resolves an environment variable reference For auth configs, the value should be the environment variable name For other configs that start with $, it's treated as an env var reference
Types ¶
type APIConfig ¶
type APIConfig struct {
APIs map[string]APIDefinition `yaml:"apis"`
}
APIConfig represents the complete configuration for all APIs
func LoadAPIConfig ¶
LoadAPIConfig loads the API configuration from the specified file
type APIDefinition ¶
type APIDefinition struct {
BaseURL string `yaml:"base_url"`
Description string `yaml:"description"`
Auth AuthConfig `yaml:"auth"`
Timeout int `yaml:"timeout"` // timeout in seconds, default 30
CacheTTL int `yaml:"cache_ttl"` // cache TTL in seconds, default 300
Endpoints []EndpointConfig `yaml:"endpoints"`
Headers map[string]string `yaml:"headers"` // additional headers to send with all requests
}
APIDefinition defines a single API configuration
type AuthConfig ¶
type AuthConfig struct {
Type string `yaml:"type"` // "bearer", "api_key", "basic", "none"
EnvVar string `yaml:"env_var"` // environment variable containing the credential
Header string `yaml:"header"` // custom header name for API key auth (default: "X-API-Key")
Location string `yaml:"location"` // "header" or "query" for API key auth (default: "header")
Username string `yaml:"username"` // username for basic auth (can be env var reference)
Password string `yaml:"password"` // password env var for basic auth
}
AuthConfig defines authentication configuration
type BodyConfig ¶
type BodyConfig struct {
Type string `yaml:"type"` // "json", "form", "raw"
ContentType string `yaml:"content_type"` // override content type
Schema map[string]any `yaml:"schema"` // JSON schema for body validation
}
BodyConfig defines request body configuration
type CacheEntry ¶
CacheEntry represents a cached API response
type DynamicAPITool ¶
type DynamicAPITool struct {
// contains filtered or unexported fields
}
DynamicAPITool implements the tools.Tool interface for configured APIs
func NewDynamicAPITool ¶
func NewDynamicAPITool(apiName string, apiDef APIDefinition) *DynamicAPITool
NewDynamicAPITool creates a new dynamic API tool
func (*DynamicAPITool) Definition ¶
func (t *DynamicAPITool) Definition() mcp.Tool
Definition returns the tool's definition for MCP registration
func (*DynamicAPITool) Execute ¶
func (t *DynamicAPITool) Execute(ctx context.Context, logger *logrus.Logger, cache *sync.Map, args map[string]any) (*mcp.CallToolResult, error)
Execute executes the tool's logic
func (*DynamicAPITool) ProvideExtendedInfo ¶
func (t *DynamicAPITool) ProvideExtendedInfo() *tools.ExtendedHelp
ProvideExtendedInfo provides extended help information for the API tool
type EndpointConfig ¶
type EndpointConfig struct {
Name string `yaml:"name"`
Method string `yaml:"method"`
Path string `yaml:"path"`
Description string `yaml:"description"`
Parameters []ParameterConfig `yaml:"parameters"`
Body *BodyConfig `yaml:"body"`
Headers map[string]string `yaml:"headers"` // endpoint-specific headers
}
EndpointConfig defines a single API endpoint
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient wraps http.Client with API-specific configuration
func NewHTTPClient ¶
func NewHTTPClient(apiDef APIDefinition) *HTTPClient
NewHTTPClient creates a new HTTP client for an API with proxy support
func (*HTTPClient) ExecuteRequest ¶
func (c *HTTPClient) ExecuteRequest(ctx context.Context, endpoint EndpointConfig, parameters map[string]any) (map[string]any, error)
ExecuteRequest executes an API request
type ParameterConfig ¶
type ParameterConfig struct {
Name string `yaml:"name"`
Type string `yaml:"type"` // "string", "number", "boolean", "array", "object"
Required bool `yaml:"required"`
Description string `yaml:"description"`
Default any `yaml:"default"`
Enum []string `yaml:"enum"`
Location string `yaml:"location"` // "path", "query", "header"
}
ParameterConfig defines a parameter for an endpoint