mcp

package
v0.213.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MCPTool added in v0.208.0

type MCPTool struct {
	// contains filtered or unexported fields
}

MCPTool is the agent's view of one tool on an MCP server: it presents the server's tool to the LLM under its namespaced name and calls it through the server's Client.

func NewMCPTool added in v0.208.0

func NewMCPTool(
	serverName, toolName, description string,
	inputSchema map[string]any,
	client mcpdomain.Client,
	mcpConfig *config.MCPConfig,
) *MCPTool

NewMCPTool creates a new MCP tool wrapper

func (*MCPTool) Definition added in v0.208.0

func (t *MCPTool) Definition() sdk.ChatCompletionTool

Definition returns the tool definition for the LLM

func (*MCPTool) Execute added in v0.208.0

func (t *MCPTool) Execute(ctx context.Context, args map[string]any) (*agentdomain.ToolExecutionResult, error)

Execute runs the MCP tool with given arguments

func (*MCPTool) FormatForLLM added in v0.208.0

func (t *MCPTool) FormatForLLM(result *agentdomain.ToolExecutionResult) string

FormatForLLM formats the result for LLM consumption with detailed information

func (*MCPTool) FormatForUI added in v0.208.0

func (t *MCPTool) FormatForUI(result *agentdomain.ToolExecutionResult) string

FormatForUI formats the result for UI display

func (*MCPTool) FormatPreview added in v0.208.0

func (t *MCPTool) FormatPreview(result *agentdomain.ToolExecutionResult) string

FormatPreview returns a short preview of the result for UI display

func (*MCPTool) FormatResult added in v0.208.0

func (t *MCPTool) FormatResult(result *agentdomain.ToolExecutionResult, formatType agentdomain.FormatterType) string

FormatResult formats tool execution results for different contexts

func (*MCPTool) IsEnabled added in v0.208.0

func (t *MCPTool) IsEnabled() bool

IsEnabled returns whether this MCP tool is enabled

func (*MCPTool) ShouldAlwaysExpand added in v0.208.0

func (t *MCPTool) ShouldAlwaysExpand() bool

ShouldAlwaysExpand determines if tool results should always be expanded in UI

func (*MCPTool) ShouldCollapseArg added in v0.208.0

func (t *MCPTool) ShouldCollapseArg(key string) bool

ShouldCollapseArg determines if an argument should be collapsed in display

func (*MCPTool) Validate added in v0.208.0

func (t *MCPTool) Validate(args map[string]any) error

Validate checks if the tool arguments are valid

type ServerStatus added in v0.195.0

type ServerStatus struct {
	Name      string `json:"name"`
	Connected bool   `json:"connected"`
	Tools     int    `json:"tools"`
	Error     string `json:"error,omitempty"`
}

ServerStatus is the probe result for one configured MCP server.

type StatusReport added in v0.195.0

type StatusReport struct {
	Enabled          bool           `json:"enabled"`
	TotalServers     int            `json:"total_servers"`
	ConnectedServers int            `json:"connected_servers"`
	TotalTools       int            `json:"total_tools"`
	Servers          []ServerStatus `json:"servers"`
}

StatusReport mirrors the TUI's "MCP connected/total (tools)" indicator plus a per-server breakdown. TotalServers counts every configured server, like the TUI; only enabled servers are dialed.

func ProbeStatus added in v0.195.0

func ProbeStatus(ctx context.Context, cfg *config.MCPConfig, only string) (StatusReport, error)

ProbeStatus dials every enabled server once (or just `only` when non-empty) and reports what a fresh session would see. Connection state is per process, so a probe is the only honest answer from outside a running session.

func (StatusReport) Indicator added in v0.195.0

func (r StatusReport) Indicator() string

Indicator renders the report the way the TUI status bar does.

type Supervisor added in v0.207.0

type Supervisor struct {
	// contains filtered or unexported fields
}

Supervisor manages multiple MCP server connections and their container lifecycle

func NewSupervisor added in v0.207.0

func NewSupervisor(sessionID convdomain.SessionID, cfg *config.MCPConfig, runtime containerruntime.ContainerRuntime, notifier agentdomain.UINotifier) *Supervisor

NewSupervisor creates a new MCP supervisor. notifier is the single UI ingress the liveness probes push ServerStatusUpdateEvent through; a nil notifier degrades to no UI pushes.

func (*Supervisor) Close added in v0.207.0

func (s *Supervisor) Close() error

Close stops monitoring, stops containers, and cleans up resources

func (*Supervisor) DiscoverTools added in v0.208.0

func (s *Supervisor) DiscoverTools(ctx context.Context) map[string]agentdomain.Tool

DiscoverTools probes every server once, in parallel, and returns the tools of those that answered. Headless calls it before the first turn, since it has no liveness loop to register tools as servers come up. ponytail: run:true container servers still starting in the background are skipped (their client has no URL yet); wait on StartServers if headless ever needs container-hosted MCP tools on the first turn.

func (*Supervisor) GetTotalServers added in v0.207.0

func (s *Supervisor) GetTotalServers() int

GetTotalServers returns the total number of configured MCP servers from config

func (*Supervisor) StartMonitoring added in v0.207.0

func (s *Supervisor) StartMonitoring(ctx context.Context)

StartMonitoring begins background health monitoring, pushing every ServerStatusUpdateEvent through the injected UI notifier. It is idempotent - subsequent calls are no-ops. The initial status is emitted from a goroutine because Notify wraps the unbuffered (*tea.Program).Send, which blocks until the Bubble Tea loop consumes; emitting it synchronously from app.Init (before the loop runs) would deadlock.

func (*Supervisor) StartServer added in v0.207.0

func (s *Supervisor) StartServer(ctx context.Context, server config.MCPServerEntry) error

StartServer starts a single MCP server container, or points the client at a detached shared container when one is already running.

func (*Supervisor) StartServers added in v0.207.0

func (s *Supervisor) StartServers(ctx context.Context) error

StartServers starts all MCP servers that have run=true This method is non-fatal and always returns nil

func (*Supervisor) StopServer added in v0.207.0

func (s *Supervisor) StopServer(ctx context.Context, serverName string) error

StopServer stops this session's container for the named server. With the shared session id it stops the detached container started by `infer mcp start`.

func (*Supervisor) StopServers added in v0.207.0

func (s *Supervisor) StopServers(ctx context.Context) error

StopServers stops all running MCP server containers

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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