Skip to main content
Glama
test_new_structure.pyโ€ข5.36 kB
#!/usr/bin/env python3 """ Test script to verify the new MCP structure and environment-based configuration """ import os import sys import asyncio from pathlib import Path def test_imports(): """Test that all imports work with the new structure""" print("๐Ÿ”ง Testing Imports...") print("=" * 50) try: # Test new structure imports from src.notion_mcp_server import NotionMCPServer print("โœ… NotionMCPServer import successful") from src.utils.mcp_client_manager import MCPClientManager print("โœ… MCPClientManager import successful") from src.utils.chatbot_agentic_v3 import Chatbot print("โœ… Chatbot import successful") return True except ImportError as e: print(f"โŒ Import error: {e}") return False def test_environment_config(): """Test environment variable configuration""" print("\n๐Ÿ”ง Testing Environment Configuration...") print("=" * 50) # Check required environment variables config = { "NOTION_TOKEN": os.getenv("NOTION_TOKEN"), "NOTION_MCP_SERVER_URL": os.getenv("NOTION_MCP_SERVER_URL", "https://notion-mcp-server-5s5v.onrender.com/"), "OPENAI_API_KEY": os.getenv("OPENAI_API_KEY"), } for key, value in config.items(): status = "โœ…" if value else "โŒ" display_value = value[:20] + "..." if value and len(value) > 20 else value or "Not set" print(f" {key}: {status} {display_value}") return bool(config["NOTION_TOKEN"]) and bool(config["OPENAI_API_KEY"]) def test_mcp_client_manager(): """Test MCP Client Manager with new configuration""" print("\n๐Ÿ”ง Testing MCP Client Manager...") print("=" * 50) try: from src.utils.mcp_client_manager import MCPClientManager # Test initialization client_manager = MCPClientManager() print("โœ… MCPClientManager initialized successfully") print(f" Server URL: {client_manager.notion_server_url}") print(f" Token configured: {'โœ…' if client_manager.notion_token else 'โŒ'}") return True except Exception as e: print(f"โŒ MCPClientManager test failed: {e}") return False async def test_server_connection(): """Test connection to the deployed server""" print("\n๐Ÿ”ง Testing Server Connection...") print("=" * 50) try: import aiohttp server_url = os.getenv("NOTION_MCP_SERVER_URL", "https://notion-mcp-server-5s5v.onrender.com/") async with aiohttp.ClientSession() as session: async with session.get(server_url, timeout=10) as response: if response.status == 200: data = await response.json() print(f"โœ… Server connection successful") print(f" Status: {data.get('status')}") print(f" Available tools: {len(data.get('available_tools', []))}") return True else: print(f"โŒ Server returned status: {response.status}") return False except Exception as e: print(f"โŒ Server connection failed: {e}") return False def test_file_structure(): """Test that the new file structure exists""" print("\n๐Ÿ”ง Testing File Structure...") print("=" * 50) required_files = [ "src/notion_mcp_server/__init__.py", "src/notion_mcp_server/server.py", "src/utils/mcp_client_manager.py", "src/utils/chatbot_agentic_v3.py", "docker/Dockerfile.notion-mcp", "config.env.example" ] all_exist = True for file_path in required_files: if Path(file_path).exists(): print(f"โœ… {file_path}") else: print(f"โŒ {file_path} - Missing") all_exist = False return all_exist async def main(): """Run all tests""" print("๐Ÿงช New Structure Verification Test Suite") print("=" * 60) test_results = [] # Run tests test_results.append(("File Structure", test_file_structure())) test_results.append(("Imports", test_imports())) test_results.append(("Environment Config", test_environment_config())) test_results.append(("MCP Client Manager", test_mcp_client_manager())) test_results.append(("Server Connection", await test_server_connection())) # Summary print("\n" + "=" * 60) print("๐Ÿ“Š Test Results Summary:") passed = 0 for test_name, result in test_results: status = "โœ… PASSED" if result else "โŒ FAILED" print(f" {test_name}: {status}") if result: passed += 1 print(f"\n๐ŸŽฏ Overall: {passed}/{len(test_results)} tests passed") if passed == len(test_results): print("\n๐ŸŽ‰ All tests passed! New structure is working correctly.") return True else: print("\nโš ๏ธ Some tests failed. Check the output above for details.") return False if __name__ == "__main__": try: success = asyncio.run(main()) sys.exit(0 if success else 1) except KeyboardInterrupt: print("\nโน๏ธ Test interrupted by user") sys.exit(1)

Latest Blog Posts

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/ankitmalik84/Agentic_Longterm_Memory'

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