client

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: MIT Imports: 9 Imported by: 123

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,
		capabilities mcp.ClientCapabilities,
		clientInfo mcp.Implementation,
		protocolVersion string,
	) (*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,
		cursor *string,
	) (*mcp.ListResourcesResult, error)

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

	// Subscribe requests notifications for changes to a specific resource
	Subscribe(ctx context.Context, uri string) error

	// Unsubscribe cancels notifications for a specific resource
	Unsubscribe(ctx context.Context, uri string) error

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

	// GetPrompt retrieves a specific prompt from the server
	GetPrompt(
		ctx context.Context,
		name string,
		arguments map[string]string,
	) (*mcp.GetPromptResult, error)

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

	// CallTool invokes a specific tool on the server
	CallTool(
		ctx context.Context,
		name string,
		arguments map[string]interface{},
	) (*mcp.CallToolResult, error)

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

	// Complete requests completion options for a given argument
	Complete(
		ctx context.Context,
		ref interface{},
		argument mcp.CompleteArgument,
	) (*mcp.CompleteResult, error)
}

Client represents an MCP client interface

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,
	name string,
	arguments map[string]interface{},
) (*mcp.CallToolResult, error)

func (*StdioMCPClient) Close

func (c *StdioMCPClient) Close() error

func (*StdioMCPClient) Complete

func (c *StdioMCPClient) Complete(
	ctx context.Context,
	ref interface{},
	argument mcp.CompleteArgument,
) (*mcp.CompleteResult, error)

func (*StdioMCPClient) GetPrompt

func (c *StdioMCPClient) GetPrompt(
	ctx context.Context,
	name string,
	arguments map[string]string,
) (*mcp.GetPromptResult, error)

func (*StdioMCPClient) Initialize

func (c *StdioMCPClient) Initialize(
	ctx context.Context,
	capabilities mcp.ClientCapabilities,
	clientInfo mcp.Implementation,
	protocolVersion string,
) (*mcp.InitializeResult, error)

func (*StdioMCPClient) ListPrompts

func (c *StdioMCPClient) ListPrompts(
	ctx context.Context,
	cursor *string,
) (*mcp.ListPromptsResult, error)

func (*StdioMCPClient) ListResources

func (c *StdioMCPClient) ListResources(
	ctx context.Context,
	cursor *string,
) (*mcp.ListResourcesResult, error)

func (*StdioMCPClient) ListTools

func (c *StdioMCPClient) ListTools(
	ctx context.Context,
	cursor *string,
) (*mcp.ListToolsResult, error)

func (*StdioMCPClient) Ping

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

func (*StdioMCPClient) ReadResource

func (c *StdioMCPClient) ReadResource(
	ctx context.Context,
	uri string,
) (*mcp.ReadResourceResult, error)

func (*StdioMCPClient) SetLevel

func (c *StdioMCPClient) SetLevel(
	ctx context.Context,
	level mcp.LoggingLevel,
) error

func (*StdioMCPClient) Subscribe

func (c *StdioMCPClient) Subscribe(ctx context.Context, uri string) error

func (*StdioMCPClient) Unsubscribe

func (c *StdioMCPClient) Unsubscribe(ctx context.Context, uri string) error

Jump to

Keyboard shortcuts

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