decorators

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: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CoreMethodAccess = map[string]AccessType{
	"initialize":     AccessBoth,
	"tools/list":     AccessClient,
	"tools/call":     AccessClient,
	"tools/progress": AccessServer,
	"tools/cancel":   AccessClient,

	"mcp/list_tools": AccessClient,
	"mcp/call_tool":  AccessClient,
	"mcp/progress":   AccessServer,
	"mcp/cancel":     AccessClient,
}

CoreMethodAccess maps core method names to their access types

Functions

func Client

func Client(method string) error

Client is a decorator that ensures a method is accessible by clients

func GetMethodAlternatives

func GetMethodAlternatives(method string) []string

GetMethodAlternatives returns alternative method names for a given method This handles cases where method names might have different formats (e.g., with or without slashes)

func Server

func Server(method string) error

Server is a decorator that ensures a method is accessible by servers

func ValidateAccess

func ValidateAccess(method string, role string) error

ValidateAccess checks if a method has the correct access type for the given role

func ValidateMethodName

func ValidateMethodName(method string, isClient bool) error

ValidateMethodName checks if a method name is valid and has the correct access type

func ValidateMethodPath

func ValidateMethodPath(method string) error

ValidateMethodPath checks if a method path is valid

Types

type AccessType

type AccessType int

AccessType represents the type of access a method has

const (
	// AccessClient indicates the method is accessible only by clients
	AccessClient AccessType = iota
	// AccessServer indicates the method is accessible only by servers
	AccessServer
	// AccessBoth indicates the method is accessible by both clients and servers
	AccessBoth
)

Jump to

Keyboard shortcuts

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