Skip to main content
Glama

License Scanner MCP Server

by RyanCadby
test_server.py2.92 kB
#!/usr/bin/env python3 """ Test script for the License Scanner MCP Server """ import json import sys from pathlib import Path # Add the current directory to Python path sys.path.insert(0, str(Path(__file__).parent)) from license_scanner import ( scan_project_dependencies, generate_license_report_markdown, get_package_manager_files, parse_package_json, parse_requirements_txt, parse_cargo_toml ) def test_example_project(): """Test the MCP server with the example project.""" project_path = Path("example_project") print("=== Testing License Scanner MCP Server ===\n") # Test 1: List package managers print("1. Testing package manager detection:") package_files = get_package_manager_files(project_path) result = { "project_path": str(project_path), "package_files": [str(f) for f in package_files], "total_files": len(package_files) } print(json.dumps(result, indent=2)) print() # Test 2: Parse individual files print("2. Testing individual file parsing:") # Test package.json package_json_path = project_path / "package.json" if package_json_path.exists(): npm_deps = parse_package_json(package_json_path) print(f"Found {len(npm_deps)} npm dependencies") for dep in npm_deps[:3]: # Show first 3 print(f" - {dep['name']} {dep['version']}") print() # Test requirements.txt requirements_path = project_path / "requirements.txt" if requirements_path.exists(): pip_deps = parse_requirements_txt(requirements_path) print(f"Found {len(pip_deps)} pip dependencies") for dep in pip_deps[:3]: # Show first 3 print(f" - {dep['name']} {dep['version']}") print() # Test Cargo.toml cargo_path = project_path / "Cargo.toml" if cargo_path.exists(): cargo_deps = parse_cargo_toml(cargo_path) print(f"Found {len(cargo_deps)} cargo dependencies") for dep in cargo_deps[:3]: # Show first 3 print(f" - {dep['name']} {dep['version']}") print() # Test 3: Full dependency scan print("3. Testing full dependency scan:") result = scan_project_dependencies(str(project_path)) print(json.dumps(result, indent=2)) print() # Test 4: Generate markdown report print("4. Testing generate_license_report (markdown):") markdown = generate_license_report_markdown(result) print(markdown[:800] + "..." if len(markdown) > 800 else markdown) print() # Test 5: Save report to file print("5. Saving license report to file:") output_file = "example_license_report.md" with open(output_file, 'w') as f: f.write(markdown) print(f"Report saved to: {output_file}") print("\n=== Test completed successfully! ===") if __name__ == "__main__": test_example_project()

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/RyanCadby/mcp-license-scanner'

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