refactor(tools): Audit and cleanup mcp_client.py and shell_runner.py

This commit is contained in:
2026-05-02 13:06:48 -04:00
parent 29dd6ec36d
commit 6dd9b67d5c
2 changed files with 19 additions and 4 deletions
+9 -2
View File
@@ -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()