tool

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package tool provides MCP tool registration and handling.

Index

Constants

View Source
const (
	ExecutePythonToolName = "execute_python"
	DefaultTimeout        = 60
	MaxTimeout            = execsvc.MaxTimeout
	MinTimeout            = execsvc.MinTimeout
)
View Source
const (
	// ManageSessionToolName is the name of the manage_session tool.
	ManageSessionToolName = "manage_session"
)
View Source
const SearchToolName = "search"

Variables

This section is empty.

Functions

func CallToolError

func CallToolError(err error) *mcp.CallToolResult

CallToolError creates an error result for a tool call.

func CallToolSuccess

func CallToolSuccess(text string) *mcp.CallToolResult

CallToolSuccess creates a successful text result for a tool call.

Types

type CreateSessionResponse

type CreateSessionResponse struct {
	SessionID    string `json:"session_id"`
	TTLRemaining string `json:"ttl_remaining"`
	Message      string `json:"message"`
}

CreateSessionResponse is the response for the create operation.

type Definition

type Definition struct {
	Tool    mcp.Tool
	Handler Handler
}

Definition describes a tool's metadata and handler.

func NewExecutePythonTool

func NewExecutePythonTool(
	log logrus.FieldLogger,
	sandboxSvc sandbox.Service,
	cfg *config.Config,
	service *execsvc.Service,
) Definition

func NewManageSessionTool

func NewManageSessionTool(
	log logrus.FieldLogger,
	service *execsvc.Service,
) Definition

NewManageSessionTool creates the manage_session tool definition.

func NewSearchTool

func NewSearchTool(
	log logrus.FieldLogger,
	service *searchsvc.Service,
) Definition

NewSearchTool creates the unified search MCP tool definition.

type Handler

type Handler func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)

Handler processes a tool call and returns the result.

type ListSessionsResponse

type ListSessionsResponse struct {
	Sessions    []SessionDetail `json:"sessions"`
	Total       int             `json:"total"`
	MaxSessions int             `json:"max_sessions"`
}

ListSessionsResponse is the response for the list operation.

type Registry

type Registry interface {
	// Register adds a tool definition to the registry.
	Register(def Definition)
	// List returns all registered tool definitions.
	List() []mcp.Tool
	// Get retrieves a tool handler by name.
	// Returns the handler and a boolean indicating if the tool exists.
	Get(name string) (Handler, bool)
	// Definitions returns all registered tool definitions.
	Definitions() []Definition
}

Registry manages tool registration and lookup.

func NewRegistry

func NewRegistry(log logrus.FieldLogger) Registry

NewRegistry creates a new tool registry.

type SessionDetail

type SessionDetail struct {
	SessionID      string              `json:"session_id"`
	CreatedAt      string              `json:"created_at"`
	LastUsed       string              `json:"last_used"`
	TTLRemaining   string              `json:"ttl_remaining"`
	WorkspaceFiles []WorkspaceFileInfo `json:"workspace_files"`
}

SessionDetail represents a session in the list response.

type WorkspaceFileInfo

type WorkspaceFileInfo struct {
	Name string `json:"name"`
	Size string `json:"size"`
}

WorkspaceFileInfo represents a file in the session workspace.

Jump to

Keyboard shortcuts

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