Documentation
¶
Overview ¶
Package mcp provides Model Context Protocol client and server management.
Index ¶
- func LoadMCPTools(baseDir string, registry *tools.Registry) error
- type Client
- func (c *Client) CallTool(ctx context.Context, name string, arguments map[string]interface{}) (map[string]interface{}, error)
- func (c *Client) Initialize(ctx context.Context, clientName, clientVersion, protocolVersion string) error
- func (c *Client) ListTools(ctx context.Context) ([]Tool, error)
- func (c *Client) Shutdown() error
- type MCPConfig
- type MCPToolAdapter
- func (a *MCPToolAdapter) AsToolDefinition() core.ToolDefinition
- func (a *MCPToolAdapter) Description() string
- func (a *MCPToolAdapter) Execute(ctx context.Context, params map[string]interface{}) (*tools.Result, error)
- func (a *MCPToolAdapter) GetInputSchema() map[string]interface{}
- func (a *MCPToolAdapter) Name() string
- func (a *MCPToolAdapter) RequiresApproval(_ map[string]interface{}) bool
- type MCPToolManager
- type Registry
- func (r *Registry) AddServer(server ServerConfig) error
- func (r *Registry) ConfigPath() string
- func (r *Registry) Count() int
- func (r *Registry) GetServer(name string) (ServerConfig, error)
- func (r *Registry) ListServers() []ServerConfig
- func (r *Registry) Load() error
- func (r *Registry) RemoveServer(name string) error
- func (r *Registry) Save() error
- func (r *Registry) ServerExists(name string) bool
- func (r *Registry) UpdateServer(server ServerConfig) error
- type ServerConfig
- type ServerInfo
- type Tool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadMCPTools ¶
LoadMCPTools loads MCP server configurations from .mcp.json and registers their tools with the provided tool registry. Returns nil if .mcp.json doesn't exist (graceful skip). Returns error if config is invalid or if any server fails to initialize.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents an MCP client connected to a server via stdio
func (*Client) CallTool ¶
func (c *Client) CallTool(ctx context.Context, name string, arguments map[string]interface{}) (map[string]interface{}, error)
CallTool invokes a tool on the server with the given arguments
func (*Client) Initialize ¶
func (c *Client) Initialize(ctx context.Context, clientName, clientVersion, protocolVersion string) error
Initialize performs the MCP initialization handshake
type MCPConfig ¶
type MCPConfig struct {
Version string `json:"version"`
Servers map[string]ServerConfig `json:"servers"`
}
MCPConfig represents the .mcp.json configuration file format
type MCPToolAdapter ¶
type MCPToolAdapter struct {
// contains filtered or unexported fields
}
MCPToolAdapter wraps an MCP tool to implement Jeff's Tool interface
func NewMCPToolAdapter ¶
func NewMCPToolAdapter(client *Client, mcpTool Tool) *MCPToolAdapter
NewMCPToolAdapter creates a new adapter for an MCP tool
func (*MCPToolAdapter) AsToolDefinition ¶
func (a *MCPToolAdapter) AsToolDefinition() core.ToolDefinition
AsToolDefinition converts the MCP tool to Jeff's ToolDefinition format This is used when registering the tool with the API
func (*MCPToolAdapter) Description ¶
func (a *MCPToolAdapter) Description() string
Description returns the tool's human-readable description
func (*MCPToolAdapter) Execute ¶
func (a *MCPToolAdapter) Execute(ctx context.Context, params map[string]interface{}) (*tools.Result, error)
Execute runs the MCP tool and converts the result to Jeff's Result format
func (*MCPToolAdapter) GetInputSchema ¶
func (a *MCPToolAdapter) GetInputSchema() map[string]interface{}
GetInputSchema returns the tool's input schema
func (*MCPToolAdapter) Name ¶
func (a *MCPToolAdapter) Name() string
Name returns the tool's unique identifier
func (*MCPToolAdapter) RequiresApproval ¶
func (a *MCPToolAdapter) RequiresApproval(_ map[string]interface{}) bool
RequiresApproval determines if this tool execution needs user approval For MCP tools, we default to not requiring approval unless specific patterns are detected (can be enhanced later)
type MCPToolManager ¶
type MCPToolManager struct {
// contains filtered or unexported fields
}
MCPToolManager manages MCP tool adapters for a server
func NewMCPToolManager ¶
func NewMCPToolManager(client *Client) *MCPToolManager
NewMCPToolManager creates a new tool manager for an MCP server
func (*MCPToolManager) Count ¶
func (m *MCPToolManager) Count() int
Count returns the number of available tools
func (*MCPToolManager) GetTool ¶
func (m *MCPToolManager) GetTool(name string) tools.Tool
GetTool returns a specific MCP tool by name
func (*MCPToolManager) GetTools ¶
func (m *MCPToolManager) GetTools() []tools.Tool
GetTools returns all available MCP tools as Jeff tools
func (*MCPToolManager) RefreshTools ¶
func (m *MCPToolManager) RefreshTools(ctx context.Context) error
RefreshTools fetches the latest tool list from the MCP server
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages MCP server configurations
func NewRegistry ¶
NewRegistry creates a new server registry
func (*Registry) AddServer ¶
func (r *Registry) AddServer(server ServerConfig) error
AddServer adds a new server configuration
func (*Registry) ConfigPath ¶
ConfigPath returns the path to the .mcp.json file
func (*Registry) GetServer ¶
func (r *Registry) GetServer(name string) (ServerConfig, error)
GetServer retrieves a server configuration by name
func (*Registry) ListServers ¶
func (r *Registry) ListServers() []ServerConfig
ListServers returns all registered servers
func (*Registry) RemoveServer ¶
RemoveServer removes a server configuration
func (*Registry) ServerExists ¶
ServerExists checks if a server with the given name exists
func (*Registry) UpdateServer ¶
func (r *Registry) UpdateServer(server ServerConfig) error
UpdateServer updates an existing server configuration
type ServerConfig ¶
type ServerConfig struct {
Name string `json:"name"`
Transport string `json:"transport"`
Command string `json:"command"`
Args []string `json:"args,omitempty"`
}
ServerConfig represents an MCP server configuration
type ServerInfo ¶
type ServerInfo struct {
Name string `json:"name"`
Version string `json:"version"`
Capabilities map[string]interface{} `json:"capabilities"`
}
ServerInfo contains information about the connected MCP server