client

package
v0.0.0-...-1267af6 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseClient

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

BaseClient provides common functionality for MCP clients

func (*BaseClient) ListToolsWithTransport

func (c *BaseClient) ListToolsWithTransport(ctx context.Context, transport interface {
	SendRequest(ctx context.Context, method string, params interface{}) (*types.Response, error)
}) ([]types.Tool, error)

ListToolsWithTransport implements the common logic for listing tools across different transports

type Client

type Client interface {
	// Initialize sends the initialization request to the server
	Initialize(ctx context.Context) error

	// ListTools returns a list of available tools
	ListTools(ctx context.Context) ([]types.Tool, error)

	// ExecuteTool executes a tool with the given parameters
	ExecuteTool(ctx context.Context, call types.ToolCall) (*types.ToolResult, error)

	// ListResources returns a list of available resources
	ListResources(ctx context.Context) ([]types.Resource, error)

	// GetResourceTemplates returns a list of available resource templates
	GetResourceTemplates(ctx context.Context) ([]types.Resource, error)

	// ApplyResourceTemplate applies a resource template with the given parameters
	ApplyResourceTemplate(ctx context.Context, template types.ResourceTemplate) (*types.ResourceTemplateResult, error)

	// Close shuts down the client and cleans up resources
	Close() error
}

Client represents an MCP client

type Session

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

Session represents an MCP session

func NewSession

func NewSession(reader io.Reader, writer io.Writer, client Client) (*Session, error)

NewSession creates a new session with the given reader, writer, and client

func (*Session) Close

func (s *Session) Close() error

Close shuts down the session and cleans up resources

func (*Session) ExecuteTool

func (s *Session) ExecuteTool(ctx context.Context, call types.ToolCall) (*types.ToolResult, error)

ExecuteTool executes a tool with the given parameters

func (*Session) GetTools

func (s *Session) GetTools() []types.Tool

GetTools returns a list of available tools

func (*Session) Run

func (s *Session) Run(ctx context.Context) error

Run starts the session

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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