Documentation
¶
Overview ¶
Package server wires together the security pipeline and registers MCP tools.
Index ¶
- func NewHTTPHandler(core *Core, opts ...ServerOptions) http.Handler
- func NewMCPServer(core *Core, opts ...ServerOptions) *mcp.Server
- func RunStdio(ctx context.Context, core *Core, opts ...ServerOptions) error
- type ConnectInput
- type Core
- func (c *Core) Close(ctx context.Context) error
- func (c *Core) Connect(ctx context.Context, in ConnectInput) (map[string]any, error)
- func (c *Core) Disconnect(ctx context.Context, in DisconnectInput) (map[string]any, error)
- func (c *Core) DownloadFile(ctx context.Context, in DownloadInput) (DownloadResult, error)
- func (c *Core) Execute(ctx context.Context, in ExecuteInput) (output.CommandResult, error)
- func (c *Core) Logger() *slog.Logger
- func (c *Core) Provision(ctx context.Context, in ProvisionInput) (map[string]any, error)
- func (c *Core) Sleep(ctx context.Context, in SleepInput) (map[string]any, error)
- type CoreOption
- type DisconnectInput
- type DownloadInput
- type DownloadResult
- type ExecuteInput
- type Executor
- type ProbeResult
- type ProvisionInput
- type ServerOptions
- type SleepInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHTTPHandler ¶
func NewHTTPHandler(core *Core, opts ...ServerOptions) http.Handler
NewHTTPHandler returns an http.Handler serving MCP over SSE.
func NewMCPServer ¶
func NewMCPServer(core *Core, opts ...ServerOptions) *mcp.Server
Types ¶
type ConnectInput ¶
type ConnectInput struct {
Host string `json:"host" jsonschema:"Hostname or IP address"`
User string `json:"user,omitempty" jsonschema:"SSH username (default root)"`
Port int `json:"port,omitempty" jsonschema:"SSH port (default 22)"`
IdentityFile string `json:"identity_file,omitempty" jsonschema:"Path to SSH identity file"`
}
type Core ¶
type Core struct {
Registry map[string]*manifest.Manifest
Runner Executor
Parse func(string) (*parser.Pipeline, error)
Validate func(*parser.Pipeline, map[string]*manifest.Manifest) error
Reconstruct func(*parser.Pipeline, bool, bool) string
Truncate func(string, string, int, int, ...int) output.CommandResult
DefaultTimeout int
MaxOutputBytes int
MaxDownloadBytes int
DownloadDir string
MaxSleepSeconds int
// contains filtered or unexported fields
}
func (*Core) Close ¶
Close disconnects all SSH sessions and clears internal state. Internal state is always cleared even if the disconnect fails. It is safe to call multiple times.
func (*Core) Disconnect ¶
func (*Core) DownloadFile ¶
func (c *Core) DownloadFile(ctx context.Context, in DownloadInput) (DownloadResult, error)
func (*Core) Execute ¶
func (c *Core) Execute(ctx context.Context, in ExecuteInput) (output.CommandResult, error)
type CoreOption ¶
type CoreOption func(*Core)
func WithDefaultTimeout ¶
func WithDefaultTimeout(seconds int) CoreOption
func WithDownloadDir ¶
func WithDownloadDir(dir string) CoreOption
func WithMaxDownloadBytes ¶
func WithMaxDownloadBytes(bytes int) CoreOption
func WithMaxOutputBytes ¶
func WithMaxOutputBytes(bytes int) CoreOption
func WithMaxSleepSeconds ¶
func WithMaxSleepSeconds(seconds int) CoreOption
type DisconnectInput ¶
type DisconnectInput struct {
Host string `json:"host,omitempty" jsonschema:"Hostname to disconnect; empty disconnects all"`
}
type DownloadInput ¶
type DownloadInput struct {
RemotePath string `json:"remote_path" jsonschema:"Absolute path to file on remote server"`
LocalDir string `json:"local_dir,omitempty" jsonschema:"Local directory to save to (default: /tmp/shellguard-downloads/)"`
Host string `json:"host,omitempty" jsonschema:"Hostname when multiple connections exist"`
}
type DownloadResult ¶
type ExecuteInput ¶
type Executor ¶
type Executor interface {
Connect(ctx context.Context, params ssh.ConnectionParams) error
Execute(ctx context.Context, host, command string, timeout time.Duration) (ssh.ExecResult, error)
ExecuteRaw(ctx context.Context, host, command string, timeout time.Duration) (ssh.ExecResult, error)
SFTPSession(host string) (ssh.SFTPClient, error)
Disconnect(ctx context.Context, host string) error
}
Executor runs commands on remote targets.
type ProbeResult ¶
type ProvisionInput ¶
type ProvisionInput struct {
Host string `json:"host,omitempty" jsonschema:"Hostname to provision. Required when connected to multiple servers."`
}
type ServerOptions ¶
type SleepInput ¶
type SleepInput struct {
Seconds float64 `json:"seconds" jsonschema:"Duration to sleep in seconds"`
}
Click to show internal directories.
Click to hide internal directories.