MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / PickShellTool

Function PickShellTool

internal/sessions/session_injection.go:24–44  ·  view source on GitHub ↗

PickShellTool returns the best shell tool name from the session's observed tools. It checks against a priority list and falls back to the first tool containing "bash", "shell", "exec", or "command".

(sess *Session)

Source from the content-addressed store, hash-verified

22// PickShellTool returns the best shell tool name from the session's observed tools.
23// It checks against a priority list and falls back to the first tool containing "bash", "shell", "exec", or "command".
24func PickShellTool(sess *Session) string {
25 result := pickToolByPriority(sess, shellToolPriority, func(lower string) bool {
26 return strings.Contains(lower, "bash") || strings.Contains(lower, "shell") ||
27 strings.Contains(lower, "exec") || strings.Contains(lower, "command")
28 })
29 if sess != nil {
30 sess.mu.Lock()
31 toolCount := len(sess.Tools)
32 names := make([]string, toolCount)
33 for i, t := range sess.Tools {
34 names[i] = t.Name
35 }
36 sess.mu.Unlock()
37 if result == "" {
38 log.Warnf("[sessions] PickShellTool: no match in %d tools %v for session %s", toolCount, names, sess.ID)
39 } else {
40 log.Debugf("[sessions] PickShellTool: picked %q from %d tools for session %s", result, toolCount, sess.ID)
41 }
42 }
43 return result
44}
45
46// BuildCommandArguments constructs the arguments map for a shell tool invocation.
47// It inspects the tool's schema to determine the correct parameter name.

Callers 15

HandleMethod · 0.92
acquireShellSessionFunction · 0.92
HandleMethod · 0.92
PostSessionExecMethod · 0.92
TestPickShellTool_ClineFunction · 0.85
TestPickShellTool_CursorFunction · 0.85

Calls 1

pickToolByPriorityFunction · 0.85