server

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 17, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package server implements the MCP server functionality.

It handles loading tool configurations, starting the server, and processing requests from AI clients using the MCP protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ConfigFile         string         // Path to the YAML configuration file
	Shell              string         // Shell to use for executing commands
	Logger             *common.Logger // Logger for server operations
	Version            string         // Version string for the server
	Description        string         // Description shown to AI clients
	DescriptionFile    string         // Path to a file containing the description
	DescriptionAdd     string         // Additional text to add to the description
	DescriptionAddFile string         // Path to a file containing additional description text
}

Config contains the configuration options for creating a new Server

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server represents the MCPShell server that handles tool registration and request processing.

func New

func New(cfg Config) *Server

New creates a new Server instance with the provided configuration

Parameters:

  • cfg: The server configuration

Returns:

  • A new Server instance

func (*Server) CreateServer added in v0.0.14

func (s *Server) CreateServer() error

CreateServer initializes the MCP server instance

func (*Server) ExecuteTool added in v0.0.14

func (s *Server) ExecuteTool(ctx context.Context, toolName string, args map[string]interface{}) (string, error)

ExecuteTool executes a specific tool with the given parameters Used by the agent to execute tools requested by the LLM

func (*Server) GetOpenAITools added in v0.0.14

func (s *Server) GetOpenAITools() ([]openai.Tool, error)

convertMCPToolsToOpenAI converts MCP tools to OpenAI tool format

func (*Server) GetTools added in v0.0.14

func (s *Server) GetTools() ([]mcp.Tool, error)

GetTools returns all available MCP tools from the server Used by the agent to get tools for the LLM

func (*Server) Start

func (s *Server) Start() error

Start initializes the MCP server, loads tools from the configuration file, and starts listening for client connections.

Returns:

  • An error if server initialization or startup fails

func (*Server) Validate

func (s *Server) Validate() error

Validate verifies the configuration file without starting the server. It loads the configuration, attempts to compile all constraints, and checks for errors.

Returns:

  • nil if the configuration is valid
  • An error describing validation failures

Jump to

Keyboard shortcuts

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