Documentation
¶
Index ¶
- func EncodeSSEMessage(event string, data []byte) ([]byte, error)
- func MarshalJSONEvent(v any) ([]byte, error)
- func ParseJSON(data []byte) json.RawMessage
- func ParseSSE(r io.Reader, out chan<- SSEEvent) error
- type BackendConfig
- type BackendInfo
- type BackendStatus
- type BackendType
- type ClientConfig
- type ClientOption
- type HealthCheckConfig
- type MCPClient
- func (c *MCPClient) CallTool(ctx context.Context, name string, args json.RawMessage) (*protocol.ToolResult, error)
- func (c *MCPClient) Close() error
- func (c *MCPClient) Connect(ctx context.Context) error
- func (c *MCPClient) Info() BackendInfo
- func (c *MCPClient) ListTools(ctx context.Context) ([]protocol.ToolDefinition, error)
- func (c *MCPClient) SendRequest(ctx context.Context, req *protocol.Request) (*protocol.Response, error)
- type MessageWriter
- type MultiClient
- type SSEClient
- type SSEEvent
- type SSEStream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalJSONEvent ¶
func ParseJSON ¶
func ParseJSON(data []byte) json.RawMessage
Types ¶
type BackendConfig ¶
type BackendConfig struct {
Name string `yaml:"name"`
Type BackendType `yaml:"type"`
Command string `yaml:"command,omitempty"`
Args []string `yaml:"args,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
URL string `yaml:"url,omitempty"`
Timeout time.Duration `yaml:"timeout,omitempty"`
MaxRetries int `yaml:"maxRetries,omitempty"`
HealthCheck *HealthCheckConfig `yaml:"healthCheck,omitempty"`
}
type BackendInfo ¶
type BackendInfo struct {
Config BackendConfig
Status BackendStatus
Tools []protocol.ToolDefinition
Resources []protocol.Resource
Prompts []protocol.Prompt
Latency time.Duration
ConnectedAt time.Time
ErrorCount int
}
type BackendStatus ¶
type BackendStatus string
const ( StatusConnected BackendStatus = "connected" StatusDisconnected BackendStatus = "disconnected" StatusError BackendStatus = "error" StatusDraining BackendStatus = "draining" )
type BackendType ¶
type BackendType string
const ( BackendTypeStdio BackendType = "stdio" BackendTypeSSE BackendType = "sse" )
type ClientConfig ¶
type ClientConfig struct {
MaxRetries int
RetryDelay time.Duration
RequestTimeout time.Duration
BufferSize int
}
func DefaultClientConfig ¶
func DefaultClientConfig() ClientConfig
type ClientOption ¶
type ClientOption func(*ClientConfig)
func WithBufferSize ¶
func WithBufferSize(n int) ClientOption
func WithMaxRetries ¶
func WithMaxRetries(n int) ClientOption
func WithRequestTimeout ¶
func WithRequestTimeout(d time.Duration) ClientOption
type HealthCheckConfig ¶
type MCPClient ¶
type MCPClient struct {
// contains filtered or unexported fields
}
func NewMCPClient ¶
func NewMCPClient(backend BackendConfig, opts ...ClientOption) *MCPClient
func (*MCPClient) CallTool ¶
func (c *MCPClient) CallTool(ctx context.Context, name string, args json.RawMessage) (*protocol.ToolResult, error)
func (*MCPClient) Info ¶
func (c *MCPClient) Info() BackendInfo
type MessageWriter ¶
type MessageWriter struct {
// contains filtered or unexported fields
}
func NewMessageWriter ¶
func NewMessageWriter(endpoint string) *MessageWriter
func (*MessageWriter) WriteMessage ¶
func (w *MessageWriter) WriteMessage(data []byte) error
type MultiClient ¶
type MultiClient struct {
// contains filtered or unexported fields
}
func NewMultiClient ¶
func NewMultiClient() *MultiClient
func (*MultiClient) All ¶
func (mc *MultiClient) All() []*MCPClient
func (*MultiClient) CloseAll ¶
func (mc *MultiClient) CloseAll()
func (*MultiClient) Register ¶
func (mc *MultiClient) Register(name string, client *MCPClient)
type SSEClient ¶
type SSEClient struct {
// contains filtered or unexported fields
}
func NewSSEClient ¶
type SSEEvent ¶
func DecodeSSEMessage ¶
type SSEStream ¶
type SSEStream struct {
// contains filtered or unexported fields
}
func NewSSEStream ¶
func NewSSEStream() *SSEStream
Click to show internal directories.
Click to hide internal directories.