Documentation
¶
Overview ¶
Package utils provides utility functions for MCPShell
Package utils provides utility functions for testing and development ¶
Package utils provides utility functions for MCPShell
Index ¶
- Constants
- Variables
- func EnsureToolsDir() error
- func FindBestAvailableModel() (string, bool, error)
- func GetHome() (string, error)
- func GetMCPShellHome() (string, error)
- func GetMCPShellToolsDir() (string, error)
- func IsModelToolCapable(modelName string) bool
- func IsOllamaRunning() bool
- func RequireOllama(t *testing.T) string
- func RequireOllamaWithTools(t *testing.T) string
- func ResolveToolsFile(toolsFile string) (string, error)
- func SkipIfOllamaNotRunning(t *testing.T)
- type ModelDetails
- type OllamaModel
- type OllamaModelsResponse
Constants ¶
const ( // MCPShellDirEnv is the environment variable that specifies the configuration directory for MCPShell MCPShellDirEnv = "MCPSHELL_DIR" // MCPShellToolsDirEnv is the environment variable that specifies the tools directory for MCPShell MCPShellToolsDirEnv = "MCPSHELL_TOOLS_DIR" // MCPShellHome is the name of the configuration directory for MCPShell MCPShellHome = ".mcpshell" // MCPShellToolsDir is the name of the tools directory within MCPShell home MCPShellToolsDir = "tools" )
Variables ¶
var PreferredModels = []string{
"qwen2.5:14b",
"qwen2.5:7b",
"qwen2.5:3b",
"qwen2.5:1.5b",
"llama3.1:8b",
"llama3.1:7b",
"llama3.2:3b",
"llama3.2:1b",
"mistral:7b",
"phi3:3.8b",
"phi3:mini",
}
PreferredModels defines the order of preference for testing models These models are known to support tools/function calling
var ToolCapableModels = map[string]bool{ "qwen": true, "qwen2": true, "qwen2.5": true, "llama3": true, "llama3.1": true, "llama3.2": true, "mistral": true, "phi3": true, "gemma": false, "codellama": false, }
ToolCapableModels contains model families known to support tools
Functions ¶
func EnsureToolsDir ¶
func EnsureToolsDir() error
EnsureToolsDir creates the tools directory if it doesn't exist
func FindBestAvailableModel ¶
FindBestAvailableModel finds the best available model for testing Returns the model name and whether it supports tools
func GetMCPShellHome ¶
GetMCPShellHome returns the MCPShell configuration directory This is typically ~/.mcpshell on Unix-like systems or %USERPROFILE%\.mcpshell on Windows
func GetMCPShellToolsDir ¶
GetMCPShellToolsDir returns the MCPShell tools directory This is typically ~/.mcpshell/tools on Unix-like systems or %USERPROFILE%\.mcpshell\tools on Windows
func IsModelToolCapable ¶
IsModelToolCapable checks if a model supports tools based on its family
func IsOllamaRunning ¶
func IsOllamaRunning() bool
IsOllamaRunning checks if Ollama server is running and accessible
func RequireOllama ¶
RequireOllama skips the test if Ollama is not running but returns any available model
func RequireOllamaWithTools ¶
RequireOllamaWithTools skips the test if Ollama is not running or no tool-capable models are available
func ResolveToolsFile ¶
ResolveToolsFile resolves a tools file path with the following logic: 1. If the file path is absolute, use it as-is 2. If the file path is relative, first check current directory, then tools directory 3. If the file doesn't have an extension, append .yaml 4. Return an error if the resolved file doesn't exist
func SkipIfOllamaNotRunning ¶
SkipIfOllamaNotRunning skips the test if Ollama is not running
Types ¶
type ModelDetails ¶
type ModelDetails struct {
Format string `json:"format"`
Family string `json:"family"`
Families []string `json:"families"`
ParameterSize string `json:"parameter_size"`
QuantizationLevel string `json:"quantization_level"`
}
ModelDetails contains detailed information about a model
type OllamaModel ¶
type OllamaModel struct {
Name string `json:"name"`
ModifiedAt time.Time `json:"modified_at"`
Size int64 `json:"size"`
Digest string `json:"digest"`
Details ModelDetails `json:"details"`
}
OllamaModel represents a model available in Ollama
func GetAvailableModels ¶
func GetAvailableModels() ([]OllamaModel, error)
GetAvailableModels retrieves the list of models available in Ollama
type OllamaModelsResponse ¶
type OllamaModelsResponse struct {
Models []OllamaModel `json:"models"`
}
OllamaModelsResponse represents the response from Ollama's models API