tool

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package tool provides utilities for creating and registering MCP tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseTool

type BaseTool struct {
	// contains filtered or unexported fields
}

BaseTool provides a base implementation of ToolHandler.

func NewBaseTool

func NewBaseTool(name, description string) *BaseTool

NewBaseTool creates a new base tool with the given name and description.

func (*BaseTool) Handler

func (t *BaseTool) Handler() func(ctx context.Context, progressToken *protocol.ProgressToken, arguments any) ([]protocol.Content, bool)

Handler implements ToolHandler.Handler.

func (*BaseTool) Tool

func (t *BaseTool) Tool() protocol.Tool

Tool implements ToolHandler.Tool.

func (*BaseTool) WithHandler

func (t *BaseTool) WithHandler(handler func(ctx context.Context, progressToken *protocol.ProgressToken, arguments any) ([]protocol.Content, bool)) *BaseTool

WithHandler sets the tool's handler function.

type ToolHandler

type ToolHandler interface {
	// Tool returns the tool definition.
	Tool() protocol.Tool
	// Handler returns the tool's handler function.
	Handler() func(ctx context.Context, progressToken *protocol.ProgressToken, arguments any) ([]protocol.Content, bool)
}

ToolHandler is the interface that tool implementations should satisfy.

Jump to

Keyboard shortcuts

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