Documentation
¶
Index ¶
- Constants
- func SaveMCPConfig(mcpConfig MCPConfig) error
- type AgentTool
- type DefaultMCPManager
- func (m *DefaultMCPManager) AddServer(config MCPServerConfig) error
- func (m *DefaultMCPManager) AutoDiscoverGitHubServer(ctx context.Context) error
- func (m *DefaultMCPManager) CallTool(ctx context.Context, serverName, toolName string, args map[string]interface{}) (*MCPToolCallResult, error)
- func (m *DefaultMCPManager) GetAllTools(ctx context.Context) ([]MCPTool, error)
- func (m *DefaultMCPManager) GetServer(name string) (MCPServer, bool)
- func (m *DefaultMCPManager) GetServerStats() map[string]interface{}
- func (m *DefaultMCPManager) ListServers() []MCPServer
- func (m *DefaultMCPManager) RemoveServer(name string) error
- func (m *DefaultMCPManager) StartAll(ctx context.Context) error
- func (m *DefaultMCPManager) StopAll(ctx context.Context) error
- type EnvVarTemplate
- type MCPClient
- func (c *MCPClient) CallTool(ctx context.Context, request MCPToolCallRequest) (*MCPToolCallResult, error)
- func (c *MCPClient) GetConfig() MCPServerConfig
- func (c *MCPClient) GetName() string
- func (c *MCPClient) GetPrompt(ctx context.Context, name string, args map[string]interface{}) (*MCPContent, error)
- func (c *MCPClient) Initialize(ctx context.Context) error
- func (c *MCPClient) IsRunning() bool
- func (c *MCPClient) ListPrompts(ctx context.Context) ([]MCPPrompt, error)
- func (c *MCPClient) ListResources(ctx context.Context) ([]MCPResource, error)
- func (c *MCPClient) ListTools(ctx context.Context) ([]MCPTool, error)
- func (c *MCPClient) ReadResource(ctx context.Context, uri string) (*MCPContent, error)
- func (c *MCPClient) Start(ctx context.Context) error
- func (c *MCPClient) Stop(ctx context.Context) error
- type MCPConfig
- func (c *MCPConfig) AddGitHubServer(githubToken string)
- func (c *MCPConfig) AddServer(serverConfig MCPServerConfig) error
- func (c *MCPConfig) GetConfigSummary() map[string]interface{}
- func (c *MCPConfig) GetEnabledServers() []MCPServerConfig
- func (c *MCPConfig) HasGitHubToken() bool
- func (c *MCPConfig) RemoveServer(name string)
- func (c *MCPConfig) UnmarshalJSON(data []byte) error
- func (c *MCPConfig) ValidateConfig() error
- type MCPContent
- type MCPError
- type MCPHTTPClient
- func (c *MCPHTTPClient) CallTool(ctx context.Context, request MCPToolCallRequest) (*MCPToolCallResult, error)
- func (c *MCPHTTPClient) GetConfig() MCPServerConfig
- func (c *MCPHTTPClient) GetName() string
- func (c *MCPHTTPClient) GetPrompt(ctx context.Context, name string, args map[string]interface{}) (*MCPContent, error)
- func (c *MCPHTTPClient) Initialize(ctx context.Context) error
- func (c *MCPHTTPClient) IsRunning() bool
- func (c *MCPHTTPClient) ListPrompts(ctx context.Context) ([]MCPPrompt, error)
- func (c *MCPHTTPClient) ListResources(ctx context.Context) ([]MCPResource, error)
- func (c *MCPHTTPClient) ListTools(ctx context.Context) ([]MCPTool, error)
- func (c *MCPHTTPClient) ReadResource(ctx context.Context, uri string) (*MCPContent, error)
- func (c *MCPHTTPClient) Start(ctx context.Context) error
- func (c *MCPHTTPClient) Stop(ctx context.Context) error
- type MCPManager
- type MCPMessage
- type MCPPrompt
- type MCPPromptArgument
- type MCPResource
- type MCPServer
- type MCPServerConfig
- type MCPServerRegistry
- func (r *MCPServerRegistry) AddTemplate(template MCPServerTemplate) error
- func (r *MCPServerRegistry) GetTemplate(id string) (MCPServerTemplate, bool)
- func (r *MCPServerRegistry) GetTemplatesByType(serverType string) []MCPServerTemplate
- func (r *MCPServerRegistry) ListTemplates() []MCPServerTemplate
- func (r *MCPServerRegistry) SearchTemplates(query string) []MCPServerTemplate
- type MCPServerTemplate
- type MCPTool
- type MCPToolCallRequest
- type MCPToolCallResult
- type MCPToolWrapper
- func (w *MCPToolWrapper) CanExecute(ctx context.Context, params Parameters) bool
- func (w *MCPToolWrapper) Category() string
- func (w *MCPToolWrapper) Description() string
- func (w *MCPToolWrapper) EstimatedDuration() time.Duration
- func (w *MCPToolWrapper) Execute(ctx context.Context, params Parameters) (*Result, error)
- func (w *MCPToolWrapper) GetMCPTool() MCPTool
- func (w *MCPToolWrapper) GetServerName() string
- func (w *MCPToolWrapper) GetToolName() string
- func (w *MCPToolWrapper) IsAvailable() bool
- func (w *MCPToolWrapper) Name() string
- func (w *MCPToolWrapper) RequiredPermissions() []string
- func (w *MCPToolWrapper) SetAvailable(available bool)
- func (w *MCPToolWrapper) SetCategory(category string)
- func (w *MCPToolWrapper) SetTimeout(timeout time.Duration)
- func (w *MCPToolWrapper) ToAgentTool() AgentTool
- func (w *MCPToolWrapper) ValidateArgs(args map[string]interface{}) error
- type Parameters
- type Result
Constants ¶
const ( CategoryWeb = "web" PermissionNetworkAccess = "network_access" )
Local constants to avoid importing tools package and creating cycle
const ( ErrorCodeParse = -32700 ErrorCodeInvalidRequest = -32600 ErrorCodeMethodNotFound = -32601 ErrorCodeInvalidParams = -32602 ErrorCodeInternalError = -32603 )
Standard error codes
Variables ¶
This section is empty.
Functions ¶
func SaveMCPConfig ¶
SaveMCPConfig saves MCP configuration to file
Types ¶
type AgentTool ¶
type AgentTool struct { Type string `json:"type"` Function struct { Name string `json:"name"` Description string `json:"description"` Parameters interface{} `json:"parameters"` } `json:"function"` }
AgentTool represents the agent's tool format for compatibility
type DefaultMCPManager ¶
type DefaultMCPManager struct {
// contains filtered or unexported fields
}
DefaultMCPManager implements the MCPManager interface
func NewMCPManager ¶
func NewMCPManager(logger *utils.Logger) *DefaultMCPManager
NewMCPManager creates a new MCP manager
func (*DefaultMCPManager) AddServer ¶
func (m *DefaultMCPManager) AddServer(config MCPServerConfig) error
AddServer adds a new MCP server
func (*DefaultMCPManager) AutoDiscoverGitHubServer ¶
func (m *DefaultMCPManager) AutoDiscoverGitHubServer(ctx context.Context) error
AutoDiscoverTools attempts to discover and start GitHub MCP server automatically
func (*DefaultMCPManager) CallTool ¶
func (m *DefaultMCPManager) CallTool(ctx context.Context, serverName, toolName string, args map[string]interface{}) (*MCPToolCallResult, error)
CallTool calls a tool on the appropriate server
func (*DefaultMCPManager) GetAllTools ¶
func (m *DefaultMCPManager) GetAllTools(ctx context.Context) ([]MCPTool, error)
GetAllTools gets all tools from all running servers
func (*DefaultMCPManager) GetServer ¶
func (m *DefaultMCPManager) GetServer(name string) (MCPServer, bool)
GetServer gets an MCP server by name
func (*DefaultMCPManager) GetServerStats ¶
func (m *DefaultMCPManager) GetServerStats() map[string]interface{}
GetServerStats returns statistics about all servers
func (*DefaultMCPManager) ListServers ¶
func (m *DefaultMCPManager) ListServers() []MCPServer
ListServers lists all registered servers
func (*DefaultMCPManager) RemoveServer ¶
func (m *DefaultMCPManager) RemoveServer(name string) error
RemoveServer removes an MCP server
type EnvVarTemplate ¶
type EnvVarTemplate struct { Name string `json:"name"` Description string `json:"description"` Required bool `json:"required"` Secret bool `json:"secret"` // Should be masked in display Default string `json:"default"` // Default value if any }
EnvVarTemplate represents a required environment variable
type MCPClient ¶
type MCPClient struct {
// contains filtered or unexported fields
}
MCPClient implements the MCPServer interface for subprocess-based MCP servers
func NewMCPClient ¶
func NewMCPClient(config MCPServerConfig, logger *utils.Logger) *MCPClient
NewMCPClient creates a new MCP client for a server
func (*MCPClient) CallTool ¶
func (c *MCPClient) CallTool(ctx context.Context, request MCPToolCallRequest) (*MCPToolCallResult, error)
CallTool calls a tool on the server
func (*MCPClient) GetConfig ¶
func (c *MCPClient) GetConfig() MCPServerConfig
GetConfig returns the server configuration
func (*MCPClient) GetPrompt ¶
func (c *MCPClient) GetPrompt(ctx context.Context, name string, args map[string]interface{}) (*MCPContent, error)
GetPrompt gets a prompt from the server
func (*MCPClient) Initialize ¶
Initialize sends initialize request to server
func (*MCPClient) ListPrompts ¶
ListPrompts lists available prompts from the server
func (*MCPClient) ListResources ¶
func (c *MCPClient) ListResources(ctx context.Context) ([]MCPResource, error)
ListResources lists available resources from the server
func (*MCPClient) ReadResource ¶
ReadResource reads a resource from the server
type MCPConfig ¶
type MCPConfig struct { Enabled bool `json:"enabled"` Servers map[string]MCPServerConfig `json:"servers"` AutoStart bool `json:"auto_start"` AutoDiscover bool `json:"auto_discover"` Timeout time.Duration `json:"timeout"` }
MCPConfig represents the MCP configuration
func DefaultMCPConfig ¶
func DefaultMCPConfig() MCPConfig
DefaultMCPConfig returns the default MCP configuration
func LoadMCPConfig ¶
LoadMCPConfig loads MCP configuration from file
func (*MCPConfig) AddGitHubServer ¶
AddGitHubServer adds a GitHub MCP server to the configuration
func (*MCPConfig) AddServer ¶
func (c *MCPConfig) AddServer(serverConfig MCPServerConfig) error
AddServer adds a custom MCP server to the configuration
func (*MCPConfig) GetConfigSummary ¶
GetConfigSummary returns a summary of the current MCP configuration
func (*MCPConfig) GetEnabledServers ¶
func (c *MCPConfig) GetEnabledServers() []MCPServerConfig
GetEnabledServers returns a list of servers that should be started
func (*MCPConfig) HasGitHubToken ¶
HasGitHubToken checks if a GitHub token is configured for any server
func (*MCPConfig) RemoveServer ¶
RemoveServer removes an MCP server from the configuration
func (*MCPConfig) UnmarshalJSON ¶ added in v0.6.0
UnmarshalJSON implements custom JSON unmarshaling for MCPConfig to handle timeout as string or duration
func (*MCPConfig) ValidateConfig ¶
ValidateConfig validates the MCP configuration
type MCPContent ¶
type MCPContent struct { Type string `json:"type"` Text string `json:"text,omitempty"` Data string `json:"data,omitempty"` MimeType string `json:"mimeType,omitempty"` Annotations map[string]interface{} `json:"annotations,omitempty"` }
MCPContent represents content in MCP responses
type MCPError ¶
type MCPError struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data,omitempty"` }
MCPError represents an MCP protocol error
type MCPHTTPClient ¶
type MCPHTTPClient struct {
// contains filtered or unexported fields
}
MCPHTTPClient represents an HTTP-based MCP client for remote servers
func NewMCPHTTPClient ¶
func NewMCPHTTPClient(config MCPServerConfig, logger *utils.Logger) *MCPHTTPClient
NewMCPHTTPClient creates a new HTTP MCP client
func (*MCPHTTPClient) CallTool ¶
func (c *MCPHTTPClient) CallTool(ctx context.Context, request MCPToolCallRequest) (*MCPToolCallResult, error)
CallTool calls a tool on the server
func (*MCPHTTPClient) GetConfig ¶
func (c *MCPHTTPClient) GetConfig() MCPServerConfig
GetConfig returns the server configuration
func (*MCPHTTPClient) GetName ¶
func (c *MCPHTTPClient) GetName() string
GetName returns the server name
func (*MCPHTTPClient) GetPrompt ¶
func (c *MCPHTTPClient) GetPrompt(ctx context.Context, name string, args map[string]interface{}) (*MCPContent, error)
GetPrompt gets a prompt from the server
func (*MCPHTTPClient) Initialize ¶
func (c *MCPHTTPClient) Initialize(ctx context.Context) error
Initialize sends initialize request to the server
func (*MCPHTTPClient) IsRunning ¶
func (c *MCPHTTPClient) IsRunning() bool
IsRunning checks if the client is running
func (*MCPHTTPClient) ListPrompts ¶
func (c *MCPHTTPClient) ListPrompts(ctx context.Context) ([]MCPPrompt, error)
ListPrompts lists available prompts from the server
func (*MCPHTTPClient) ListResources ¶
func (c *MCPHTTPClient) ListResources(ctx context.Context) ([]MCPResource, error)
ListResources lists available resources from the server
func (*MCPHTTPClient) ListTools ¶
func (c *MCPHTTPClient) ListTools(ctx context.Context) ([]MCPTool, error)
ListTools lists available tools from the server
func (*MCPHTTPClient) ReadResource ¶
func (c *MCPHTTPClient) ReadResource(ctx context.Context, uri string) (*MCPContent, error)
ReadResource reads a resource from the server
type MCPManager ¶
type MCPManager interface { // AddServer adds a new MCP server AddServer(config MCPServerConfig) error // RemoveServer removes an MCP server RemoveServer(name string) error // GetServer gets an MCP server by name GetServer(name string) (MCPServer, bool) // ListServers lists all registered servers ListServers() []MCPServer // StartAll starts all configured servers StartAll(ctx context.Context) error // StopAll stops all running servers StopAll(ctx context.Context) error // GetAllTools gets all tools from all running servers GetAllTools(ctx context.Context) ([]MCPTool, error) // CallTool calls a tool on the appropriate server CallTool(ctx context.Context, serverName, toolName string, args map[string]interface{}) (*MCPToolCallResult, error) }
MCPManager manages multiple MCP servers
type MCPMessage ¶
type MCPMessage struct { JSONRPC string `json:"jsonrpc"` ID interface{} `json:"id,omitempty"` Method string `json:"method,omitempty"` Params interface{} `json:"params,omitempty"` Result interface{} `json:"result,omitempty"` Error *MCPError `json:"error,omitempty"` }
MCPMessage represents an MCP protocol message
type MCPPrompt ¶
type MCPPrompt struct { Name string `json:"name"` Description string `json:"description,omitempty"` Arguments []MCPPromptArgument `json:"arguments,omitempty"` ServerName string `json:"server_name"` }
MCPPrompt represents a prompt available via MCP
type MCPPromptArgument ¶
type MCPPromptArgument struct { Name string `json:"name"` Description string `json:"description,omitempty"` Required bool `json:"required"` }
MCPPromptArgument represents a prompt argument
type MCPResource ¶
type MCPResource struct { URI string `json:"uri"` Name string `json:"name"` Description string `json:"description,omitempty"` MimeType string `json:"mimeType,omitempty"` ServerName string `json:"server_name"` }
MCPResource represents a resource available via MCP
type MCPServer ¶
type MCPServer interface { // Start starts the MCP server process Start(ctx context.Context) error // Stop stops the MCP server process Stop(ctx context.Context) error // IsRunning checks if the server is running IsRunning() bool // GetName returns the server name GetName() string // GetConfig returns the server configuration GetConfig() MCPServerConfig // Initialize sends initialize request to server Initialize(ctx context.Context) error // ListTools lists available tools from the server ListTools(ctx context.Context) ([]MCPTool, error) // CallTool calls a tool on the server CallTool(ctx context.Context, request MCPToolCallRequest) (*MCPToolCallResult, error) // ListResources lists available resources from the server ListResources(ctx context.Context) ([]MCPResource, error) // ReadResource reads a resource from the server ReadResource(ctx context.Context, uri string) (*MCPContent, error) // ListPrompts lists available prompts from the server ListPrompts(ctx context.Context) ([]MCPPrompt, error) // GetPrompt gets a prompt from the server GetPrompt(ctx context.Context, name string, args map[string]interface{}) (*MCPContent, error) }
MCPServer represents an MCP server interface
type MCPServerConfig ¶
type MCPServerConfig struct { Name string `json:"name"` Type string `json:"type,omitempty"` // "stdio" or "http" Command string `json:"command,omitempty"` // For stdio servers Args []string `json:"args,omitempty"` // For stdio servers URL string `json:"url,omitempty"` // For HTTP servers Env map[string]string `json:"env,omitempty"` WorkingDir string `json:"working_dir,omitempty"` // For stdio servers Timeout time.Duration `json:"timeout,omitempty"` AutoStart bool `json:"auto_start"` MaxRestarts int `json:"max_restarts"` }
MCPServerConfig represents the configuration for an MCP server
func GetGitHubServerConfig ¶
func GetGitHubServerConfig() MCPServerConfig
GetGitHubServerConfig returns a default GitHub MCP server configuration
func GetPlaywrightServerConfig ¶ added in v0.8.3
func GetPlaywrightServerConfig() MCPServerConfig
GetPlaywrightServerConfig returns a default Playwright MCP server configuration
func GetPlaywrightServerConfigUvx ¶ added in v0.8.3
func GetPlaywrightServerConfigUvx() MCPServerConfig
GetPlaywrightServerConfigUvx returns a Playwright MCP server configuration using uvx
func (*MCPServerConfig) UnmarshalJSON ¶ added in v0.6.0
func (s *MCPServerConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for MCPServerConfig to handle timeout as string or duration
type MCPServerRegistry ¶
type MCPServerRegistry struct {
// contains filtered or unexported fields
}
MCPServerRegistry holds templates for known MCP servers
func NewMCPServerRegistry ¶
func NewMCPServerRegistry() *MCPServerRegistry
NewMCPServerRegistry creates a new server registry with built-in templates
func (*MCPServerRegistry) AddTemplate ¶
func (r *MCPServerRegistry) AddTemplate(template MCPServerTemplate) error
AddTemplate adds a custom template to the registry
func (*MCPServerRegistry) GetTemplate ¶
func (r *MCPServerRegistry) GetTemplate(id string) (MCPServerTemplate, bool)
GetTemplate returns a server template by ID
func (*MCPServerRegistry) GetTemplatesByType ¶
func (r *MCPServerRegistry) GetTemplatesByType(serverType string) []MCPServerTemplate
GetTemplatesByType returns templates of a specific type
func (*MCPServerRegistry) ListTemplates ¶
func (r *MCPServerRegistry) ListTemplates() []MCPServerTemplate
ListTemplates returns all available templates
func (*MCPServerRegistry) SearchTemplates ¶
func (r *MCPServerRegistry) SearchTemplates(query string) []MCPServerTemplate
SearchTemplates searches for templates by name or description
type MCPServerTemplate ¶
type MCPServerTemplate struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` Type string `json:"type"` // "stdio", "http" URL string `json:"url"` // For HTTP servers Command string `json:"command"` // For stdio servers Args []string `json:"args"` // For stdio servers EnvVars []EnvVarTemplate `json:"env_vars"` // Required environment variables Timeout time.Duration `json:"timeout"` Features []string `json:"features"` // List of capabilities AuthType string `json:"auth_type"` // "bearer", "basic", "none" Docs string `json:"docs"` // Documentation URL }
MCPServerTemplate represents a template for creating MCP servers
func (*MCPServerTemplate) CreateServerConfig ¶
func (template *MCPServerTemplate) CreateServerConfig(name string, envValues map[string]string, customURL string, customCommand string, customArgs []string) MCPServerConfig
CreateServerConfig creates a server config from a template with user values
type MCPTool ¶
type MCPTool struct { Name string `json:"name"` Description string `json:"description"` InputSchema map[string]interface{} `json:"inputSchema"` ServerName string `json:"server_name"` }
MCPTool represents a tool available via MCP
type MCPToolCallRequest ¶
type MCPToolCallRequest struct { Name string `json:"name"` Arguments map[string]interface{} `json:"arguments,omitempty"` }
MCPToolCallRequest represents a tool call request
type MCPToolCallResult ¶
type MCPToolCallResult struct { Content []MCPContent `json:"content"` IsError bool `json:"isError"` }
MCPToolCallResult represents a tool call result
type MCPToolWrapper ¶
type MCPToolWrapper struct {
// contains filtered or unexported fields
}
MCPToolWrapper wraps an MCP tool to implement the standard Tool interface
func NewMCPToolWrapper ¶
func NewMCPToolWrapper(mcpTool MCPTool, manager MCPManager) *MCPToolWrapper
NewMCPToolWrapper creates a new wrapper for an MCP tool to implement the standard Tool interface
func (*MCPToolWrapper) CanExecute ¶
func (w *MCPToolWrapper) CanExecute(ctx context.Context, params Parameters) bool
CanExecute checks if the tool can be executed with the current context
func (*MCPToolWrapper) Category ¶
func (w *MCPToolWrapper) Category() string
Category returns the category this tool belongs to
func (*MCPToolWrapper) Description ¶
func (w *MCPToolWrapper) Description() string
Description returns a human-readable description of what the tool does
func (*MCPToolWrapper) EstimatedDuration ¶
func (w *MCPToolWrapper) EstimatedDuration() time.Duration
EstimatedDuration returns an estimate of how long the tool will take to execute
func (*MCPToolWrapper) Execute ¶
func (w *MCPToolWrapper) Execute(ctx context.Context, params Parameters) (*Result, error)
Execute runs the tool with the given context and parameters
func (*MCPToolWrapper) GetMCPTool ¶
func (w *MCPToolWrapper) GetMCPTool() MCPTool
GetMCPTool returns the underlying MCP tool
func (*MCPToolWrapper) GetServerName ¶
func (w *MCPToolWrapper) GetServerName() string
GetServerName returns the server name
func (*MCPToolWrapper) GetToolName ¶
func (w *MCPToolWrapper) GetToolName() string
GetToolName returns the original tool name (without MCP prefix)
func (*MCPToolWrapper) IsAvailable ¶
func (w *MCPToolWrapper) IsAvailable() bool
IsAvailable checks if the tool is available in the current environment
func (*MCPToolWrapper) Name ¶
func (w *MCPToolWrapper) Name() string
Name returns the unique name of the tool
func (*MCPToolWrapper) RequiredPermissions ¶
func (w *MCPToolWrapper) RequiredPermissions() []string
RequiredPermissions returns the permissions needed to execute this tool
func (*MCPToolWrapper) SetAvailable ¶
func (w *MCPToolWrapper) SetAvailable(available bool)
SetAvailable allows enabling/disabling the tool
func (*MCPToolWrapper) SetCategory ¶
func (w *MCPToolWrapper) SetCategory(category string)
SetCategory allows customizing the tool category
func (*MCPToolWrapper) SetTimeout ¶
func (w *MCPToolWrapper) SetTimeout(timeout time.Duration)
SetTimeout allows customizing the tool timeout
func (*MCPToolWrapper) ToAgentTool ¶
func (w *MCPToolWrapper) ToAgentTool() AgentTool
ToAgentTool converts the MCP tool to the agent's Tool format
func (*MCPToolWrapper) ValidateArgs ¶
func (w *MCPToolWrapper) ValidateArgs(args map[string]interface{}) error
ValidateArgs validates arguments against the tool's input schema
type Parameters ¶ added in v0.6.0
Local type definitions to avoid import cycle