MCPcopy Create free account
hub / github.com/bcefghj/miniClaudeCode / execute

Method execute

miniclaudecode/tools/bash_tool.py:60–85  ·  view source on GitHub ↗
(self, params: dict[str, Any])

Source from the content-addressed store, hash-verified

58 return None
59
60 def execute(self, params: dict[str, Any]) -> ToolResult:
61 command = params.get("command", "")
62 if not command.strip():
63 return ToolResult(output="Error: empty command", is_error=True)
64 try:
65 result = subprocess.run(
66 command,
67 shell=True,
68 capture_output=True,
69 text=True,
70 timeout=120,
71 cwd=None,
72 )
73 output_parts = []
74 if result.stdout:
75 output_parts.append(result.stdout)
76 if result.stderr:
77 output_parts.append(f"STDERR:\n{result.stderr}")
78 output = "\n".join(output_parts) or "(no output)"
79 if len(output) > 50_000:
80 output = output[:50_000] + "\n... (truncated)"
81 return ToolResult(output=output, is_error=result.returncode != 0)
82 except subprocess.TimeoutExpired:
83 return ToolResult(output="Error: command timed out after 120s", is_error=True)
84 except Exception as exc:
85 return ToolResult(output=f"Error: {exc}", is_error=True)

Callers

nothing calls this directly

Calls 3

ToolResultClass · 0.85
getMethod · 0.80
runMethod · 0.80

Tested by

no test coverage detected