client

package
v0.2.24 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: MIT Imports: 14 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseNotifyHandler added in v0.1.10

type BaseNotifyHandler struct {
	Logger pkg.Logger
}

func NewBaseNotifyHandler added in v0.1.10

func NewBaseNotifyHandler() *BaseNotifyHandler

func (*BaseNotifyHandler) PromptListChanged added in v0.1.10

func (handler *BaseNotifyHandler) PromptListChanged(_ context.Context, request *protocol.PromptListChangedNotification) error

func (*BaseNotifyHandler) ResourceListChanged added in v0.1.10

func (handler *BaseNotifyHandler) ResourceListChanged(_ context.Context, request *protocol.ResourceListChangedNotification) error

func (*BaseNotifyHandler) ResourcesUpdated added in v0.1.10

func (handler *BaseNotifyHandler) ResourcesUpdated(_ context.Context, request *protocol.ResourceUpdatedNotification) error

func (*BaseNotifyHandler) ToolsListChanged added in v0.1.10

func (handler *BaseNotifyHandler) ToolsListChanged(_ context.Context, request *protocol.ToolListChangedNotification) error

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(t transport.ClientTransport, opts ...Option) (*Client, error)

func (*Client) CallTool

func (client *Client) CallTool(ctx context.Context, request *protocol.CallToolRequest) (*protocol.CallToolResult, error)

func (*Client) CallToolWithProgressChan added in v0.2.9

func (client *Client) CallToolWithProgressChan(ctx context.Context, request *protocol.CallToolRequest,
	progressCh chan<- *protocol.ProgressNotification) (*protocol.CallToolResult, error)

CallToolWithProgressChan progressCh Used to return the progress notification, chan will close in the method after the end of the function.

func (*Client) Close

func (client *Client) Close() error

func (*Client) GetPrompt

func (client *Client) GetPrompt(ctx context.Context, request *protocol.GetPromptRequest) (*protocol.GetPromptResult, error)

func (*Client) GetServerCapabilities

func (client *Client) GetServerCapabilities() protocol.ServerCapabilities

func (*Client) GetServerInfo

func (client *Client) GetServerInfo() protocol.Implementation

func (*Client) GetServerInstructions

func (client *Client) GetServerInstructions() string

func (*Client) ListPrompts

func (client *Client) ListPrompts(ctx context.Context) (*protocol.ListPromptsResult, error)

func (*Client) ListResourceTemplates

func (client *Client) ListResourceTemplates(ctx context.Context) (*protocol.ListResourceTemplatesResult, error)

func (*Client) ListResources

func (client *Client) ListResources(ctx context.Context) (*protocol.ListResourcesResult, error)

func (*Client) ListTools

func (client *Client) ListTools(ctx context.Context) (*protocol.ListToolsResult, error)

func (*Client) Ping

func (client *Client) Ping(ctx context.Context, request *protocol.PingRequest) (*protocol.PingResult, error)

func (*Client) ReadResource

func (client *Client) ReadResource(ctx context.Context, request *protocol.ReadResourceRequest) (*protocol.ReadResourceResult, error)

func (*Client) SubscribeResourceChange

func (client *Client) SubscribeResourceChange(ctx context.Context, request *protocol.SubscribeRequest) (*protocol.SubscribeResult, error)

func (*Client) UnSubscribeResourceChange

func (client *Client) UnSubscribeResourceChange(ctx context.Context, request *protocol.UnsubscribeRequest) (*protocol.UnsubscribeResult, error)

type NotifyHandler added in v0.1.10

type NotifyHandler interface {
	ToolsListChanged(ctx context.Context, request *protocol.ToolListChangedNotification) error
	PromptListChanged(ctx context.Context, request *protocol.PromptListChangedNotification) error
	ResourceListChanged(ctx context.Context, request *protocol.ResourceListChangedNotification) error
	ResourcesUpdated(ctx context.Context, request *protocol.ResourceUpdatedNotification) error
}

NotifyHandler When implementing a custom NotifyHandler, you can combine it with BaseNotifyHandler to implement it on demand without implementing extra methods.

type Option

type Option func(*Client)

func WithClientInfo

func WithClientInfo(info *protocol.Implementation) Option

func WithInitTimeout

func WithInitTimeout(timeout time.Duration) Option

func WithLogger

func WithLogger(logger pkg.Logger) Option

func WithNotifyHandler added in v0.1.10

func WithNotifyHandler(handler NotifyHandler) Option

func WithSamplingHandler added in v0.2.3

func WithSamplingHandler(handler SamplingHandler) Option

type SamplingHandler added in v0.2.3

type SamplingHandler interface {
	CreateMessage(ctx context.Context, request *protocol.CreateMessageRequest) (*protocol.CreateMessageResult, error)
}

Jump to

Keyboard shortcuts

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