Documentation
¶
Index ¶
- type Client
- func (c *Client) CallTool(ctx context.Context, name string, arguments map[string]interface{}) (*protocol.ToolResult, error)
- func (c *Client) Close(ctx context.Context) error
- func (c *Client) CreateMessage(ctx context.Context, messages []protocol.Message, ...) (*protocol.Message, error)
- func (c *Client) GetPrompt(ctx context.Context, name string, arguments map[string]string) (*protocol.PromptMessage, error)
- func (c *Client) Initialize(ctx context.Context, capabilities protocol.ClientCapabilities) error
- func (c *Client) ListPrompts(ctx context.Context, cursor string) ([]protocol.Prompt, string, error)
- func (c *Client) ListResources(ctx context.Context, cursor string) ([]protocol.Resource, string, error)
- func (c *Client) ListTools(ctx context.Context, cursor string) ([]protocol.Tool, string, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) ReadResource(ctx context.Context, uri string) (*protocol.ResourceContent, error)
- type SSETransport
- type StdioTransport
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents an MCP client that can use different transports
func (*Client) CallTool ¶
func (c *Client) CallTool(ctx context.Context, name string, arguments map[string]interface{}) (*protocol.ToolResult, error)
CallTool calls a specific tool on the server
func (*Client) CreateMessage ¶
func (c *Client) CreateMessage(ctx context.Context, messages []protocol.Message, modelPreferences protocol.ModelPreferences, systemPrompt string, maxTokens int) (*protocol.Message, error)
CreateMessage sends a sampling request to create a message
func (*Client) GetPrompt ¶
func (c *Client) GetPrompt(ctx context.Context, name string, arguments map[string]string) (*protocol.PromptMessage, error)
GetPrompt retrieves a specific prompt from the server
func (*Client) Initialize ¶
Initialize initializes the connection with the server
func (*Client) ListPrompts ¶
ListPrompts retrieves the list of available prompts from the server
func (*Client) ListResources ¶
func (c *Client) ListResources(ctx context.Context, cursor string) ([]protocol.Resource, string, error)
ListResources retrieves the list of available resources from the server
func (*Client) ReadResource ¶
ReadResource retrieves the content of a specific resource from the server
type SSETransport ¶
type SSETransport struct {
// contains filtered or unexported fields
}
SSETransport implements Transport using Server-Sent Events
func NewSSETransport ¶
func NewSSETransport(baseURL string, logger zerolog.Logger) *SSETransport
NewSSETransport creates a new SSE transport
func (*SSETransport) Close ¶
func (t *SSETransport) Close(ctx context.Context) error
Close closes the transport
func (*SSETransport) Send ¶
func (t *SSETransport) Send(ctx context.Context, request *protocol.Request) (*protocol.Response, error)
Send sends a request and returns the response
func (*SSETransport) SetNotificationHandler ¶ added in v0.0.2
func (t *SSETransport) SetNotificationHandler(handler func(*protocol.Response))
SetNotificationHandler sets the handler for notifications
type StdioTransport ¶
type StdioTransport struct {
// contains filtered or unexported fields
}
StdioTransport implements Transport using standard input/output
func NewCommandStdioTransport ¶
func NewCommandStdioTransport(logger zerolog.Logger, command string, args ...string) (*StdioTransport, error)
NewCommandStdioTransport creates a new stdio transport that launches a command
func NewStdioTransport ¶
func NewStdioTransport(logger zerolog.Logger) *StdioTransport
NewStdioTransport creates a new stdio transport
func (*StdioTransport) Close ¶
func (t *StdioTransport) Close(ctx context.Context) error
Close closes the transport
func (*StdioTransport) Send ¶
func (t *StdioTransport) Send(ctx context.Context, request *protocol.Request) (*protocol.Response, error)
Send sends a request and returns the response
func (*StdioTransport) SetNotificationHandler ¶ added in v0.0.2
func (t *StdioTransport) SetNotificationHandler(handler func(*protocol.Response))
SetNotificationHandler sets the handler for notifications
type Transport ¶
type Transport interface { // Send sends a request and returns the response Send(ctx context.Context, request *protocol.Request) (*protocol.Response, error) // Close closes the transport connection Close(ctx context.Context) error // SetNotificationHandler sets a handler for notifications SetNotificationHandler(handler func(*protocol.Response)) }
Transport represents a client transport mechanism