Test an mcp-cli command and return success status and output.
(command_args, timeout=30)
| 10 | |
| 11 | |
| 12 | def test_mcp_cli_command(command_args, timeout=30): |
| 13 | """Test an mcp-cli command and return success status and output.""" |
| 14 | try: |
| 15 | # Set up environment |
| 16 | env = os.environ.copy() |
| 17 | env["MCP_TOOL_TIMEOUT"] = str(timeout) |
| 18 | env["CHUK_LOG_LEVEL"] = "WARNING" # Reduce noise |
| 19 | |
| 20 | # Run the command |
| 21 | cmd = [sys.executable, "-m", "mcp_cli"] + command_args |
| 22 | print(f"🧪 Running: {' '.join(cmd)}") |
| 23 | |
| 24 | result = subprocess.run( |
| 25 | cmd, capture_output=True, text=True, timeout=timeout, env=env |
| 26 | ) |
| 27 | |
| 28 | success = result.returncode == 0 |
| 29 | return success, result.stdout, result.stderr |
| 30 | |
| 31 | except subprocess.TimeoutExpired: |
| 32 | return False, "", f"Command timed out after {timeout}s" |
| 33 | except Exception as e: |
| 34 | return False, "", f"Command failed: {e}" |
| 35 | |
| 36 | |
| 37 | def check_config_file(config_file="server_config.json"): |
no test coverage detected