Documentation
¶
Overview ¶
Package tool provides MCP tool registration and handling.
Index ¶
Constants ¶
const ( ExecutePythonToolName = "execute_python" DefaultTimeout = 60 MaxTimeout = execsvc.MaxTimeout MinTimeout = execsvc.MinTimeout )
const (
// ManageSessionToolName is the name of the manage_session tool.
ManageSessionToolName = "manage_session"
)
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 ¶
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 ¶
WorkspaceFileInfo represents a file in the session workspace.