fxctx

package
v0.0.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ListResourcesFailed = iota - 32099
	ReadResourceFailed
	GetPromptFailed
	ToolNotFound
)

Variables

View Source
var (
	ErrToolNotFound = errors.New("tool not found")
)

Functions

func AsPrompt

func AsPrompt(f any) any

func AsResource

func AsResource(f any) any

func AsResourceProvider

func AsResourceProvider(f any) any

func AsTool

func AsTool(f any) any

func ProvidePromptMux

func ProvidePromptMux() fx.Option

func ProvideResourceMux

func ProvideResourceMux() fx.Option

func ProvideToolMux

func ProvideToolMux() fx.Option

Types

type Prompt

type Prompt interface {
	GetMcpPrompt() mcp.Prompt
	Get(*mcp.GetPromptRequest) (*mcp.GetPromptResult, error)
}

func NewPrompt

func NewPrompt(
	p mcp.Prompt,
	get func(*mcp.GetPromptRequest) (*mcp.GetPromptResult, error),
) Prompt

type PromptMux

type PromptMux interface {
	ListPrompts() []mcp.Prompt
	RegisterHandlers(s server.Server)
}

func NewPromptMux

func NewPromptMux(prompts []Prompt) PromptMux

type Resource

type Resource interface {
	GetResource() mcp.Resource
	ReadResource(uri string) (*mcp.ReadResourceResult, error)
}

func NewResource

func NewResource(
	mcpResource mcp.Resource,
	callback func(uri string) (*mcp.ReadResourceResult, error)) Resource

type ResourceMux

type ResourceMux interface {
	GetResources() ([]mcp.Resource, error)
	ReadResource(uri string) (*mcp.ReadResourceResult, error)
	RegisterHandlers(s server.Server)
}

func NewResourceMux

func NewResourceMux(
	resources []Resource,
	resourceProviders []ResourceProvider,
) ResourceMux

type ResourceProvider

type ResourceProvider interface {
	GetResources() ([]mcp.Resource, error)
	ReadResource(uri string) (*mcp.ReadResourceResult, error)
}

func NewResourceProvider

func NewResourceProvider(
	getResources func() ([]mcp.Resource, error),
	readResource func(uri string) (*mcp.ReadResourceResult, error),
) ResourceProvider

type Tool

type Tool interface {
	GetMcpTool() *mcp.Tool
	Callback(args map[string]interface{}) *mcp.CallToolResult
}

func NewTool

func NewTool(
	mcpTool *mcp.Tool,
	callback func(args map[string]interface{}) *mcp.CallToolResult) Tool

type ToolMux

type ToolMux interface {
	GetMcpTools() []mcp.Tool
	CallToolNamed(name string, args map[string]interface{}) (*mcp.CallToolResult, error)
	RegisterHandlers(s server.Server)
}

func NewToolMux

func NewToolMux(
	tools []Tool,
) ToolMux

type ToolResponse

type ToolResponse struct {
	Meta    map[string]interface{}
	Content []interface{}
	IsError *bool
}

Jump to

Keyboard shortcuts

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