connection

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package connection implements MCP connection handling.

Index

Constants

This section is empty.

Variables

View Source
var ConnectionsMutex sync.RWMutex
View Source
var RemoteConnections = make(map[string]*MCPConnection)

RemoteConnections stores active connections to remote servers

Functions

func CleanupConnections

func CleanupConnections(logger log.Logger)

CleanupConnections closes all active connections and clears the map

Types

type ConnectionState

type ConnectionState int32

ConnectionState tracks the lifecycle state of a connection

const (
	ConnectionStateIdle ConnectionState = iota
	ConnectionStateConnecting
	ConnectionStateConnected
	ConnectionStateDisconnecting
	ConnectionStateDisconnected
	ConnectionStateFailed
)

type MCPConnection

type MCPConnection struct {
	Client *client.SSEMCPClient // Use original client type for compatibility
	URL    string
	Ctx    context.Context
	Cancel context.CancelFunc
	Tools  []mcp.Tool

	EnhancedMode bool // Whether this connection uses the enhanced client wrapper
	// contains filtered or unexported fields
}

MCPConnection represents a connection to a remote MCP server

func ConnectToRemoteServer

func ConnectToRemoteServer(ctx context.Context, logger log.Logger, remote config.RemoteMCPServer) (*MCPConnection, error)

ConnectToRemoteServer establishes a connection to a remote MCP server

func (*MCPConnection) GetTools

func (c *MCPConnection) GetTools() []mcp.Tool

GetTools returns the tools list in a thread-safe way

func (*MCPConnection) SetState

func (c *MCPConnection) SetState(state ConnectionState)

SetState sets the connection state atomically

func (*MCPConnection) State

func (c *MCPConnection) State() ConnectionState

State gets the current connection state

Jump to

Keyboard shortcuts

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