Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Verification script for MCP setup | |
| """ | |
| import os | |
| import sys | |
| import subprocess | |
| def check_files(): | |
| """Check that all MCP-related files exist.""" | |
| required_files = [ | |
| "mcp_server.py", | |
| "docs/MCP_INTEGRATION.md", | |
| "docs/MCP_IMPLEMENTATION_SUMMARY.md", | |
| "examples/mcp_client_example.py", | |
| "tests/test_mcp_server.py", | |
| "tests/test_mcp_integration.py" | |
| ] | |
| missing_files = [] | |
| for file in required_files: | |
| if not os.path.exists(file): | |
| missing_files.append(file) | |
| if missing_files: | |
| print("โ Missing files:") | |
| for file in missing_files: | |
| print(f" - {file}") | |
| return False | |
| else: | |
| print("โ All MCP-related files are present") | |
| return True | |
| def check_requirements(): | |
| """Check that MCP is in requirements.txt.""" | |
| try: | |
| with open("requirements.txt", "r") as f: | |
| content = f.read() | |
| if "mcp==" in content: | |
| print("โ MCP package is in requirements.txt") | |
| return True | |
| else: | |
| print("โ MCP package is not in requirements.txt") | |
| return False | |
| except FileNotFoundError: | |
| print("โ requirements.txt not found") | |
| return False | |
| def check_imports(): | |
| """Check that MCP imports work.""" | |
| try: | |
| # Try importing the main module using subprocess | |
| result = subprocess.run( | |
| [sys.executable, "-c", "import mcp; print('Success')"], | |
| capture_output=True, | |
| text=True | |
| ) | |
| if result.returncode == 0: | |
| print("โ MCP imports work correctly") | |
| return True | |
| else: | |
| print(f"โ MCP imports failed: {result.stderr}") | |
| return False | |
| except Exception as e: | |
| print(f"โ MCP imports failed: {e}") | |
| return False | |
| def main(): | |
| """Run all verification checks.""" | |
| print("Verifying MCP setup...") | |
| print() | |
| checks = [ | |
| ("Files", check_files), | |
| ("Requirements", check_requirements), | |
| ("Imports", check_imports) | |
| ] | |
| results = [] | |
| for name, check in checks: | |
| print(f"Checking {name}...") | |
| result = check() | |
| results.append(result) | |
| print() | |
| if all(results): | |
| print("๐ All MCP setup checks passed!") | |
| print() | |
| print("You can now start the MCP server with:") | |
| print(" python mcp_server.py") | |
| print() | |
| print("Or start both servers with:") | |
| print(" python start_with_mcp.py") | |
| return 0 | |
| else: | |
| print("โ Some MCP setup checks failed!") | |
| return 1 | |
| if __name__ == "__main__": | |
| sys.exit(main()) |