Documentation
¶
Index ¶
- Constants
- Variables
- func FilterRequestTools(activation *ToolActivation) func([]tools.Tool) []tools.Tool
- func FromConfigMap(in map[string]config.MCPServer) map[string]ServerConfig
- func ParseToolName(name string) (srvKey, tool string, ok bool)
- func Serve(ctx context.Context, version string) error
- func ToolName(server, tool string) string
- type CredentialBridge
- type LiveAuth
- type LiveManager
- func (m *LiveManager) Close()
- func (m *LiveManager) ReadUIResource(ctx context.Context, cwd, serverID, uri string) (UIResource, error)
- func (m *LiveManager) Reload() error
- func (m *LiveManager) Replace(ctx context.Context, settings LiveSettings) error
- func (m *LiveManager) Search(ctx context.Context, query string, cwd string, selected []string, limit int) []tools.Tool
- func (m *LiveManager) SetCredentialBridge(bridge CredentialBridge)
- func (m *LiveManager) SetOnChange(fn func())
- func (m *LiveManager) SetSave(fn func(LiveSettings) error)
- func (m *LiveManager) Settings() LiveSettings
- func (m *LiveManager) Statuses() []LiveStatus
- func (m *LiveManager) ToolUI(cwd, toolName string) (ToolUI, bool)
- func (m *LiveManager) ToolUIs(cwd string, names []string) map[string]ToolUI
- func (m *LiveManager) ToolsFor(ctx context.Context, cwd string, selected []string) []tools.Tool
- func (m *LiveManager) ToolsForTurn(ctx context.Context, cwd string, selected []string, activation *ToolActivation) ([]tools.Tool, func([]tools.Tool) []tools.Tool)
- type LiveServer
- type LiveSettings
- type LiveStatus
- type Manager
- func (m *Manager) AddServers(ctx context.Context, cfgs map[string]ServerConfig)
- func (m *Manager) Close()
- func (m *Manager) Config(name string) (ServerConfig, bool)
- func (m *Manager) Disable(name string) bool
- func (m *Manager) Enable(name string) bool
- func (m *Manager) EnableElicitation()
- func (m *Manager) FireOnChangeForTest()
- func (m *Manager) InstructionsBlock() string
- func (m *Manager) Reconnect(name string) bool
- func (m *Manager) RemoveServers(names ...string)
- func (m *Manager) SetOnChange(fn func())
- func (m *Manager) Start(ctx context.Context)
- func (m *Manager) Statuses() []Server
- func (m *Manager) Tools() []tools.Tool
- type ProbeResult
- type Server
- type ServerConfig
- type Status
- type ToolActivation
- type ToolUI
- type UIResource
Constants ¶
const ( // UIResourceScheme prefixes every UI resource URI. UIResourceScheme = "ui://" // MaxUIResourceBytes bounds the HTML read for one UI resource. MaxUIResourceBytes = 4 << 20 )
const (
ToolSearchName = "ToolSearch"
)
Variables ¶
var ( // ErrUIResourceNotFound: no usable server or tool declares the resource. ErrUIResourceNotFound = errors.New("MCP UI resource not found") // ErrUIResourceInvalid: the server's reply is not a usable HTML resource. ErrUIResourceInvalid = errors.New("MCP UI resource is not usable HTML") )
Functions ¶
func FilterRequestTools ¶ added in v0.107.0
func FilterRequestTools(activation *ToolActivation) func([]tools.Tool) []tools.Tool
func FromConfigMap ¶
func FromConfigMap(in map[string]config.MCPServer) map[string]ServerConfig
func ParseToolName ¶
Types ¶
type CredentialBridge ¶ added in v0.107.0
CredentialBridge resolves a native-host credential without moving the secret into the K-brain settings file or HTTP API.
type LiveManager ¶ added in v0.107.0
type LiveManager struct {
// contains filtered or unexported fields
}
func NewLiveManager ¶ added in v0.107.0
func NewLiveManager(ctx context.Context, path string, settings LiveSettings) (*LiveManager, error)
func OpenLiveManager ¶ added in v0.107.0
func OpenLiveManager(ctx context.Context, path string, fallback map[string]ServerConfig) (*LiveManager, error)
func (*LiveManager) Close ¶ added in v0.107.0
func (m *LiveManager) Close()
func (*LiveManager) ReadUIResource ¶ added in v0.107.42
func (m *LiveManager) ReadUIResource(ctx context.Context, cwd, serverID, uri string) (UIResource, error)
ReadUIResource reads the UI resource uri from server serverID for a session in cwd. Only a resource that one of the server's tools declares, and whose policy does not deny that tool, is read: the route cannot be used to read arbitrary resources.
func (*LiveManager) Reload ¶ added in v0.107.0
func (m *LiveManager) Reload() error
func (*LiveManager) Replace ¶ added in v0.107.0
func (m *LiveManager) Replace(ctx context.Context, settings LiveSettings) error
func (*LiveManager) SetCredentialBridge ¶ added in v0.107.0
func (m *LiveManager) SetCredentialBridge(bridge CredentialBridge)
func (*LiveManager) SetOnChange ¶ added in v0.107.0
func (m *LiveManager) SetOnChange(fn func())
func (*LiveManager) SetSave ¶ added in v0.107.0
func (m *LiveManager) SetSave(fn func(LiveSettings) error)
func (*LiveManager) Settings ¶ added in v0.107.0
func (m *LiveManager) Settings() LiveSettings
func (*LiveManager) Statuses ¶ added in v0.107.0
func (m *LiveManager) Statuses() []LiveStatus
func (*LiveManager) ToolUI ¶ added in v0.107.42
func (m *LiveManager) ToolUI(cwd, toolName string) (ToolUI, bool)
ToolUI returns the UI resource the model-facing MCP tool toolName declares, when its server is enabled and allowed from cwd and its policy does not deny the tool.
func (*LiveManager) ToolUIs ¶ added in v0.107.42
func (m *LiveManager) ToolUIs(cwd string, names []string) map[string]ToolUI
ToolUIs maps the model-facing names of the tools in list that declare a UI resource (see ToolUI) to that resource.
func (*LiveManager) ToolsForTurn ¶ added in v0.107.0
type LiveServer ¶ added in v0.107.0
type LiveServer struct {
ID string `json:"id"`
Description string `json:"description,omitempty"`
DocsURL string `json:"docsUrl,omitempty"`
Enabled bool `json:"enabled"`
Transport string `json:"transport"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
URL string `json:"url,omitempty"`
Env map[string]string `json:"env,omitempty"`
Cwd string `json:"cwd,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
TimeoutMs int `json:"timeoutMs,omitempty"`
WorkspaceRoots []string `json:"workspaceRoots,omitempty"`
Policy map[string]string `json:"policy,omitempty"`
Auth *LiveAuth `json:"auth,omitempty"`
}
type LiveSettings ¶ added in v0.107.0
type LiveSettings struct {
Servers []LiveServer `json:"servers"`
Selected []string `json:"selected,omitempty"`
}
type LiveStatus ¶ added in v0.107.0
type LiveStatus struct {
LiveServer
Status string `json:"status"`
Error string `json:"error,omitempty"`
Tools int `json:"tools"`
}
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(cfgs map[string]ServerConfig) *Manager
func (*Manager) AddServers ¶
func (m *Manager) AddServers(ctx context.Context, cfgs map[string]ServerConfig)
func (*Manager) EnableElicitation ¶ added in v0.107.26
func (m *Manager) EnableElicitation()
EnableElicitation makes the manager declare the MCP elicitation capability (form mode) and route servers' elicitations to the front end in the tool call's context (internal/elicit). Call it before Start; a manager without it declares no elicitation capability, so servers cannot ask.
func (*Manager) FireOnChangeForTest ¶
func (m *Manager) FireOnChangeForTest()
func (*Manager) InstructionsBlock ¶
func (*Manager) RemoveServers ¶
func (*Manager) SetOnChange ¶
func (m *Manager) SetOnChange(fn func())
type ProbeResult ¶
func Probe ¶
func Probe(ctx context.Context, name string, cfg ServerConfig) ProbeResult
type ServerConfig ¶
type ServerConfig struct {
Command []string `json:"command,omitempty"`
Env map[string]string `json:"env,omitempty"`
Cwd string `json:"cwd,omitempty"`
URL string `json:"url,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Note string `json:"note,omitempty"`
StartupTimeout int `json:"startupTimeout,omitempty"`
ToolTimeout int `json:"toolTimeout,omitempty"`
Source string `json:"-"`
}
func (ServerConfig) Disabled ¶
func (c ServerConfig) Disabled() bool
func (ServerConfig) Remote ¶
func (c ServerConfig) Remote() bool
func (ServerConfig) StartupTimeoutDuration ¶
func (c ServerConfig) StartupTimeoutDuration() time.Duration
func (ServerConfig) ToolTimeoutDuration ¶
func (c ServerConfig) ToolTimeoutDuration() time.Duration
func (ServerConfig) Valid ¶
func (c ServerConfig) Valid() string
type ToolActivation ¶ added in v0.107.0
type ToolActivation struct {
// contains filtered or unexported fields
}
func NewToolActivation ¶ added in v0.107.0
func NewToolActivation() *ToolActivation
func (*ToolActivation) Add ¶ added in v0.107.0
func (a *ToolActivation) Add(name string)
func (*ToolActivation) Has ¶ added in v0.107.0
func (a *ToolActivation) Has(name string) bool
type ToolUI ¶ added in v0.107.42
type ToolUI struct {
// ServerID is the configured server (LiveServer.ID).
ServerID string
// URI is the ui:// resource.
URI string
}
ToolUI is the UI resource a model-facing MCP tool declares.
type UIResource ¶ added in v0.107.42
type UIResource struct {
URI string
MIMEType string
HTML string
// ConnectDomains and ResourceDomains are the https origins the resource's
// _meta.ui.csp asks to reach (fetch/WebSocket) and to load scripts,
// styles, images, fonts and media from. Entries that are not plain https
// origins are dropped.
ConnectDomains []string
ResourceDomains []string
}
UIResource is a UI resource's HTML as read from its server.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mcptest provides a minimal MCP server for tests that need to control the exact bytes a server sends, such as an elicitation's requestedSchema with its property order or a schema outside the subset.
|
Package mcptest provides a minimal MCP server for tests that need to control the exact bytes a server sends, such as an elicitation's requestedSchema with its property order or a schema outside the subset. |