Test basic MCP CLI functionality.
()
| 123 | |
| 124 | |
| 125 | def test_basic_functionality(): |
| 126 | """Test basic MCP CLI functionality.""" |
| 127 | print("\n4. Basic Functionality Test") |
| 128 | print("-" * 28) |
| 129 | |
| 130 | # Test help command |
| 131 | try: |
| 132 | result = subprocess.run( |
| 133 | [sys.executable, "-m", "mcp_cli", "--help"], |
| 134 | capture_output=True, |
| 135 | text=True, |
| 136 | timeout=10, |
| 137 | ) |
| 138 | if result.returncode == 0: |
| 139 | print(" ✅ mcp-cli --help works") |
| 140 | else: |
| 141 | print(f" ❌ mcp-cli --help failed: {result.stderr}") |
| 142 | return False |
| 143 | except Exception as e: |
| 144 | print(f" ❌ Cannot run mcp-cli help: {e}") |
| 145 | return False |
| 146 | |
| 147 | # Test tools list with a simple server |
| 148 | try: |
| 149 | env = os.environ.copy() |
| 150 | env["MCP_TOOL_TIMEOUT"] = "30" |
| 151 | |
| 152 | result = subprocess.run( |
| 153 | [sys.executable, "-m", "mcp_cli", "tools", "list", "--server", "sqlite"], |
| 154 | capture_output=True, |
| 155 | text=True, |
| 156 | timeout=15, |
| 157 | env=env, |
| 158 | ) |
| 159 | if result.returncode == 0: |
| 160 | print(" ✅ tools list works with sqlite") |
| 161 | if "tool" in result.stdout.lower(): |
| 162 | print(" ✅ Tools are listed correctly") |
| 163 | else: |
| 164 | print(f" ⚠️ tools list failed: {result.stderr}") |
| 165 | except Exception as e: |
| 166 | print(f" ⚠️ Cannot test tools list: {e}") |
| 167 | |
| 168 | return True |
| 169 | |
| 170 | |
| 171 | def check_environment_variables(): |