Documentation
¶
Overview ¶
Package mcp owns Or's product-level MCP configuration, connection manager, leases, diagnostics, and adaptation of protocol tools to coding-agent tools.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisplayTitle ¶
DisplayTitle returns the MCP-standard display-name precedence for a tool.
func ToolName ¶
ToolName returns the provider-safe, deterministic name Or advertises for an MCP tool.
func WriteConfig ¶
WriteConfig atomically replaces path with a private, canonical JSON file.
Types ¶
type Config ¶
type Config struct {
Version int `json:"version"`
MCPServers map[string]ServerConfig `json:"mcpServers"`
}
Config is the on-disk MCP server configuration. It intentionally lives in Or's private data directory rather than in a workspace: opening an untrusted repository must never be enough to start an arbitrary local process.
func ParseConfig ¶
ParseConfig decodes one strict MCP configuration document.
func ReadConfig ¶
ReadConfig loads the product-owned MCP configuration without connecting to any server. A missing file remains distinguishable from an empty config so callers can decide whether MCP should be surfaced at all.
type Lease ¶
type Lease struct {
// contains filtered or unexported fields
}
Lease is one conversation's immutable view of tools and server statuses.
func (*Lease) Close ¶
func (lease *Lease) Close()
Close releases this lease without closing connections still used by another runtime or retained by the active manager generation.
func (*Lease) Statuses ¶
func (lease *Lease) Statuses() []ServerStatus
Statuses returns an independent slice of secret-free diagnostics.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager loads one product-owned config and shares matching connections among conversation runtimes. Config generations are isolated so active runtimes retain their old connections while newly loaded runtimes use new settings.
func New ¶
New creates a manager and loads its initial configuration. Configuration errors are retained as lease diagnostics instead of preventing app startup.
func (*Manager) Acquire ¶
Acquire waits for every applicable server in the current generation and returns one immutable snapshot. Individual server failures are represented in Statuses and never fail the whole lease.
func (*Manager) Close ¶
func (manager *Manager) Close()
Close cancels initialization and closes every cached connection.
func (*Manager) Reload ¶
Reload installs the latest on-disk configuration as a new generation. Old connections remain alive until every lease using them has been released.
func (*Manager) Warm ¶
Warm starts resolving the servers visible to workspace without retaining a conversation lease. Connections from the active config generation remain cached for later sessions.
func (*Manager) WarmGlobal ¶
func (manager *Manager) WarmGlobal()
WarmGlobal starts workspace-independent HTTP servers. It is safe during app startup before any project or scratch workspace has been selected.
type ProbeResult ¶
ProbeResult reports a successful initialize and tools/list round trip.
func Probe ¶
func Probe(ctx context.Context, name string, config ServerConfig, workspace string) (ProbeResult, error)
Probe connects to one saved server long enough to discover its tools, then closes the connection. Calling it is an explicit user action in settings.
type ProbeTool ¶
type ProbeTool struct {
Name string `json:"name"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
}
ProbeTool is compact protocol metadata discovered during a connection probe.
type ServerConfig ¶
type ServerConfig struct {
Disabled bool `json:"disabled,omitempty"`
Command string `json:"command,omitempty"`
Args []string `json:"args,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"`
Workspaces []string `json:"workspaces,omitempty"`
TimeoutSeconds int `json:"timeoutSeconds,omitempty"`
}
ServerConfig describes either one stdio server (Command) or one Streamable HTTP server (URL). Workspaces scopes a server to exact workspace roots; an empty list makes it available to every session.
func (ServerConfig) AppliesTo ¶
func (config ServerConfig) AppliesTo(workspace string) (bool, error)
AppliesTo reports whether this server is visible to one exact workspace.
func (ServerConfig) Validate ¶
func (config ServerConfig) Validate() error
Validate checks the transport-level fields that do not require expanding environment references or opening a connection.
type ServerState ¶
type ServerState string
const ( StateConnected ServerState = "connected" StateDisabled ServerState = "disabled" StateError ServerState = "error" StateOutOfScope ServerState = "out_of_scope" )
type ServerStatus ¶
type ServerStatus struct {
Name string `json:"name"`
Transport string `json:"transport,omitempty"`
State ServerState `json:"state"`
ToolCount int `json:"toolCount,omitempty"`
Error string `json:"error,omitempty"`
}
ServerStatus is a secret-free connection diagnostic returned by mcp_status.