refactor(tools): Audit and cleanup mcp_client.py and shell_runner.py
This commit is contained in:
+9
-2
@@ -1,4 +1,11 @@
|
||||
# shell_runner.py
|
||||
"""
|
||||
Shell Runner - Execution engine for PowerShell scripts.
|
||||
|
||||
This module provides utilities to run PowerShell scripts in a subprocess,
|
||||
configuring the environment via mcp_env.toml. It handles timeouts,
|
||||
logging, and optional QA/patch callbacks for error recovery.
|
||||
"""
|
||||
import os
|
||||
import subprocess
|
||||
import shutil
|
||||
@@ -14,7 +21,7 @@ TIMEOUT_SECONDS: int = 60
|
||||
_ENV_CONFIG: dict = {}
|
||||
|
||||
def _load_env_config() -> dict:
|
||||
"""Load mcp_env.toml from project root (sibling of this file or parent dir)."""
|
||||
"""Load mcp_env.toml from project root or environment variable."""
|
||||
env_path = os.environ.get("SLOP_MCP_ENV")
|
||||
if env_path and Path(env_path).exists():
|
||||
with open(env_path, "rb") as f:
|
||||
@@ -30,7 +37,7 @@ def _load_env_config() -> dict:
|
||||
return {}
|
||||
|
||||
def _build_subprocess_env() -> dict[str, str]:
|
||||
"""Build env dict for subprocess: current env + mcp_env.toml overrides."""
|
||||
"""Build environment dictionary for subprocess with overrides from mcp_env.toml."""
|
||||
global _ENV_CONFIG
|
||||
if not _ENV_CONFIG:
|
||||
_ENV_CONFIG = _load_env_config()
|
||||
|
||||
Reference in New Issue
Block a user