mcp

package
v0.107.12 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ToolSearchName = "ToolSearch"
)

Variables

This section is empty.

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

func ParseToolName(name string) (srvKey, tool string, ok bool)

func Serve

func Serve(ctx context.Context, version string) error

func ToolName

func ToolName(server, tool string) string

Types

type CredentialBridge added in v0.107.0

type CredentialBridge func(context.Context, string) (string, error)

CredentialBridge resolves a native-host credential without moving the secret into the K-brain settings file or HTTP API.

type LiveAuth added in v0.107.0

type LiveAuth struct {
	Type          string `json:"type"`
	Scope         string `json:"scope,omitempty"`
	ClientID      string `json:"clientId,omitempty"`
	CredentialRef string `json:"credentialRef,omitempty"`
}

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) 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) Search added in v0.107.0

func (m *LiveManager) Search(ctx context.Context, query string, cwd string, selected []string, limit int) []tools.Tool

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) ToolsFor added in v0.107.0

func (m *LiveManager) ToolsFor(ctx context.Context, cwd string, selected []string) []tools.Tool

func (*LiveManager) ToolsForTurn added in v0.107.0

func (m *LiveManager) ToolsForTurn(ctx context.Context, cwd string, selected []string, activation *ToolActivation) ([]tools.Tool, func([]tools.Tool) []tools.Tool)

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) Close

func (m *Manager) Close()

func (*Manager) Config

func (m *Manager) Config(name string) (ServerConfig, bool)

func (*Manager) Disable

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

func (*Manager) Enable

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

func (*Manager) FireOnChangeForTest

func (m *Manager) FireOnChangeForTest()

func (*Manager) InstructionsBlock

func (m *Manager) InstructionsBlock() string

func (*Manager) Reconnect

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

func (*Manager) RemoveServers

func (m *Manager) RemoveServers(names ...string)

func (*Manager) SetOnChange

func (m *Manager) SetOnChange(fn func())

func (*Manager) Start

func (m *Manager) Start(ctx context.Context)

func (*Manager) Statuses

func (m *Manager) Statuses() []Server

func (*Manager) Tools

func (m *Manager) Tools() []tools.Tool

type ProbeResult

type ProbeResult struct {
	Server
	Elapsed   time.Duration
	ToolNames []string
}

func Probe

func Probe(ctx context.Context, name string, cfg ServerConfig) ProbeResult

type Server

type Server struct {
	Name   string
	Status Status
	Note   string
	Err    string
	Tools  int
	Source string
}

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 Status

type Status int
const (
	StatusDisabled Status = iota
	StatusConnecting
	StatusReady
	StatusFailed
)

func (Status) String

func (s Status) String() 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

Jump to

Keyboard shortcuts

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