mcp

package
v0.205.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager manages multiple MCP server connections and their container lifecycle

func NewManager

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

NewManager creates a new MCP manager. notifier is the single UI ingress the liveness probes push MCPServerStatusUpdateEvent through; a nil notifier degrades to no UI pushes.

func (*Manager) ClearToolCount

func (m *Manager) ClearToolCount(serverName string)

ClearToolCount removes the tool count for a specific server

func (*Manager) Close

func (m *Manager) Close() error

Close stops monitoring, stops containers, and cleans up resources

func (*Manager) GetClient

func (m *Manager) GetClient(serverName string) agentdomain.MCPClient

GetClient returns the client for a specific server by name, or nil if no such client exists. Direct map lookup - does not perform any network I/O, in contrast to iterating GetClients() and calling DiscoverTools to identify the owning client.

func (*Manager) GetClients

func (m *Manager) GetClients() []agentdomain.MCPClient

GetClients returns a list of MCP clients

func (*Manager) GetTotalServers

func (m *Manager) GetTotalServers() int

GetTotalServers returns the total number of configured MCP servers from config

func (*Manager) StartMonitoring

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

StartMonitoring begins background health monitoring, pushing every MCPServerStatusUpdateEvent 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 (*Manager) StartServer

func (m *Manager) 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 (*Manager) StartServers

func (m *Manager) StartServers(ctx context.Context) error

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

func (*Manager) StopServer added in v0.195.0

func (m *Manager) 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 (*Manager) StopServers

func (m *Manager) StopServers(ctx context.Context) error

StopServers stops all running MCP server containers

func (*Manager) UpdateToolCount

func (m *Manager) UpdateToolCount(serverName string, count int)

UpdateToolCount updates the tool count for a specific server

type SSEHTTPClientTransport

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

SSEHTTPClientTransport implements an SSE-aware HTTP client transport for MCP This handles servers that respond with Server-Sent Events format

func NewSSEHTTPClientTransport

func NewSSEHTTPClientTransport(endpoint string) *SSEHTTPClientTransport

NewSSEHTTPClientTransport creates a new SSE-aware HTTP client transport

func (*SSEHTTPClientTransport) Close

func (t *SSEHTTPClientTransport) Close() error

Close implements Transport.Close

func (*SSEHTTPClientTransport) Send

Send implements Transport.Send

func (*SSEHTTPClientTransport) SetCloseHandler

func (t *SSEHTTPClientTransport) SetCloseHandler(handler func())

SetCloseHandler implements Transport.SetCloseHandler

func (*SSEHTTPClientTransport) SetErrorHandler

func (t *SSEHTTPClientTransport) SetErrorHandler(handler func(error))

SetErrorHandler implements Transport.SetErrorHandler

func (*SSEHTTPClientTransport) SetMessageHandler

func (t *SSEHTTPClientTransport) SetMessageHandler(handler func(ctx context.Context, message *transport.BaseJsonRpcMessage))

SetMessageHandler implements Transport.SetMessageHandler

func (*SSEHTTPClientTransport) Start

Start implements Transport.Start

func (*SSEHTTPClientTransport) WithHeader

func (t *SSEHTTPClientTransport) WithHeader(key, value string) *SSEHTTPClientTransport

WithHeader adds a header to the request

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 "🔌 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.

Jump to

Keyboard shortcuts

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