Documentation
¶
Index ¶
- Constants
- func ConvertSchema(params, v any) error
- func ExtractDescription(arguments string) string
- func MustSchemaFor[T any]() any
- func SchemaFor[T any]() (any, error)
- func SchemaToMap(params any) (map[string]any, error)
- type BaseToolSet
- type DescriptionToolSet
- func (f *DescriptionToolSet) Instructions() string
- func (f *DescriptionToolSet) SetElicitationHandler(handler ElicitationHandler)
- func (f *DescriptionToolSet) SetManagedOAuth(managed bool)
- func (f *DescriptionToolSet) SetOAuthSuccessHandler(handler func())
- func (f *DescriptionToolSet) Start(ctx context.Context) error
- func (f *DescriptionToolSet) Stop(ctx context.Context) error
- func (f *DescriptionToolSet) Tools(ctx context.Context) ([]Tool, error)
- type ElicitationAction
- type ElicitationHandler
- type ElicitationResult
- type FunctionCall
- type Tool
- type ToolAnnotations
- type ToolCall
- type ToolCallResult
- type ToolHandler
- type ToolSet
- type ToolType
Constants ¶
const (
// DescriptionParam is the parameter name for the description
DescriptionParam = "description"
)
Variables ¶
This section is empty.
Functions ¶
func ConvertSchema ¶ added in v1.7.1
func ExtractDescription ¶ added in v1.19.4
ExtractDescription extracts the description from tool call arguments.
func MustSchemaFor ¶ added in v1.7.1
Types ¶
type BaseToolSet ¶ added in v1.8.2
type BaseToolSet struct{}
BaseToolSet provides default no-op implementations for common ToolSet methods. Embed this in tool implementations to reduce boilerplate.
func (BaseToolSet) Instructions ¶ added in v1.8.2
func (BaseToolSet) Instructions() string
Instructions returns an empty string by default.
func (BaseToolSet) SetElicitationHandler ¶ added in v1.8.2
func (BaseToolSet) SetElicitationHandler(ElicitationHandler)
SetElicitationHandler is a no-op for tools that don't use elicitation.
func (BaseToolSet) SetManagedOAuth ¶ added in v1.8.2
func (BaseToolSet) SetManagedOAuth(bool)
SetManagedOAuth is a no-op for tools that don't use OAuth.
func (BaseToolSet) SetOAuthSuccessHandler ¶ added in v1.8.2
func (BaseToolSet) SetOAuthSuccessHandler(func())
SetOAuthSuccessHandler is a no-op for tools that don't use OAuth.
type DescriptionToolSet ¶ added in v1.19.4
type DescriptionToolSet struct {
// contains filtered or unexported fields
}
DescriptionToolSet wraps a ToolSet and adds a "description" parameter to all tools. This allows the LLM to provide context about what it's doing with each tool call.
func NewDescriptionToolSet ¶ added in v1.19.4
func NewDescriptionToolSet(inner ToolSet) *DescriptionToolSet
NewDescriptionToolSet creates a new DescriptionToolSet wrapping the given ToolSet.
func (*DescriptionToolSet) Instructions ¶ added in v1.19.4
func (f *DescriptionToolSet) Instructions() string
func (*DescriptionToolSet) SetElicitationHandler ¶ added in v1.19.4
func (f *DescriptionToolSet) SetElicitationHandler(handler ElicitationHandler)
func (*DescriptionToolSet) SetManagedOAuth ¶ added in v1.19.4
func (f *DescriptionToolSet) SetManagedOAuth(managed bool)
func (*DescriptionToolSet) SetOAuthSuccessHandler ¶ added in v1.19.4
func (f *DescriptionToolSet) SetOAuthSuccessHandler(handler func())
func (*DescriptionToolSet) Start ¶ added in v1.19.4
func (f *DescriptionToolSet) Start(ctx context.Context) error
type ElicitationAction ¶ added in v1.8.2
type ElicitationAction string
const ( ElicitationActionAccept ElicitationAction = "accept" ElicitationActionDecline ElicitationAction = "decline" ElicitationActionCancel ElicitationAction = "cancel" )
type ElicitationHandler ¶ added in v1.7.0
type ElicitationHandler func(ctx context.Context, req *mcp.ElicitParams) (ElicitationResult, error)
ElicitationHandler is a function type that handles elicitation requests from the MCP server This allows the runtime to handle elicitation requests and propagate them to its own client
type ElicitationResult ¶ added in v1.7.0
type ElicitationResult struct {
Action ElicitationAction `json:"action"`
Content map[string]any `json:"content,omitempty"`
}
type FunctionCall ¶
type Tool ¶
type Tool struct {
Name string `json:"name"`
Category string `json:"category"`
Description string `json:"description,omitempty"`
Parameters any `json:"parameters"`
Annotations ToolAnnotations `json:"annotations"`
OutputSchema any `json:"outputSchema"`
Handler ToolHandler `json:"-"`
AddDescriptionParameter bool `json:"-"`
}
func (*Tool) DisplayName ¶ added in v0.7.0
type ToolAnnotations ¶ added in v1.7.0
type ToolAnnotations mcp.ToolAnnotations
type ToolCall ¶
type ToolCall struct {
ID string `json:"id,omitempty"`
Type ToolType `json:"type"`
Function FunctionCall `json:"function"`
}
type ToolCallResult ¶
type ToolCallResult struct {
Output string `json:"output"`
IsError bool `json:"isError,omitempty"`
Meta any `json:"meta,omitempty"`
}
func ResultError ¶ added in v1.8.2
func ResultError(output string) *ToolCallResult
func ResultSuccess ¶ added in v1.8.2
func ResultSuccess(output string) *ToolCallResult
type ToolHandler ¶
type ToolHandler func(ctx context.Context, toolCall ToolCall) (*ToolCallResult, error)
func NewHandler ¶ added in v1.19.1
func NewHandler[T any](fn func(context.Context, T) (*ToolCallResult, error)) ToolHandler
NewHandler creates a type-safe tool handler from a function that accepts typed parameters. It handles JSON unmarshaling of the tool call arguments into the specified type T.