Documentation
¶
Index ¶
- type Base
- func (b *Base) Close() error
- func (b *Base) Done() <-chan struct{}
- func (b *Base) GetRouter() *transport.MessageRouter
- func (b *Base) Logf(format string, args ...interface{})
- func (b *Base) RegisterNotificationHandler(method string, handler NotificationHandler)
- func (b *Base) RegisterRequestHandler(method string, handler RequestHandler)
- func (b *Base) SendNotification(ctx context.Context, method string, params interface{}) error
- func (b *Base) SendRequest(ctx context.Context, method string, params interface{}) (*types.Message, error)
- func (b *Base) SendResponse(ctx context.Context, reqID types.ID, result interface{}, err error) error
- func (b *Base) SetLogger(l logger.Logger)
- func (b *Base) Start(ctx context.Context) error
- type NotificationHandler
- type RequestHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct {
Started bool
// contains filtered or unexported fields
}
Base is a base abstraction for MCP clients and servers
func (*Base) Done ¶
func (b *Base) Done() <-chan struct{}
Done returns a channel that is closed when the transport is closed
func (*Base) GetRouter ¶
func (b *Base) GetRouter() *transport.MessageRouter
GetRouter returns the message router
func (*Base) RegisterNotificationHandler ¶
func (b *Base) RegisterNotificationHandler(method string, handler NotificationHandler)
RegisterNotificationHandler registers a handler for a notification method
func (*Base) RegisterRequestHandler ¶
func (b *Base) RegisterRequestHandler(method string, handler RequestHandler)
RegisterRequestHandler registers a handler for a request method
func (*Base) SendNotification ¶
SendNotification sends a notification (no response expected)
func (*Base) SendRequest ¶
func (b *Base) SendRequest(ctx context.Context, method string, params interface{}) (*types.Message, error)
SendRequest sends a request and waits for the response
func (*Base) SendResponse ¶
func (b *Base) SendResponse(ctx context.Context, reqID types.ID, result interface{}, err error) error
SendResponse sends a response to a request
type NotificationHandler ¶
type NotificationHandler func(ctx context.Context, params json.RawMessage)
NotificationHandler handles MCP notifications
type RequestHandler ¶
type RequestHandler func(ctx context.Context, params *json.RawMessage) (interface{}, error)
RequestHandler handles MCP requests and returns a response
Click to show internal directories.
Click to hide internal directories.