config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: MIT Imports: 8 Imported by: 0

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 MCPToolConfig) 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

func ResolveConfigPath(configPath string, logger *common.Logger) (string, func(), error)

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 {
	// Prompts is a list of prompts that will be provided to clients
	Prompts []Prompts `yaml:"prompts,omitempty"`

	// 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

func NewConfigFromFile(filepath string) (*Config, error)

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

func (*Config) GetTools

func (c *Config) GetTools() []Tool

GetTools converts the configuration's tool definitions into a list of executable ToolDefinition objects ready to be registered with the MCP server.

Returns:

  • A slice of ToolDefinition objects

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 []MCPToolConfig `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 MCPToolConfig added in v0.0.14

type MCPToolConfig struct {
	// Name is the unique identifier for the tool
	Name string `yaml:"name"`

	// 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 MCPToolRunConfig `yaml:"run"`

	// Output specifies how to format the tool's output
	Output common.OutputConfig `yaml:"output,omitempty"`
}

MCPToolConfig represents a single tool configuration.

type MCPToolRequirements added in v0.0.14

type MCPToolRequirements 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"`
}

MCPToolRequirements 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.

type MCPToolRunConfig added in v0.0.14

type MCPToolRunConfig struct {
	// 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"`

	// Runners is a list of possible runner configurations
	Runners []MCPToolRunner `yaml:"runners,omitempty"`
}

MCPToolRunConfig represents the run configuration for a tool.

type MCPToolRunner added in v0.1.0

type MCPToolRunner struct {
	// Name is the identifier for this runner (e.g., "osx", "linux")
	Name string `yaml:"name"`

	// Requirements are the prerequisites for this runner to be used
	Requirements MCPToolRequirements `yaml:"requirements,omitempty"`

	// Options for the runner
	Options map[string]interface{} `yaml:"options,omitempty"`
}

MCPToolRunner represents a specific execution environment for a tool.

type Prompts added in v0.0.14

type Prompts struct {
	// System is a list of system prompts
	System []string `yaml:"system,omitempty"`

	// User is a list of user prompts
	User []string `yaml:"user,omitempty"`
}

Prompts is a list of prompts that could be provided to clients

type Tool

type Tool struct {
	// MCPTool is the MCP client-facing tool definition
	MCPTool mcp.Tool

	// Config is the original tool configuration
	Config MCPToolConfig

	// SelectedRunner is the runner that will be used to execute the tool command
	// This is set during validation when a suitable runner is found
	SelectedRunner *MCPToolRunner
}

Tool holds an MCP tool and its associated handling information.

func (*Tool) GetEffectiveCommand added in v0.1.0

func (t *Tool) GetEffectiveCommand() string

GetEffectiveCommand returns the command template that should be used. Since the command is now always defined at the MCPToolRunConfig level, we simply return it directly.

func (*Tool) GetEffectiveOptions added in v0.1.0

func (t *Tool) GetEffectiveOptions() map[string]interface{}

GetEffectiveOptions returns the runner options from the selected runner.

func (*Tool) GetEffectiveRunner added in v0.1.0

func (t *Tool) GetEffectiveRunner() string

GetEffectiveRunner returns the runner type that should be used.

Jump to

Keyboard shortcuts

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