Documentation
¶
Index ¶
Constants ¶
View Source
const ( // DefaultTimeout is the default timeout for JS execution DefaultTimeout = 15 * time.Second // MaxScriptSize is the maximum script size in bytes MaxScriptSize = 100 * 1024 // 100KB // MaxLogEntries is the maximum number of log entries allowed MaxLogEntries = 1000 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Timeout time.Duration
AllowedTools map[string][]string // map[serverID][]toolNames, nil = allow all
}
Config holds runtime configuration
type LogEntry ¶
type LogEntry struct {
Level string `json:"level"`
Message string `json:"message"`
Fields map[string]any `json:"fields,omitempty"`
}
LogEntry represents a log entry from mcp.log()
type ManagerCaller ¶
type ManagerCaller struct {
// contains filtered or unexported fields
}
ManagerCaller adapts a SessionGetter (like client.Manager) to the ToolCaller interface
func NewManagerCaller ¶
func NewManagerCaller(getter SessionGetter) *ManagerCaller
NewManagerCaller creates a new ManagerCaller from a SessionGetter
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime represents a JavaScript runtime for executing tool scripts
func NewRuntime ¶
func NewRuntime(logger *slog.Logger, caller ToolCaller, cfg *Config) *Runtime
NewRuntime creates a new JavaScript runtime
type RuntimeError ¶
RuntimeError represents a structured runtime error
func (*RuntimeError) Error ¶
func (e *RuntimeError) Error() string
Error implements the error interface
type SessionGetter ¶
type SessionGetter interface {
GetClient(serverID string) (*mcp.ClientSession, error)
}
SessionGetter abstracts getting a client session by server ID (implemented by client.Manager)
type ToolCaller ¶
type ToolCaller interface {
// CallTool calls a tool with the given serverID, toolName, and parameters
// For single-server clients, serverID can be ignored or used as a default
CallTool(ctx context.Context, serverID, toolName string, params map[string]any) (*mcp.CallToolResult, error)
}
ToolCaller abstracts tool calling for different client types
Click to show internal directories.
Click to hide internal directories.