Documentation
¶
Index ¶
- func RegisterCommonTools(s *server.MCPServer)
- func RegisterDateTimeTools(s *server.MCPServer)
- func RunCommand(command string, args []string) (string, error)
- func RunCommandWithContext(ctx context.Context, command string, args []string) (string, error)
- func WithShellExecutor(ctx context.Context, executor ShellExecutor) context.Context
- type DefaultShellExecutor
- type MockCommandCall
- type MockCommandResult
- type MockShellExecutor
- func (m *MockShellExecutor) AddCommand(command string, args []string, output []byte, err error)
- func (m *MockShellExecutor) AddCommandString(command string, args []string, output string, err error)
- func (m *MockShellExecutor) AddPartialMatcher(command string, args []string, output []byte, err error)
- func (m *MockShellExecutor) AddPartialMatcherString(command string, args []string, output string, err error)
- func (m *MockShellExecutor) Exec(ctx context.Context, command string, args ...string) ([]byte, error)
- func (m *MockShellExecutor) GetCallLog() []MockCommandCall
- func (m *MockShellExecutor) Reset()
- type PartialMatcher
- type ShellExecutor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterCommonTools ¶
func RegisterDateTimeTools ¶
func RunCommand ¶
RunCommand executes a command and returns output or error with OTEL tracing
func RunCommandWithContext ¶
RunCommandWithContext executes a command with context and returns output or error with OTEL tracing
func WithShellExecutor ¶
func WithShellExecutor(ctx context.Context, executor ShellExecutor) context.Context
WithShellExecutor returns a context with the given shell executor
Types ¶
type DefaultShellExecutor ¶
type DefaultShellExecutor struct{}
DefaultShellExecutor implements ShellExecutor using os/exec
type MockCommandCall ¶
MockCommandCall represents a logged command execution
type MockCommandResult ¶
MockCommandResult represents the expected result of a mocked command
type MockShellExecutor ¶
type MockShellExecutor struct {
// Commands maps command+args to expected output and error
Commands map[string]MockCommandResult
// CallLog keeps track of all executed commands for verification
CallLog []MockCommandCall
// PartialMatchers allows partial matching for dynamic arguments
PartialMatchers []PartialMatcher
}
MockShellExecutor implements ShellExecutor for testing
func NewMockShellExecutor ¶
func NewMockShellExecutor() *MockShellExecutor
NewMockShellExecutor creates a new mock shell executor for testing
func (*MockShellExecutor) AddCommand ¶
func (m *MockShellExecutor) AddCommand(command string, args []string, output []byte, err error)
AddCommand adds a command mock
func (*MockShellExecutor) AddCommandString ¶
func (m *MockShellExecutor) AddCommandString(command string, args []string, output string, err error)
AddCommandString is a convenience method for adding string output
func (*MockShellExecutor) AddPartialMatcher ¶
func (m *MockShellExecutor) AddPartialMatcher(command string, args []string, output []byte, err error)
AddPartialMatcher adds a partial matcher for dynamic arguments
func (*MockShellExecutor) AddPartialMatcherString ¶
func (m *MockShellExecutor) AddPartialMatcherString(command string, args []string, output string, err error)
AddPartialMatcherString is a convenience method for adding string output with partial matching
func (*MockShellExecutor) Exec ¶
func (m *MockShellExecutor) Exec(ctx context.Context, command string, args ...string) ([]byte, error)
Exec executes a mocked command
func (*MockShellExecutor) GetCallLog ¶
func (m *MockShellExecutor) GetCallLog() []MockCommandCall
GetCallLog returns the log of all command calls
type PartialMatcher ¶
type PartialMatcher struct {
Command string
Args []string // Use "*" for wildcard matching
Result MockCommandResult
}
PartialMatcher represents a partial command matcher for dynamic arguments
type ShellExecutor ¶
type ShellExecutor interface {
Exec(ctx context.Context, command string, args ...string) (output []byte, err error)
}
ShellExecutor defines the interface for executing shell commands
func GetShellExecutor ¶
func GetShellExecutor(ctx context.Context) ShellExecutor
GetShellExecutor retrieves the shell executor from context, or returns default