Documentation
¶
Index ¶
- func DefaultConfigPath() (string, error)
- func GetBundledServersByCategory() map[string][]BundledServer
- func GetMCPToolSpecs(manager *Manager) []llm.ToolSpec
- func RegisterMCPTools(manager *Manager, registry *llm.ToolRegistry)
- type ArgumentInfo
- type BundledServer
- type Client
- type Config
- type MCPTool
- type Manager
- func (m *Manager) AllTools() []ToolSpec
- func (m *Manager) AvailableServers() []string
- func (m *Manager) CallTool(ctx context.Context, fullName string, args json.RawMessage) (string, error)
- func (m *Manager) Config() *Config
- func (m *Manager) Disable(name string) error
- func (m *Manager) Enable(ctx context.Context, name string) error
- func (m *Manager) EnabledServers() []string
- func (m *Manager) GetAllStates() []ServerState
- func (m *Manager) LoadConfig() error
- func (m *Manager) Restart(ctx context.Context, name string) error
- func (m *Manager) ServerStatus(name string) (ServerStatus, error)
- func (m *Manager) SetStatusChannel(ch chan StatusUpdate)
- func (m *Manager) StopAll()
- type OfficialMeta
- type PackageInfo
- type RegistryClient
- type RegistryMeta
- type RegistryServer
- type RegistryServerWrapper
- type RepositoryInfo
- type SearchMetadata
- type SearchOptions
- type SearchResult
- type ServerConfig
- type ServerState
- type ServerStatus
- type StatusUpdate
- type ToolSpec
- type TransportInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultConfigPath ¶
DefaultConfigPath returns the default path for mcp.json.
func GetBundledServersByCategory ¶
func GetBundledServersByCategory() map[string][]BundledServer
GetBundledServersByCategory returns servers grouped by category.
func GetMCPToolSpecs ¶
GetMCPToolSpecs returns LLM tool specs for all running MCP tools.
func RegisterMCPTools ¶
func RegisterMCPTools(manager *Manager, registry *llm.ToolRegistry)
RegisterMCPTools registers all MCP tools from the manager into the tool registry.
Types ¶
type ArgumentInfo ¶
type ArgumentInfo struct {
Name string `json:"name"`
Description string `json:"description"`
Type string `json:"type"` // positional, named
Format string `json:"format"` // string, number
IsRequired bool `json:"isRequired"`
Default string `json:"default,omitempty"`
}
ArgumentInfo describes a command-line argument.
type BundledServer ¶
type BundledServer struct {
Name string
Description string
Package string // npm package name
PackageType string // "npm" or "pypi"
Category string
Official bool // true if official/reference implementation
URL string // repository or homepage URL
}
BundledServer represents a curated MCP server included in the binary. These are popular servers that may not always appear in registry searches.
func GetBundledServers ¶
func GetBundledServers() []BundledServer
GetBundledServers returns all bundled servers.
func (*BundledServer) ToRegistryServer ¶
func (b *BundledServer) ToRegistryServer() RegistryServer
ToRegistryServer converts a BundledServer to a RegistryServer for UI consistency.
func (*BundledServer) ToServerConfig ¶
func (b *BundledServer) ToServerConfig() ServerConfig
ToServerConfig converts a BundledServer to a local ServerConfig.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps an MCP server connection.
func NewClient ¶
func NewClient(name string, config ServerConfig) *Client
NewClient creates a new MCP client for the given server configuration.
type Config ¶
type Config struct {
Servers map[string]ServerConfig `json:"servers"`
}
Config represents the mcp.json configuration file.
func LoadConfig ¶
LoadConfig loads the MCP configuration from the default path.
func LoadConfigFromPath ¶
LoadConfigFromPath loads the MCP configuration from a specific path.
func (*Config) AddServer ¶
func (c *Config) AddServer(name string, cfg ServerConfig)
AddServer adds or updates a server configuration.
func (*Config) RemoveServer ¶
RemoveServer removes a server configuration.
func (*Config) SaveToPath ¶
SaveToPath saves the configuration to a specific path.
func (*Config) ServerNames ¶
ServerNames returns a sorted list of configured server names.
type MCPTool ¶
type MCPTool struct {
// contains filtered or unexported fields
}
MCPTool wraps an MCP server tool as an llm.Tool.
func NewMCPTool ¶
NewMCPTool creates a new MCP tool wrapper.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles MCP server lifecycle and provides tools to LLM.
func (*Manager) AllTools ¶
AllTools returns all tools from all running MCP servers. Tool names are prefixed with server name to avoid collisions.
func (*Manager) AvailableServers ¶
AvailableServers returns the names of all configured servers.
func (*Manager) CallTool ¶
func (m *Manager) CallTool(ctx context.Context, fullName string, args json.RawMessage) (string, error)
CallTool routes a tool call to the appropriate MCP server. Tool names should be prefixed with "servername__".
func (*Manager) EnabledServers ¶
EnabledServers returns the names of currently enabled (running or starting) servers.
func (*Manager) GetAllStates ¶
func (m *Manager) GetAllStates() []ServerState
GetAllStates returns the current state of all servers (for UI display).
func (*Manager) LoadConfig ¶
LoadConfig loads the MCP configuration.
func (*Manager) ServerStatus ¶
func (m *Manager) ServerStatus(name string) (ServerStatus, error)
ServerStatus returns the current status of a server.
func (*Manager) SetStatusChannel ¶
func (m *Manager) SetStatusChannel(ch chan StatusUpdate)
SetStatusChannel sets a channel to receive status updates.
type OfficialMeta ¶
type OfficialMeta struct {
Status string `json:"status"` // active, deleted
PublishedAt string `json:"publishedAt"`
UpdatedAt string `json:"updatedAt"`
IsLatest bool `json:"isLatest"`
}
OfficialMeta contains official registry metadata.
type PackageInfo ¶
type PackageInfo struct {
RegistryType string `json:"registryType"` // npm, pypi, oci
RegistryBaseURL string `json:"registryBaseUrl,omitempty"`
Identifier string `json:"identifier"`
Version string `json:"version"`
Transport *TransportInfo `json:"transport,omitempty"`
Arguments []ArgumentInfo `json:"packageArguments,omitempty"`
RuntimeArgs []ArgumentInfo `json:"runtimeArguments,omitempty"`
}
PackageInfo describes how to install/run a server.
type RegistryClient ¶
type RegistryClient struct {
// contains filtered or unexported fields
}
RegistryClient queries the official MCP registry.
func NewRegistryClient ¶
func NewRegistryClient() *RegistryClient
NewRegistryClient creates a new registry client.
func (*RegistryClient) GetServer ¶
func (r *RegistryClient) GetServer(ctx context.Context, name string) (*RegistryServer, error)
GetServer fetches a specific server by name.
func (*RegistryClient) Search ¶
func (r *RegistryClient) Search(ctx context.Context, opts SearchOptions) (*SearchResult, error)
Search queries the registry for MCP servers.
type RegistryMeta ¶
type RegistryMeta struct {
Official *OfficialMeta `json:"io.modelcontextprotocol.registry/official,omitempty"`
}
RegistryMeta contains registry-specific metadata.
type RegistryServer ¶
type RegistryServer struct {
Name string `json:"name"`
Description string `json:"description"`
Version string `json:"version"`
Repository *RepositoryInfo `json:"repository,omitempty"`
Packages []PackageInfo `json:"packages,omitempty"`
Meta *RegistryMeta `json:"_meta,omitempty"`
}
RegistryServer represents a server from the registry.
func (*RegistryServer) DisplayName ¶
func (s *RegistryServer) DisplayName() string
DisplayName returns a user-friendly display name for the server.
func (*RegistryServer) ToServerConfig ¶
func (s *RegistryServer) ToServerConfig() (ServerConfig, bool)
ToServerConfig converts a registry server to a local configuration. Returns the config and a flag indicating if user input is needed.
type RegistryServerWrapper ¶
type RegistryServerWrapper struct {
Server RegistryServer `json:"server"`
Meta *RegistryMeta `json:"_meta,omitempty"`
}
RegistryServerWrapper wraps server with metadata.
func GetBundledAsRegistryWrappers ¶
func GetBundledAsRegistryWrappers() []RegistryServerWrapper
GetBundledAsRegistryWrappers returns bundled servers as RegistryServerWrappers for UI.
type RepositoryInfo ¶
type RepositoryInfo struct {
URL string `json:"url"`
Source string `json:"source"`
Subfolder string `json:"subfolder,omitempty"`
}
RepositoryInfo contains source repository information.
type SearchMetadata ¶
type SearchMetadata struct {
Count int `json:"count"`
NextCursor string `json:"nextCursor,omitempty"`
}
SearchMetadata contains pagination info.
type SearchOptions ¶
SearchOptions configures a registry search.
type SearchResult ¶
type SearchResult struct {
Servers []RegistryServerWrapper `json:"servers"`
Metadata SearchMetadata `json:"metadata"`
}
SearchResult contains the response from a registry search.
type ServerConfig ¶
type ServerConfig struct {
Command string `json:"command"`
Args []string `json:"args"`
Env map[string]string `json:"env,omitempty"`
}
ServerConfig represents a configured MCP server.
type ServerState ¶
type ServerState struct {
Name string
Status ServerStatus
Error error
Client *Client
}
ServerState holds the state of a managed MCP server.
type ServerStatus ¶
type ServerStatus string
ServerStatus represents the current state of an MCP server.
const ( StatusStopped ServerStatus = "stopped" StatusStarting ServerStatus = "starting" StatusReady ServerStatus = "ready" StatusFailed ServerStatus = "failed" )
type StatusUpdate ¶
type StatusUpdate struct {
Name string
Status ServerStatus
Error error
}
StatusUpdate is sent when a server's status changes.
type TransportInfo ¶
type TransportInfo struct {
Type string `json:"type"` // stdio, sse, streamable-http
URL string `json:"url,omitempty"`
}
TransportInfo describes the transport type.