Skip to main content
Glama

Kali Linux MCP Server

by pellax
test_syntax.py•3.33 kB
#!/usr/bin/env python3 """ Syntax and structure test for the Kali MCP Server Tests the code without requiring external dependencies """ import ast import sys from pathlib import Path def test_python_syntax(file_path): """Test if Python file has valid syntax""" try: with open(file_path, 'r') as f: content = f.read() # Parse the AST to check syntax ast.parse(content) return True, "Valid Python syntax" except SyntaxError as e: return False, f"Syntax error: {e}" except Exception as e: return False, f"Error: {e}" def test_imports(file_path): """Test which imports are available""" available_imports = [] missing_imports = [] standard_libs = ['asyncio', 'json', 'logging', 'os', 're', 'subprocess', 'sys', 'pathlib', 'typing'] third_party = ['fastmcp', 'pydantic'] for lib in standard_libs: try: __import__(lib) available_imports.append(lib) except ImportError: missing_imports.append(lib) for lib in third_party: try: __import__(lib) available_imports.append(lib) except ImportError: missing_imports.append(lib) return available_imports, missing_imports def count_tools_in_file(file_path): """Count @mcp.tool() decorators in the file""" try: with open(file_path, 'r') as f: content = f.read() # Count @mcp.tool() decorators tool_count = content.count('@mcp.tool()') # Extract function names import re pattern = r'@mcp\.tool\(\)\s*(?:async\s+)?def\s+(\w+)' tools = re.findall(pattern, content, re.MULTILINE) return tool_count, tools except Exception as e: return 0, [] def main(): """Run all tests""" server_file = Path(__file__).parent / 'kali_mcp_server' / 'server.py' print("šŸ” Testing Kali MCP Server") print("=" * 50) # Test syntax print("1. Testing Python syntax...") syntax_ok, syntax_msg = test_python_syntax(server_file) print(f" {'āœ“' if syntax_ok else 'āœ—'} {syntax_msg}") if not syntax_ok: sys.exit(1) # Test imports print("\n2. Testing imports...") available, missing = test_imports(server_file) print(f" āœ“ Available: {', '.join(available)}") if missing: print(f" ⚠ Missing: {', '.join(missing)}") # Count tools print("\n3. Analyzing MCP tools...") tool_count, tools = count_tools_in_file(server_file) print(f" āœ“ Found {tool_count} MCP tools:") for tool in tools: print(f" - {tool}") # Test file structure print("\n4. Testing file structure...") required_files = [ 'requirements.txt', 'pyproject.toml', 'setup_capabilities.sh', 'install.sh', 'run_server.py', '.env.example', 'README.md' ] for file in required_files: if (Path(__file__).parent / file).exists(): print(f" āœ“ {file}") else: print(f" āœ— {file} (missing)") print("\n" + "=" * 50) print("āœ“ Testing complete!") if missing: print(f"\nšŸ“¦ To install missing dependencies:") print(f" pip install {' '.join(missing)}") if __name__ == "__main__": main()

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pellax/kaliMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server