mcp

package
v0.207.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 "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 manager. notifier is the single UI ingress the liveness probes push MCPServerStatusUpdateEvent through; a nil notifier degrades to no UI pushes.

func (*Supervisor) ClearToolCount added in v0.207.0

func (m *Supervisor) ClearToolCount(serverName string)

ClearToolCount removes the tool count for a specific server

func (*Supervisor) Close added in v0.207.0

func (m *Supervisor) Close() error

Close stops monitoring, stops containers, and cleans up resources

func (*Supervisor) GetClient added in v0.207.0

func (m *Supervisor) 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 (*Supervisor) GetClients added in v0.207.0

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

GetClients returns a list of MCP clients

func (*Supervisor) GetTotalServers added in v0.207.0

func (m *Supervisor) GetTotalServers() int

GetTotalServers returns the total number of configured MCP servers from config

func (*Supervisor) StartMonitoring added in v0.207.0

func (m *Supervisor) 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 (*Supervisor) StartServer added in v0.207.0

func (m *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 (m *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 (m *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 (m *Supervisor) StopServers(ctx context.Context) error

StopServers stops all running MCP server containers

func (*Supervisor) UpdateToolCount added in v0.207.0

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

UpdateToolCount updates the tool count for a specific server

Jump to

Keyboard shortcuts

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