client

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 20 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() engine.Plugin

New constructs the plugin.

func RegisterInProcessServer

func RegisterInProcessServer(key string, server *mcp.Server)

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

func (p *Plugin) ConfigSchema() []byte

ConfigSchema implements engine.ConfigSchemaProvider.

func (*Plugin) Dependencies

func (p *Plugin) Dependencies() []string

func (*Plugin) DrainTimeout

func (p *Plugin) DrainTimeout() time.Duration

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

func (p *Plugin) Emissions() []string

func (*Plugin) ID

func (p *Plugin) ID() string

func (*Plugin) Init

func (p *Plugin) Init(ctx engine.PluginContext) error

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Ready

func (p *Plugin) Ready() error

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

func (p *Plugin) Shutdown(ctx context.Context) error

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

func (*Plugin) Version

func (p *Plugin) Version() string

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

type ToolFilter struct {
	Allow []string
	Deny  []string
}

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.

Jump to

Keyboard shortcuts

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