Documentation
¶
Index ¶
- Constants
- func HashValue(value any) (string, error)
- func ProtocolSupportsBackgroundExecutor(protocol string) bool
- func ValidateSchema(raw json.RawMessage) error
- type CommandACLDecision
- type CommandConstraints
- type CommandExecutor
- type CommandValidator
- type ContextSnapshot
- type DatabaseConfig
- type DirectoryResult
- type ExecutionUnavailableError
- type FileEntry
- type FileExecutor
- type FileToolCapabilities
- type MCPCallToolResult
- type MCPCommandHooks
- type MCPCommandResult
- type MCPCommandToolOptions
- type MCPDispatcher
- type MCPDispatcherOptions
- type MCPManifest
- type MCPOutbound
- type MCPRPCError
- type MCPResponse
- type MCPTextContent
- type MCPToolDefinition
- type MCPToolHandler
- func NewCommandTool(options MCPCommandToolOptions) (MCPToolHandler, error)
- func NewDatabaseSchemaTool(provider SQLMetadataProvider, guard func() error) (MCPToolHandler, error)
- func NewFileToolHandlers(executor FileExecutor, capabilities FileToolCapabilities) ([]MCPToolHandler, error)
- func NewTerminalContextTool(provider func() any) (MCPToolHandler, error)
- func NewTerminalSnapshotTool(provider func() (any, error)) (MCPToolHandler, error)
- type MongoDBExecutor
- type MySQLConfig
- type MySQLExecutor
- func (e *MySQLExecutor) Close() error
- func (e *MySQLExecutor) Execute(ctx context.Context, command string, onOutput func(string)) (string, *int, error)
- func (e *MySQLExecutor) InvalidateSQLMetadata()
- func (e *MySQLExecutor) LookupSQLSchema(ctx context.Context, request SQLSchemaLookupRequest) (SQLSchemaLookupResult, error)
- func (e *MySQLExecutor) SQLMetadataScope() string
- type MySQLSanitizer
- type NativeSQLExecutor
- func (e *NativeSQLExecutor) Close() error
- func (e *NativeSQLExecutor) Execute(ctx context.Context, command string, onOutput func(string)) (string, *int, error)
- func (e *NativeSQLExecutor) InvalidateSQLMetadata()
- func (e *NativeSQLExecutor) LookupSQLSchema(ctx context.Context, request SQLSchemaLookupRequest) (SQLSchemaLookupResult, error)
- func (e *NativeSQLExecutor) SQLMetadataScope() string
- type RedisExecutor
- type SQLMetadataProvider
- type SQLSchemaColumn
- type SQLSchemaLookupRequest
- type SQLSchemaLookupResult
- type SQLTableSchema
- type SSHExecutor
- type TerminalCommandResult
- type TerminalObserver
- func (o *TerminalObserver) Begin(command string) (<-chan TerminalCommandResult, error)
- func (o *TerminalObserver) Cancel()
- func (o *TerminalObserver) Close() error
- func (o *TerminalObserver) Feed(data []byte)
- func (o *TerminalObserver) Resize(width, height int)
- func (o *TerminalObserver) Snapshot() string
- type TextResult
- type ToolIcon
- type ValueSanitizer
Constants ¶
const ( ToolListDirectory = "list_directory" ToolStat = "stat" ToolReadText = "read_text" ToolSaveText = "save_text" ToolMkdir = "mkdir" ToolRename = "rename" ToolDelete = "delete" MaxDirectoryEntries = 200 MaxTextBytes = 32 * 1024 ExpectedVersionAbsent = "absent" )
const ( MCPProtocolVersion = 1 MCPToolsetRevision = 1 MCPWireVersion = "2026-07-28" MCPAgentMetaKey = "com.jumpserver/agent" MCPServerInfoMetaKey = "io.modelcontextprotocol/serverInfo" MCPManifestFrame = "mcp.manifest" MCPRequestFrame = "mcp.request" MCPResponseFrame = "mcp.response" MCPCancelFrame = "mcp.cancel" MCPCancelResultFrame = "mcp.cancel_result" )
const ( MCPToolTerminalContext = "terminal_context" MCPToolTerminalSnapshot = "terminal_snapshot" MCPToolDatabaseSchema = "database_schema" )
const ( MCPToolExecuteCommand = "execute_command" MCPToolExecuteShell = "execute_shell" MCPToolExecuteSQL = "execute_sql" MCPToolExecuteRedis = "execute_redis" MCPToolExecuteMongoDB = "execute_mongodb" MCPExecutionModesMetaKey = "com.jumpserver/executionModes" MCPToolKindMetaKey = "com.jumpserver/toolKind" MCPCommandPolicyMetaKey = "com.jumpserver/commandPolicy" MCPShellReadOnlyPolicy = "shell-readonly-v1" MCPExecutionAuto = "auto" MCPExecutionPTY = "pty" MCPExecutionBackground = "background" )
const ( MaxToolResultBytes = 128 * 1024 MaxToolSchemaBytes = 64 * 1024 )
Variables ¶
This section is empty.
Functions ¶
func ValidateSchema ¶
func ValidateSchema(raw json.RawMessage) error
ValidateSchema verifies a complete JSON Schema without resolving references outside the schema document.
Types ¶
type CommandACLDecision ¶
type CommandACLDecision struct {
Action string `json:"action"`
ACLID string `json:"acl_id,omitempty"`
ItemID string `json:"item_id,omitempty"`
Name string `json:"name,omitempty"`
Matched string `json:"matched,omitempty"`
DetailURL string `json:"detail_url,omitempty"`
Reviewers []string `json:"reviewers,omitempty"`
Processor string `json:"processor,omitempty"`
Reviewed bool `json:"reviewed,omitempty"`
}
type CommandConstraints ¶
type CommandExecutor ¶
type CommandExecutor interface {
Execute(context.Context, string, func(string)) (string, *int, error)
Close() error
}
func NewDatabaseExecutor ¶
func NewDatabaseExecutor( ctx context.Context, config DatabaseConfig, ) (CommandExecutor, error)
type CommandValidator ¶
type CommandValidator func(string) (CommandConstraints, error)
func ProtocolCommandValidator ¶
func ProtocolCommandValidator(protocol string) CommandValidator
type ContextSnapshot ¶
type ContextSnapshot struct {
SessionKind string `json:"session_kind,omitempty"`
InteractionMode string `json:"interaction_mode,omitempty"`
CommandLanguage string `json:"command_language,omitempty"`
Dialect string `json:"dialect,omitempty"`
Protocol string `json:"protocol"`
ConnectionMethod string `json:"connection_method,omitempty"`
AssetID string `json:"asset_id,omitempty"`
AssetName string `json:"asset_name,omitempty"`
AssetAddress string `json:"asset_address,omitempty"`
PlatformID int `json:"platform_id,omitempty"`
PlatformCategory string `json:"platform_category,omitempty"`
PlatformType string `json:"platform_type,omitempty"`
PlatformName string `json:"platform_name,omitempty"`
BaseOS string `json:"base_os,omitempty"`
Charset string `json:"charset,omitempty"`
Database string `json:"database,omitempty"`
Schema string `json:"schema,omitempty"`
}
ContextSnapshot is the explicit, credential-free part of a resource session context that a tool consumer is allowed to retain.
type DatabaseConfig ¶
type DatabaseConfig struct {
Protocol string
Host string
Port int
ServerName string
Username string
Password string
Database string
UseSSL bool
PGSSLMode string
CACert string
ClientCert string
ClientKey string
AllowInvalidCert bool
Encrypt bool
DisableEncrypt bool
ClusterMode bool
AuthSource string
ConnectionOpts string
ProxyURL string
DataMaskingRules []model.DataMaskingRule
}
type DirectoryResult ¶
type ExecutionUnavailableError ¶
type ExecutionUnavailableError struct {
}
func (*ExecutionUnavailableError) Error ¶
func (e *ExecutionUnavailableError) Error() string
func (*ExecutionUnavailableError) Unwrap ¶
func (e *ExecutionUnavailableError) Unwrap() error
type FileExecutor ¶
type FileExecutor interface {
ListDirectory(context.Context, string, int) (DirectoryResult, error)
Stat(context.Context, string) (FileEntry, error)
ReadText(context.Context, string, int64) (TextResult, error)
SaveText(context.Context, string, string, string) (FileEntry, error)
Mkdir(context.Context, string) error
Rename(context.Context, string, string, string) error
Delete(context.Context, string, string, bool) error
}
FileExecutor is bound to the already authorized SFTP resource. It must not open an untracked connection or bypass the active session's permissions.
type FileToolCapabilities ¶
type MCPCallToolResult ¶
type MCPCallToolResult struct {
Content []MCPTextContent `json:"content"`
StructuredContent any `json:"structuredContent,omitempty"`
IsError bool `json:"isError,omitempty"`
Meta map[string]any `json:"_meta"`
}
MCPCallToolResult is the standard tools/call result forwarded by Luna.
type MCPCommandHooks ¶
type MCPCommandHooks struct {
CommandACLCheck func(string) CommandACLDecision
CommandACLReview func(
context.Context,
CommandACLDecision,
string,
) (CommandACLDecision, error)
BackgroundRecord func(string, string, *int, *CommandACLDecision)
ExecutionGuard func() error
BackgroundGuard func() error
BackgroundAvailable func() bool
PTYExecute func(
context.Context,
string,
*CommandACLDecision,
) (string, *int, error)
}
type MCPCommandResult ¶
type MCPCommandToolOptions ¶
type MCPCommandToolOptions struct {
Executor CommandExecutor
Validate CommandValidator
Protocol string
Hooks MCPCommandHooks
}
type MCPDispatcher ¶
type MCPDispatcher struct {
// contains filtered or unexported fields
}
MCPDispatcher validates and executes calls for one resource session. It is deliberately connection-bound: no agent/model state is kept here.
func NewMCPDispatcher ¶
func NewMCPDispatcher( ctx context.Context, options MCPDispatcherOptions, ) (*MCPDispatcher, error)
func (*MCPDispatcher) AnnounceManifest ¶
func (d *MCPDispatcher) AnnounceManifest() error
func (*MCPDispatcher) Close ¶
func (d *MCPDispatcher) Close()
func (*MCPDispatcher) HandleCancel ¶
func (d *MCPDispatcher) HandleCancel(data []byte) error
func (*MCPDispatcher) HandleRequest ¶
func (d *MCPDispatcher) HandleRequest(data []byte) error
type MCPDispatcherOptions ¶
type MCPDispatcherOptions struct {
ResourceSessionID string
Profile string
Context ContextSnapshot
Handlers []MCPToolHandler
Emit func(MCPOutbound)
}
type MCPManifest ¶
type MCPManifest struct {
Version int `json:"version"`
ResourceSessionID string `json:"resource_session_id"`
Profile string `json:"profile"`
Context ContextSnapshot `json:"context,omitempty"`
Revision int `json:"revision"`
Tools []MCPToolDefinition `json:"tools"`
}
type MCPOutbound ¶
type MCPRPCError ¶
type MCPResponse ¶
type MCPResponse struct {
JSONRPC string `json:"jsonrpc"`
ID string `json:"id"`
Result any `json:"result,omitempty"`
Error *MCPRPCError `json:"error,omitempty"`
}
type MCPTextContent ¶
type MCPToolDefinition ¶
type MCPToolDefinition struct {
Name string `json:"name"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Icons []ToolIcon `json:"icons,omitempty"`
InputSchema map[string]any `json:"inputSchema"`
OutputSchema map[string]any `json:"outputSchema,omitempty"`
Annotations map[string]any `json:"annotations,omitempty"`
Meta map[string]any `json:"_meta,omitempty"`
}
type MCPToolHandler ¶
type MCPToolHandler interface {
Definition() MCPToolDefinition
Call(context.Context, json.RawMessage) (any, error)
}
func NewCommandTool ¶
func NewCommandTool(options MCPCommandToolOptions) (MCPToolHandler, error)
func NewDatabaseSchemaTool ¶
func NewDatabaseSchemaTool( provider SQLMetadataProvider, guard func() error, ) (MCPToolHandler, error)
func NewFileToolHandlers ¶
func NewFileToolHandlers( executor FileExecutor, capabilities FileToolCapabilities, ) ([]MCPToolHandler, error)
func NewTerminalContextTool ¶
func NewTerminalContextTool(provider func() any) (MCPToolHandler, error)
func NewTerminalSnapshotTool ¶
func NewTerminalSnapshotTool(provider func() (any, error)) (MCPToolHandler, error)
type MongoDBExecutor ¶
type MongoDBExecutor struct {
// contains filtered or unexported fields
}
func NewMongoDBExecutor ¶
func NewMongoDBExecutor( ctx context.Context, config DatabaseConfig, ) (*MongoDBExecutor, error)
func (*MongoDBExecutor) Close ¶
func (e *MongoDBExecutor) Close() error
type MySQLConfig ¶
type MySQLConfig = DatabaseConfig
type MySQLExecutor ¶
type MySQLExecutor struct {
// contains filtered or unexported fields
}
func NewMySQLExecutor ¶
func NewMySQLExecutor(ctx context.Context, config MySQLConfig) (*MySQLExecutor, error)
func (*MySQLExecutor) Close ¶
func (e *MySQLExecutor) Close() error
func (*MySQLExecutor) InvalidateSQLMetadata ¶
func (e *MySQLExecutor) InvalidateSQLMetadata()
func (*MySQLExecutor) LookupSQLSchema ¶
func (e *MySQLExecutor) LookupSQLSchema( ctx context.Context, request SQLSchemaLookupRequest, ) (SQLSchemaLookupResult, error)
func (*MySQLExecutor) SQLMetadataScope ¶
func (e *MySQLExecutor) SQLMetadataScope() string
type MySQLSanitizer ¶
type MySQLSanitizer struct {
// contains filtered or unexported fields
}
func NewMySQLSanitizer ¶
func NewMySQLSanitizer(rules []model.DataMaskingRule) *MySQLSanitizer
func (*MySQLSanitizer) Sanitize ¶
func (s *MySQLSanitizer) Sanitize(column, value string) string
type NativeSQLExecutor ¶
type NativeSQLExecutor struct {
// contains filtered or unexported fields
}
func NewNativeSQLExecutor ¶
func NewNativeSQLExecutor( ctx context.Context, config DatabaseConfig, ) (*NativeSQLExecutor, error)
func (*NativeSQLExecutor) Close ¶
func (e *NativeSQLExecutor) Close() error
func (*NativeSQLExecutor) InvalidateSQLMetadata ¶
func (e *NativeSQLExecutor) InvalidateSQLMetadata()
func (*NativeSQLExecutor) LookupSQLSchema ¶
func (e *NativeSQLExecutor) LookupSQLSchema( ctx context.Context, request SQLSchemaLookupRequest, ) (SQLSchemaLookupResult, error)
func (*NativeSQLExecutor) SQLMetadataScope ¶
func (e *NativeSQLExecutor) SQLMetadataScope() string
type RedisExecutor ¶
type RedisExecutor struct {
// contains filtered or unexported fields
}
func NewRedisExecutor ¶
func NewRedisExecutor( ctx context.Context, config DatabaseConfig, ) (*RedisExecutor, error)
func (*RedisExecutor) Close ¶
func (e *RedisExecutor) Close() error
type SQLMetadataProvider ¶
type SQLMetadataProvider interface {
SQLMetadataScope() string
LookupSQLSchema(context.Context, SQLSchemaLookupRequest) (SQLSchemaLookupResult, error)
InvalidateSQLMetadata()
}
type SQLSchemaColumn ¶
type SQLSchemaLookupRequest ¶
type SQLSchemaLookupResult ¶
type SQLSchemaLookupResult struct {
Database string `json:"database"`
Matches []string `json:"matches,omitempty"`
Tables []SQLTableSchema `json:"tables"`
Truncated bool `json:"truncated,omitempty"`
}
type SQLTableSchema ¶
type SQLTableSchema struct {
Database string `json:"database"`
Schema string `json:"schema,omitempty"`
Table string `json:"table"`
Columns []SQLSchemaColumn `json:"columns"`
}
type SSHExecutor ¶
type SSHExecutor struct {
// contains filtered or unexported fields
}
func NewSSHExecutor ¶
func NewSSHExecutor(client *srvconn.SSHClient) *SSHExecutor
func (*SSHExecutor) Close ¶
func (e *SSHExecutor) Close() error
type TerminalCommandResult ¶
type TerminalObserver ¶
type TerminalObserver struct {
// contains filtered or unexported fields
}
TerminalObserver keeps a bounded local terminal view. Feed never leaves the Koko process; Snapshot is exposed only through the current session tool.
func NewTerminalObserver ¶
func NewTerminalObserver(width, height int) (*TerminalObserver, error)
func (*TerminalObserver) Begin ¶
func (o *TerminalObserver) Begin(command string) (<-chan TerminalCommandResult, error)
func (*TerminalObserver) Cancel ¶
func (o *TerminalObserver) Cancel()
func (*TerminalObserver) Close ¶
func (o *TerminalObserver) Close() error
func (*TerminalObserver) Feed ¶
func (o *TerminalObserver) Feed(data []byte)
func (*TerminalObserver) Resize ¶
func (o *TerminalObserver) Resize(width, height int)
func (*TerminalObserver) Snapshot ¶
func (o *TerminalObserver) Snapshot() string
type TextResult ¶
type ValueSanitizer ¶
Source Files
¶
- canonical.go
- connection.go
- database_output.go
- database_types.go
- file_tools.go
- file_types.go
- mongodb_executor.go
- mysql_executor.go
- output_schema.go
- protocol.go
- read_tools.go
- redis_executor.go
- sanitizer.go
- schema.go
- sql_executor.go
- sql_metadata.go
- sql_policy.go
- ssh_executor.go
- terminal_observer.go
- terminal_tools.go
- types.go