Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions shell/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,6 @@ type ExecuteCommandOutput struct {
Error string `json:"error,omitempty" jsonschema:"error message if execution failed"`
}

// Interactive flags that commonly cause commands to hang
var interactiveFlags = []string{
"-i", "--interactive", "--tty", "-t",
"vim", "vi", "nano", "emacs", "less", "more", "top", "htop",
"ftp", "sftp", "ssh", "ping", "tail -f", "tail -F",
}

// isInteractiveCommand checks if the script contains interactive commands
func isInteractiveCommand(script string) bool {
scriptLower := strings.ToLower(script)
for _, flag := range interactiveFlags {
if strings.Contains(scriptLower, flag) {
return true
}
}
return false
}

// getShellCommand returns the shell command to use, defaulting to "sh" if not set
func getShellCommand() string {
shellCmd := os.Getenv("SHELL_CMD")
Expand Down Expand Up @@ -89,12 +71,6 @@ func ExecuteCommand(ctx context.Context, req *mcp.CallToolRequest, input Execute
timeout = getTimeout()
}

// Warn about interactive commands (but still attempt execution with proper safeguards)
warningMsg := ""
if isInteractiveCommand(input.Script) {
warningMsg = "Warning: Command appears to be interactive and may hang. "
}

// Create a context with timeout
cmdCtx, cancel := context.WithTimeout(ctx, time.Duration(timeout)*time.Second)
defer cancel()
Expand Down Expand Up @@ -169,11 +145,6 @@ func ExecuteCommand(ctx context.Context, req *mcp.CallToolRequest, input Execute
}
}

// Add warning to stderr if interactive command detected
if warningMsg != "" {
stderrBuf.WriteString("\n" + warningMsg)
}

output := ExecuteCommandOutput{
Script: input.Script,
Stdout: stdoutBuf.String(),
Expand Down
Loading