Documentation
¶
Overview ¶
Package mcphost provides MCP (Model Context Protocol) host management for TokMan
Index ¶
- type ClientInfo
- type Error
- type EventHandler
- type EventType
- type Host
- func (h *Host) CallTool(ctx context.Context, serverID string, toolName string, ...) (json.RawMessage, error)
- func (h *Host) CloseSession(sessionID string) error
- func (h *Host) ConnectServer(ctx context.Context, serverID string) error
- func (h *Host) CreateSession(clientInfo ClientInfo, serverID string) (*Session, error)
- func (h *Host) DisconnectServer(serverID string) error
- func (h *Host) GetServer(id string) (*Server, error)
- func (h *Host) ID() string
- func (h *Host) ListServers() []*Server
- func (h *Host) ListTools(serverID string) ([]Tool, error)
- func (h *Host) Name() string
- func (h *Host) ReadResource(ctx context.Context, serverID string, uri string) (json.RawMessage, error)
- func (h *Host) RegisterServer(id string, name string, transport Transport) (*Server, error)
- func (h *Host) SetEventHandler(handler EventHandler)
- func (h *Host) Shutdown() error
- type HostCapabilities
- type HostConfig
- type HostEvent
- type LoggingCapability
- type Message
- type Prompt
- type PromptArgument
- type PromptsCapability
- type Resource
- type ResourcesCapability
- type Server
- type ServerCapabilities
- type ServerStatus
- type Session
- type SessionStatus
- type Tool
- type ToolsCapability
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientInfo ¶
ClientInfo represents client information
type Error ¶
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
Error represents an MCP error
type EventType ¶
type EventType string
EventType represents event types
const ( EventServerConnected EventType = "server_connected" EventServerDisconnected EventType = "server_disconnected" EventServerError EventType = "server_error" EventSessionCreated EventType = "session_created" EventSessionClosed EventType = "session_closed" EventToolCalled EventType = "tool_called" EventResourceAccessed EventType = "resource_accessed" )
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host manages MCP server connections
func (*Host) CallTool ¶
func (h *Host) CallTool(ctx context.Context, serverID string, toolName string, arguments map[string]interface{}) (json.RawMessage, error)
CallTool invokes a tool on a server
func (*Host) CloseSession ¶
CloseSession closes a session
func (*Host) ConnectServer ¶
ConnectServer connects to an MCP server
func (*Host) CreateSession ¶
func (h *Host) CreateSession(clientInfo ClientInfo, serverID string) (*Session, error)
CreateSession creates a new client session
func (*Host) DisconnectServer ¶
DisconnectServer disconnects from a server
func (*Host) ListServers ¶
ListServers returns all registered servers
func (*Host) ReadResource ¶
func (h *Host) ReadResource(ctx context.Context, serverID string, uri string) (json.RawMessage, error)
ReadResource reads a resource from a server
func (*Host) RegisterServer ¶
RegisterServer registers an MCP server
func (*Host) SetEventHandler ¶
func (h *Host) SetEventHandler(handler EventHandler)
SetEventHandler sets the event handler
type HostCapabilities ¶
HostCapabilities defines what the host supports
type HostConfig ¶
type HostConfig struct {
Name string
Version string
MaxConnections int
ConnectionTimeout time.Duration
RequestTimeout time.Duration
AutoReconnect bool
Capabilities HostCapabilities
}
HostConfig holds host configuration
type HostEvent ¶
type HostEvent struct {
Type EventType
Timestamp time.Time
ServerID string
SessionID string
Message string
Data interface{}
}
HostEvent represents a host event
type LoggingCapability ¶
type LoggingCapability struct {
}
LoggingCapability defines logging support
type Message ¶
type Message struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id,omitempty"`
Method string `json:"method,omitempty"`
Params json.RawMessage `json:"params,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
}
Message represents an MCP protocol message
type Prompt ¶
type Prompt struct {
Name string
Description string
Arguments []PromptArgument
}
Prompt represents an MCP prompt
type PromptArgument ¶
PromptArgument represents a prompt argument
type PromptsCapability ¶
type PromptsCapability struct {
ListChanged bool
}
PromptsCapability defines prompt support
type ResourcesCapability ¶
ResourcesCapability defines resource support
type Server ¶
type Server struct {
ID string
Name string
Version string
Transport Transport
Status ServerStatus
Capabilities ServerCapabilities
Tools []Tool
Resources []Resource
Prompts []Prompt
LastPing time.Time
ConnectTime time.Time
// contains filtered or unexported fields
}
Server represents a connected MCP server
type ServerCapabilities ¶
type ServerCapabilities struct {
Tools *ToolsCapability
Resources *ResourcesCapability
Prompts *PromptsCapability
Logging *LoggingCapability
}
ServerCapabilities defines what a server supports
type ServerStatus ¶
type ServerStatus string
ServerStatus represents server connection status
const ( ServerStatusDisconnected ServerStatus = "disconnected" ServerStatusConnecting ServerStatus = "connecting" ServerStatusConnected ServerStatus = "connected" ServerStatusError ServerStatus = "error" )
type Session ¶
type Session struct {
ID string
ClientInfo ClientInfo
ServerID string
Status SessionStatus
CreatedAt time.Time
LastActivity time.Time
// contains filtered or unexported fields
}
Session represents a client session
type SessionStatus ¶
type SessionStatus string
SessionStatus represents session status
const ( SessionStatusActive SessionStatus = "active" SessionStatusInactive SessionStatus = "inactive" SessionStatusClosed SessionStatus = "closed" )
type Tool ¶
type Tool struct {
Name string
Description string
InputSchema json.RawMessage
}
Tool represents an MCP tool
type ToolsCapability ¶
type ToolsCapability struct {
ListChanged bool
}
ToolsCapability defines tool support