client

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 14 Imported by: 146

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MCPClient

type MCPClient interface {
	// Initialize sends the initial connection request to the server
	Initialize(
		ctx context.Context,
		request mcp.InitializeRequest,
	) (*mcp.InitializeResult, error)

	// Ping checks if the server is alive
	Ping(ctx context.Context) error

	// ListResources requests a list of available resources from the server
	ListResources(
		ctx context.Context,
		request mcp.ListResourcesRequest,
	) (*mcp.ListResourcesResult, error)

	// ListResourceTemplates requests a list of available resource templates from the server
	ListResourceTemplates(
		ctx context.Context,
		request mcp.ListResourceTemplatesRequest,
	) (*mcp.ListResourceTemplatesResult,
		error)

	// ReadResource reads a specific resource from the server
	ReadResource(
		ctx context.Context,
		request mcp.ReadResourceRequest,
	) (*mcp.ReadResourceResult, error)

	// Subscribe requests notifications for changes to a specific resource
	Subscribe(ctx context.Context, request mcp.SubscribeRequest) error

	// Unsubscribe cancels notifications for a specific resource
	Unsubscribe(ctx context.Context, request mcp.UnsubscribeRequest) error

	// ListPrompts requests a list of available prompts from the server
	ListPrompts(
		ctx context.Context,
		request mcp.ListPromptsRequest,
	) (*mcp.ListPromptsResult, error)

	// GetPrompt retrieves a specific prompt from the server
	GetPrompt(
		ctx context.Context,
		request mcp.GetPromptRequest,
	) (*mcp.GetPromptResult, error)

	// ListTools requests a list of available tools from the server
	ListTools(
		ctx context.Context,
		request mcp.ListToolsRequest,
	) (*mcp.ListToolsResult, error)

	// CallTool invokes a specific tool on the server
	CallTool(
		ctx context.Context,
		request mcp.CallToolRequest,
	) (*mcp.CallToolResult, error)

	// SetLevel sets the logging level for the server
	SetLevel(ctx context.Context, request mcp.SetLevelRequest) error

	// Complete requests completion options for a given argument
	Complete(
		ctx context.Context,
		request mcp.CompleteRequest,
	) (*mcp.CompleteResult, error)

	// Close client connection and cleanup resources
	Close() error

	// OnNotification registers a handler for notifications
	OnNotification(handler func(notification mcp.JSONRPCNotification))
}

MCPClient represents an MCP client interface

type SSEMCPClient added in v0.2.0

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

func NewSSEMCPClient added in v0.2.0

func NewSSEMCPClient(baseURL string) (*SSEMCPClient, error)

func (*SSEMCPClient) CallTool added in v0.2.0

func (c *SSEMCPClient) CallTool(
	ctx context.Context,
	request mcp.CallToolRequest,
) (*mcp.CallToolResult, error)

func (*SSEMCPClient) Close added in v0.2.0

func (c *SSEMCPClient) Close() error

func (*SSEMCPClient) Complete added in v0.2.0

func (c *SSEMCPClient) Complete(
	ctx context.Context,
	request mcp.CompleteRequest,
) (*mcp.CompleteResult, error)

func (*SSEMCPClient) GetEndpoint added in v0.2.0

func (c *SSEMCPClient) GetEndpoint() *url.URL

func (*SSEMCPClient) GetPrompt added in v0.2.0

func (c *SSEMCPClient) GetPrompt(
	ctx context.Context,
	request mcp.GetPromptRequest,
) (*mcp.GetPromptResult, error)

func (*SSEMCPClient) Initialize added in v0.2.0

func (c *SSEMCPClient) Initialize(
	ctx context.Context,
	request mcp.InitializeRequest,
) (*mcp.InitializeResult, error)

func (*SSEMCPClient) ListPrompts added in v0.2.0

func (c *SSEMCPClient) ListPrompts(
	ctx context.Context,
	request mcp.ListPromptsRequest,
) (*mcp.ListPromptsResult, error)

func (*SSEMCPClient) ListResourceTemplates added in v0.5.0

func (c *SSEMCPClient) ListResourceTemplates(
	ctx context.Context,
	request mcp.ListResourceTemplatesRequest,
) (*mcp.ListResourceTemplatesResult, error)

func (*SSEMCPClient) ListResources added in v0.2.0

func (c *SSEMCPClient) ListResources(
	ctx context.Context,
	request mcp.ListResourcesRequest,
) (*mcp.ListResourcesResult, error)

