pkg

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPromptNotFound   = NewError("prompt not found", -32000)
	ErrResourceNotFound = NewError("resource not found", -32001)
	ErrToolNotFound     = NewError("tool not found", -32002)
	ErrNotImplemented   = NewError("not implemented", -32003)
)

Common errors

Functions

This section is empty.

Types

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error represents a protocol error with a code and message

func NewError

func NewError(message string, code int) *Error

NewError creates a new Error with the given message and code

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface

type PromptProvider

type PromptProvider interface {
	// ListPrompts returns a list of available prompts with optional pagination
	ListPrompts(ctx context.Context, cursor string) ([]protocol.Prompt, string, error)

	// GetPrompt retrieves a specific prompt with the given arguments
	GetPrompt(ctx context.Context, name string, arguments map[string]string) (*protocol.PromptMessage, error)
}

PromptProvider defines the interface for serving prompts

type ResourceProvider

type ResourceProvider interface {
	// ListResources returns a list of available resources with optional pagination
	ListResources(ctx context.Context, cursor string) ([]protocol.Resource, string, error)

	// ReadResource retrieves the contents of a specific resource
	ReadResource(ctx context.Context, uri string) ([]protocol.ResourceContent, error)

	// ListResourceTemplates returns a list of available resource templates
	ListResourceTemplates(ctx context.Context) ([]protocol.ResourceTemplate, error)

	// SubscribeToResource registers for notifications about resource changes
	// Returns a channel that will receive notifications and a cleanup function
	SubscribeToResource(ctx context.Context, uri string) (chan struct{}, func(), error)
}

ResourceProvider defines the interface for serving resources

type ToolProvider

type ToolProvider interface {
	// ListTools returns a list of available tools with optional pagination
	ListTools(ctx context.Context, cursor string) ([]protocol.Tool, string, error)

	// CallTool invokes a specific tool with the given arguments
	CallTool(ctx context.Context, name string, arguments map[string]interface{}) (*protocol.ToolResult, error)
}

ToolProvider defines the interface for serving tools

Jump to

Keyboard shortcuts

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