Documentation
¶
Index ¶
- Variables
- func FormatInspectResultAsJSDoc(result *InspectResult) string
- func FormatListResultAsText(tools []ListToolResult, total int) string
- func HandleExecuteTool(ctx context.Context, logger *slog.Logger, manager *client.Manager, ...) (*mcp.CallToolResult, error)
- func HandleInspectTool(ctx context.Context, provider ToolProvider, req *mcp.CallToolRequest) (*mcp.CallToolResult, error)
- func HandleInvokeTool(ctx context.Context, provider ToolProvider, req *mcp.CallToolRequest) (*mcp.CallToolResult, error)
- func HandleListTool(ctx context.Context, provider ToolProvider, req *mcp.CallToolRequest) (*mcp.CallToolResult, error)
- func InvokeTool(ctx context.Context, provider ToolProvider, name string, ...) (*mcp.CallToolResult, error)
- func TruncateDescription(s string, maxWords int) string
- type BuiltinToolRegistry
- type ExecError
- type ExecResult
- type InspectResult
- type ListOptions
- type ListResult
- type ListToolResult
- type ManagerAdapter
- type ToolProvider
Constants ¶
This section is empty.
Variables ¶
var ExecDescription string
var InspectDescription string
var InvokeDescription string
var ListDescription string
Functions ¶
func FormatInspectResultAsJSDoc ¶ added in v0.1.1
func FormatInspectResultAsJSDoc(result *InspectResult) string
FormatInspectResultAsJSDoc formats the inspect result as a JSDoc function stub
func FormatListResultAsText ¶ added in v0.1.1
func FormatListResultAsText(tools []ListToolResult, total int) string
FormatListResultAsText formats the list result as simple text (name: description)
func HandleExecuteTool ¶
func HandleExecuteTool(ctx context.Context, logger *slog.Logger, manager *client.Manager, req *mcp.CallToolRequest) (*mcp.CallToolResult, error)
HandleExecuteTool implements the execute built-in tool (MCP server handler)
func HandleInspectTool ¶
func HandleInspectTool(ctx context.Context, provider ToolProvider, req *mcp.CallToolRequest) (*mcp.CallToolResult, error)
HandleInspectTool handles the inspect tool call (MCP server handler)
func HandleInvokeTool ¶
func HandleInvokeTool(ctx context.Context, provider ToolProvider, req *mcp.CallToolRequest) (*mcp.CallToolResult, error)
HandleInvokeTool handles the invoke tool call (MCP server handler)
func HandleListTool ¶
func HandleListTool(ctx context.Context, provider ToolProvider, req *mcp.CallToolRequest) (*mcp.CallToolResult, error)
HandleListTool handles the list tool call (MCP server handler)
func InvokeTool ¶
func InvokeTool(ctx context.Context, provider ToolProvider, name string, params json.RawMessage, mapper *toolname.Mapper) (*mcp.CallToolResult, error)
InvokeTool is the shared core function for invoking a tool. Used by both CLI and MCP server handlers. The name parameter can be either JS name (camelCase) or original name (serverID__toolName).
func TruncateDescription ¶ added in v0.1.1
TruncateDescription truncates a description to a maximum number of words
Types ¶
type BuiltinToolRegistry ¶
type BuiltinToolRegistry struct {
// contains filtered or unexported fields
}
BuiltinToolRegistry manages built-in tools
func NewBuiltinToolRegistry ¶
func NewBuiltinToolRegistry(logger *slog.Logger) *BuiltinToolRegistry
NewBuiltinToolRegistry creates a new registry
func (*BuiltinToolRegistry) GetAllTools ¶
func (r *BuiltinToolRegistry) GetAllTools() map[string]config.BuiltinTool
GetAllTools returns all registered tools
func (*BuiltinToolRegistry) GetTool ¶
func (r *BuiltinToolRegistry) GetTool(name string) (config.BuiltinTool, bool)
GetTool retrieves a tool from the registry
func (*BuiltinToolRegistry) RegisterTool ¶
func (r *BuiltinToolRegistry) RegisterTool(tool config.BuiltinTool)
RegisterTool adds a tool to the registry
type ExecResult ¶
type ExecResult struct {
Result any `json:"result"`
Logs []js.LogEntry `json:"logs"`
Error *ExecError `json:"error,omitempty"`
}
ExecResult represents the result from executing JavaScript code
func ExecuteCode ¶
func ExecuteCode(ctx context.Context, logger *slog.Logger, caller js.ToolCaller, code string) (*ExecResult, error)
ExecuteCode executes JavaScript code using the provided ToolCaller. This is the shared implementation used by both CLI and MCP tool handler.
type InspectResult ¶
type InspectResult struct {
Name string `json:"name"`
Description string `json:"description"`
Server string `json:"server,omitempty"`
InputSchema map[string]any `json:"inputSchema,omitempty"`
}
InspectResult represents the result of inspecting a tool
func InspectTool ¶
func InspectTool(ctx context.Context, provider ToolProvider, name string, mapper *toolname.Mapper) (*InspectResult, error)
InspectTool is the shared core function for inspecting a tool. Used by both CLI and MCP server handlers. The name parameter can be either JS name (camelCase) or original name (serverID__toolName).
type ListOptions ¶
type ListOptions struct {
Server string // Optional: filter by server name
Query string // Optional: comma-separated keywords for search
}
ListOptions contains options for listing tools
type ListResult ¶
type ListResult struct {
Tools []*mcp.Tool `json:"-"` // Internal: original tools
Total int `json:"total"`
}
ListResult represents the result of listing tools
func ListTools ¶
func ListTools(ctx context.Context, provider ToolProvider, opts ListOptions) (*ListResult, error)
ListTools is the shared core function for listing tools. Used by both CLI and MCP server handlers.
type ListToolResult ¶
type ListToolResult struct {
Name string `json:"name"`
Description string `json:"description"`
Server string `json:"server,omitempty"`
InputSchema map[string]any `json:"inputSchema,omitempty"`
}
ListToolResult represents a tool in the list result
func FormatListResult ¶ added in v0.1.1
func FormatListResult(result *ListResult, mapper *toolname.Mapper) []ListToolResult
FormatListResult formats the list result with JS names for output. Used by both CLI and MCP server handlers for consistent output.
type ManagerAdapter ¶
type ManagerAdapter struct {
// contains filtered or unexported fields
}
ManagerAdapter adapts client.Manager to implement ToolProvider interface. Used by MCP server handlers to call tools via the shared core functions.
func NewManagerAdapter ¶
func NewManagerAdapter(manager *client.Manager) *ManagerAdapter
NewManagerAdapter creates a new ManagerAdapter
func (*ManagerAdapter) CallTool ¶
func (a *ManagerAdapter) CallTool(ctx context.Context, name string, params json.RawMessage) (*mcp.CallToolResult, error)
CallTool invokes a tool by namespaced name (serverID__toolName)
type ToolProvider ¶
type ToolProvider interface {
// ListTools returns all available tools
ListTools(ctx context.Context) ([]*mcp.Tool, error)
// GetTool returns a specific tool by name
GetTool(ctx context.Context, name string) (*mcp.Tool, error)
// CallTool invokes a tool with the given parameters
CallTool(ctx context.Context, name string, params json.RawMessage) (*mcp.CallToolResult, error)
}
ToolProvider is the common interface for tool operations. Both CLI clients and MCP server's client.Manager implement this interface.