func (*SSEMCPClient) ListTools added in v0.2.0

func (c *SSEMCPClient) ListTools(
	ctx context.Context,
	request mcp.ListToolsRequest,
) (*mcp.ListToolsResult, error)

func (*SSEMCPClient) OnNotification added in v0.5.0

func (c *SSEMCPClient) OnNotification(
	handler func(notification mcp.JSONRPCNotification),
)

func (*SSEMCPClient) Ping added in v0.2.0

func (c *SSEMCPClient) Ping(ctx context.Context) error

func (*SSEMCPClient) ReadResource added in v0.2.0

func (c *SSEMCPClient) ReadResource(
	ctx context.Context,
	request mcp.ReadResourceRequest,
) (*mcp.ReadResourceResult, error)

func (*SSEMCPClient) SetLevel added in v0.2.0

func (c *SSEMCPClient) SetLevel(
	ctx context.Context,
	request mcp.SetLevelRequest,
) error

func (*SSEMCPClient) Start added in v0.2.0

func (c *SSEMCPClient) Start(ctx context.Context) error

func (*SSEMCPClient) Subscribe added in v0.2.0

func (c *SSEMCPClient) Subscribe(
	ctx context.Context,
	request mcp.SubscribeRequest,
) error

func (*SSEMCPClient) Unsubscribe added in v0.2.0

func (c *SSEMCPClient) Unsubscribe(
	ctx context.Context,
	request mcp.UnsubscribeRequest,
) error

type StdioMCPClient

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

func NewStdioMCPClient

func NewStdioMCPClient(
	command string,
	args ...string,
) (*StdioMCPClient, error)

func (*StdioMCPClient) CallTool

func (c *StdioMCPClient) CallTool(
	ctx context.Context,
	request mcp.CallToolRequest,
) (*mcp.CallToolResult, error)

func (*StdioMCPClient) Close

func (c *StdioMCPClient) Close() error

func (*StdioMCPClient) Complete

func (c *StdioMCPClient) Complete(
	ctx context.Context,
	request mcp.CompleteRequest,
) (*mcp.CompleteResult, error)

func (*StdioMCPClient) GetPrompt

func (c *StdioMCPClient) GetPrompt(
	ctx context.Context,
	request mcp.GetPromptRequest,
) (*mcp.GetPromptResult, error)

func (*StdioMCPClient) Initialize

func (c *StdioMCPClient) Initialize(
	ctx context.Context,
	request mcp.InitializeRequest,
) (*mcp.InitializeResult, error)

func (*StdioMCPClient) ListPrompts

func (c *StdioMCPClient) ListPrompts(
	ctx context.Context,
	request mcp.ListPromptsRequest,
) (*mcp.ListPromptsResult, error)

func (*StdioMCPClient) ListResourceTemplates added in v0.5.0

func (c *StdioMCPClient) ListResourceTemplates(
	ctx context.Context,
	request mcp.ListResourceTemplatesRequest,
) (*mcp.
	ListResourceTemplatesResult, error)

func (*StdioMCPClient) ListResources

func (c *StdioMCPClient) ListResources(
	ctx context.Context,
	request mcp.ListResourcesRequest,
) (*mcp.
	ListResourcesResult, error)

func (*StdioMCPClient) ListTools

func (c *StdioMCPClient) ListTools(
	ctx context.Context,
	request mcp.ListToolsRequest,
) (*mcp.ListToolsResult, error)

func (*StdioMCPClient) OnNotification added in v0.5.0

func (c *StdioMCPClient) OnNotification(
	handler func(notification mcp.JSONRPCNotification),
)

func (*StdioMCPClient) Ping

func (c *StdioMCPClient) Ping(ctx context.Context) error

func (*StdioMCPClient) ReadResource

func (c *StdioMCPClient) ReadResource(
	ctx context.Context,
	request mcp.ReadResourceRequest,
) (*mcp.ReadResourceResult,
	error)

func (*StdioMCPClient) SetLevel

func (c *StdioMCPClient) SetLevel(
	ctx context.Context,
	request mcp.SetLevelRequest,
) error

func (*StdioMCPClient) Subscribe

func (c *StdioMCPClient) Subscribe(
	ctx context.Context,
	request mcp.SubscribeRequest,
) error

func (*StdioMCPClient) Unsubscribe

func (c *StdioMCPClient) Unsubscribe(
	ctx context.Context,
	request mcp.UnsubscribeRequest,
) error

Jump to

Keyboard shortcuts

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