MCPcopy Create free account
hub / github.com/IBM/mcp-cli / test_mcp_cli_command

Function test_mcp_cli_command

diagnostics/cli_command_diagnostic.py:12–34  ·  view source on GitHub ↗

Test an mcp-cli command and return success status and output.

(command_args, timeout=30)

Source from the content-addressed store, hash-verified

10
11
12def 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
37def check_config_file(config_file="server_config.json"):

Callers 4

test_basic_commandsFunction · 0.85
test_server_commandsFunction · 0.85
test_provider_commandsFunction · 0.85
test_advanced_commandsFunction · 0.85

Calls 1

runMethod · 0.80

Tested by

no test coverage detected