Documentation
¶
Overview ¶
Package config provides configuration loading and handling functionality.
It defines the data structures for representing the application's configuration, which is loaded from YAML files, and includes utilities for parsing and processing these configurations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMCPTool ¶ added in v0.0.10
func CreateMCPTool(config ToolConfig) mcp.Tool
CreateMCPTool creates an MCP tool from a tool configuration.
Parameters:
- config: The tool configuration from which to create the MCP tool
Returns:
- An mcp.Tool object ready to be registered with the MCP server
func ResolveConfigPath ¶
ResolveConfigPath tries to resolve the configuration file path. If the path is a URL, it downloads the file to a temporary location. The function returns the local path to the configuration file and a cleanup function that should be deferred to remove any temporary files.
Types ¶
type Config ¶
type Config struct {
// MCP contains the configuration specific to the MCP server and tools
MCP MCPConfig `yaml:"mcp"`
}
Config represents the top-level configuration structure for the application.
func NewConfigFromFile ¶
NewConfigFromFile loads the configuration from a YAML file at the specified path.
Parameters:
- filepath: Path to the YAML configuration file
Returns:
- A pointer to the loaded Config structure
- An error if loading or parsing fails
type MCPConfig ¶
type MCPConfig struct {
// Description is a text shown to AI clients that explains what this server does
Description string `yaml:"description,omitempty"`
// Run contains runtime configuration
Run MCPRunConfig `yaml:"run,omitempty"`
// Tools is a list of tool definitions that will be provided to clients
Tools []ToolConfig `yaml:"tools"`
}
MCPConfig represents the MCP server configuration section.
type MCPRunConfig ¶
type MCPRunConfig struct {
// Shell is the shell to use for executing commands (e.g., bash, sh, zsh)
Shell string `yaml:"shell,omitempty"`
}
MCPRunConfig represents run-specific configuration options.
type RunConfig ¶
type RunConfig struct {
// Runner is the type of runner to use for executing the command
Runner string `yaml:"runner,omitempty"`
// Command is a template for the shell command to execute
Command string `yaml:"command"`
// Env is a list of environment variable names to pass from the parent process
Env []string `yaml:"env,omitempty"`
// Options for the runner
Options map[string]interface{} `yaml:"options,omitempty"`
}
RunConfig represents the run configuration for a tool.
type Tool ¶
type Tool struct {
// MCPTool is the MCP client-facing tool definition
MCPTool mcp.Tool
// Config is the original tool configuration
Config ToolConfig
}
Tool holds an MCP tool and its associated handling information.
type ToolConfig ¶
type ToolConfig struct {
// Name is the unique identifier for the tool
Name string `yaml:"name"`
// Requirements is a list of tool names that must be executed before this tool
Requirements ToolRequirements `yaml:"requirements,omitempty"`
// Description explains what the tool does (shown to AI clients)
Description string `yaml:"description"`
// Params defines the parameters that the tool accepts
Params map[string]common.ParamConfig `yaml:"params"`
// Constraints are expressions that limit when the tool can be executed
Constraints []string `yaml:"constraints,omitempty"`
// Run specifies how to execute the tool
Run RunConfig `yaml:"run"`
// Output specifies how to format the tool's output
Output common.OutputConfig `yaml:"output,omitempty"`
}
ToolConfig represents a single tool configuration.
type ToolRequirements ¶
type ToolRequirements struct {
// OS is the operating system that the prerequisite tool must be installed on
OS string `yaml:"os,omitempty"`
// Executables is a list of executable names that must be present in the system
Executables []string `yaml:"executables"`
}
ToolRequirements represents a prerequisite tool configuration. If these prerequisites are not met, the tool will not even be shown as available to the client. This allows for tools to be conditionally shown based on the user's system.