Documentation
¶
Overview ¶
Package client implements the nexus.mcp.client plugin: a developer- configured bridge between Nexus and one or more MCP (Model Context Protocol) servers. Each configured server contributes its tools to the Nexus tool catalog under the namespace mcp__<server>__<tool>, surfaces its resources as catalog tools (generic browse/read plus auto-registered statics and templates), and exposes its prompts as slash commands of the form /<command_prefix>.<server>.<prompt>.
MCP capabilities deferred for Phase 1:
- sampling (server-initiated LLM calls) — tracked in issue #98
- roots beyond the session files dir
- server-initiated OAuth / dynamic client registration
See docs/src/plugins/mcp-client.md for the user-facing reference.
Index ¶
- func New() engine.Plugin
- func RegisterInProcessServer(key string, server *mcp.Server)
- func UnregisterInProcessServer(key string)
- type Config
- type Defaults
- type Plugin
- func (p *Plugin) Capabilities() []engine.Capability
- func (p *Plugin) ConfigSchema() []byte
- func (p *Plugin) Dependencies() []string
- func (p *Plugin) DrainTimeout() time.Duration
- func (p *Plugin) Emissions() []string
- func (p *Plugin) ID() string
- func (p *Plugin) Init(ctx engine.PluginContext) error
- func (p *Plugin) Name() string
- func (p *Plugin) Ready() error
- func (p *Plugin) Requires() []engine.Requirement
- func (p *Plugin) Shutdown(ctx context.Context) error
- func (p *Plugin) Subscriptions() []engine.EventSubscription
- func (p *Plugin) Version() string
- type PromptConfig
- type ResourceConfig
- type ServerConfig
- type ToolFilter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterInProcessServer ¶
RegisterInProcessServer registers a live MCP server under key so a ServerConfig with transport "inprocess" can connect to it in-process. Call before engine.Boot(). A second call with the same key replaces the previous registration.
func UnregisterInProcessServer ¶
func UnregisterInProcessServer(key string)
UnregisterInProcessServer removes a host-injected server. Intended for test cleanup so a process-wide registration doesn't leak across tests; hosts that live for the process lifetime need not call it.
Types ¶
type Config ¶
type Config struct {
Servers []ServerConfig
Defaults Defaults
Aliases map[string]string // alias name -> "<server>.<prompt>"
}
Config is the parsed plugin configuration.
type Defaults ¶
type Defaults struct {
Lifecycle string
Timeout time.Duration
Resources ResourceConfig
Prompts PromptConfig
CommandPrefix string // slash prefix; default "mcp"
}
Defaults applied to every ServerConfig unless overridden inline.
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin is the MCP client plugin.
func (*Plugin) Capabilities ¶
func (p *Plugin) Capabilities() []engine.Capability
Capabilities advertises this plugin as the "mcp.client" provider so other plugins (e.g. a future UI or eval harness) can detect that an MCP bridge is active without string-matching the concrete plugin ID.
func (*Plugin) ConfigSchema ¶
ConfigSchema implements engine.ConfigSchemaProvider.
func (*Plugin) Dependencies ¶
func (*Plugin) DrainTimeout ¶
DrainTimeout asks the engine for a longer drain window so any in-flight MCP tool calls can return before the bus shuts down.
func (*Plugin) Ready ¶
Ready connects every server whose lifecycle is "engine". Servers with lifecycle "session" wait for io.session.start. Engine-lifecycle servers are required to come up at boot — a missing one is logged but not fatal so a single broken server doesn't prevent the rest of the engine from running.
func (*Plugin) Requires ¶
func (p *Plugin) Requires() []engine.Requirement
func (*Plugin) Shutdown ¶
Shutdown closes every active MCP connection. A grace window per server keeps stdio subprocesses from leaking even when the server is unresponsive.
func (*Plugin) Subscriptions ¶
func (p *Plugin) Subscriptions() []engine.EventSubscription
type PromptConfig ¶
type PromptConfig struct {
Enabled bool
}
PromptConfig governs the slash-command surface for MCP prompts.
type ResourceConfig ¶
type ResourceConfig struct {
Enabled bool
AutoRegisterStatic bool
AutoRegisterMax int
AutoRegisterTemplate bool
SubscribeUpdates bool
}
ResourceConfig governs how MCP resources are surfaced into the catalog and onto the bus.
type ServerConfig ¶
type ServerConfig struct {
Name string
Transport string // "stdio" | "http" | "inprocess"
// stdio
Command string
Args []string
Env map[string]string
EnvPassthrough []string
// http (streamable HTTP transport)
URL string
Headers map[string]string
// inprocess — key of a live *mcp.Server the host registered via
// RegisterInProcessServer before engine.Boot(). The connection is wired
// over an in-memory transport instead of a subprocess or HTTP dial.
InjectedServer string
Lifecycle string // "engine" | "session"
Timeout time.Duration // per-request timeout
Tools ToolFilter
Resources ResourceConfig
Prompts PromptConfig
}
ServerConfig describes one MCP server connection.
type ToolFilter ¶
ToolFilter is the per-server tool allowlist/blocklist applied to MCP tools before they reach the catalog. Matched against the raw MCP tool name, not the Nexus-namespaced name.