mcp

package
v1.68.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath() string

DefaultConfigPath returns the default MCP config file path.

Types

type MCPTool

type MCPTool struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	Parameters  map[string]interface{} `json:"inputSchema"`
	ServerName  string                 `json:"-"`
}

MCPTool represents a tool discovered from an MCP server.

type MCPToolResult

type MCPToolResult struct {
	Content  string `json:"content"`
	IsError  bool   `json:"isError,omitempty"`
	MimeType string `json:"mimeType,omitempty"`
}

MCPToolResult is the result of executing an MCP tool.

type Manager

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

Manager manages MCP server connections and tool routing.

func NewManager

func NewManager(logger *zap.Logger) *Manager

NewManager creates a new MCP manager.

func (*Manager) ExecuteTool

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

ExecuteTool executes an MCP tool by name.

func (*Manager) GetServerStatus

func (m *Manager) GetServerStatus() []ServerStatus

GetServerStatus returns status for all servers.

func (*Manager) GetTools

func (m *Manager) GetTools() []models.ToolDefinition

GetTools returns all discovered MCP tools as ToolDefinitions.

func (*Manager) IsMCPTool

func (m *Manager) IsMCPTool(name string) bool

IsMCPTool checks if a tool name is an MCP tool.

func (*Manager) LoadConfig

func (m *Manager) LoadConfig(configPath string) error

LoadConfig loads MCP server configurations from a JSON file.

func (*Manager) StartAll

func (m *Manager) StartAll(ctx context.Context) error

StartAll starts all configured MCP servers.

func (*Manager) StopAll

func (m *Manager) StopAll()

StopAll stops all running MCP servers.

type ServerConfig

type ServerConfig struct {
	Name      string            `json:"name"`
	Command   string            `json:"command"`
	Args      []string          `json:"args,omitempty"`
	Env       map[string]string `json:"env,omitempty"`
	Transport TransportType     `json:"transport"`
	URL       string            `json:"url,omitempty"` // For SSE transport
	Enabled   bool              `json:"enabled"`
}

ServerConfig represents a configured MCP server.

type ServerConnection

type ServerConnection struct {
	Config  ServerConfig
	Status  ServerStatus
	Process *os.Process
}

ServerConnection represents an active MCP server.

type ServerStatus

type ServerStatus struct {
	Name      string
	Connected bool
	ToolCount int
	LastPing  time.Time
	LastError error
	StartedAt time.Time
}

ServerStatus tracks the health of an MCP server connection.

type TransportType

type TransportType string

TransportType defines MCP transport mechanism.

const (
	TransportStdio TransportType = "stdio"
	TransportSSE   TransportType = "sse"
)

Jump to

Keyboard shortcuts

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