Skip to main content
Glama
activate_production_agents.pyโ€ข9.68 kB
#!/usr/bin/env python3 """ Activate Production Agents Ensures all production agents are properly loaded and configured """ import os import sys import importlib.util from pathlib import Path def ensure_agent_registration(): """Ensure all production agents are properly registered.""" print("๐Ÿ”ง ACTIVATING PRODUCTION AGENTS") print("=" * 50) # Production agents that should be active production_agents = { "realtime_weather_agent": "agents/data/realtime_weather_agent.py", "math_agent": "agents/specialized/math_agent(2).py", "calendar_agent": "agents/specialized/calendar_agent(1).py", "real_gmail_agent": "agents/communication/real_gmail_agent.py", "document_processor": "agents/core/document_processor.py" } print(f"๐ŸŽฏ Target production agents: {len(production_agents)}") print() activated_count = 0 for agent_name, agent_path in production_agents.items(): print(f"๐Ÿ” Checking {agent_name}...") # Check if file exists if Path(agent_path).exists(): print(f" โœ… File found: {agent_path}") # Try to import and validate try: spec = importlib.util.spec_from_file_location(agent_name, agent_path) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) # Check if it has required functions if hasattr(module, 'create_agent') and hasattr(module, 'get_agent_info'): print(f" โœ… Agent structure valid") # Get agent info agent_info = module.get_agent_info() print(f" ๐Ÿ“ Description: {agent_info.get('description', 'No description')}") activated_count += 1 print(f" ๐ŸŽ‰ {agent_name} ACTIVATED") else: print(f" โŒ Missing required functions (create_agent, get_agent_info)") except Exception as e: print(f" โŒ Import error: {e}") else: print(f" โŒ File not found: {agent_path}") print() print("=" * 50) print(f"๐Ÿ“Š ACTIVATION SUMMARY:") print(f"โœ… Activated agents: {activated_count}/{len(production_agents)}") print(f"๐Ÿ“ˆ Success rate: {(activated_count/len(production_agents))*100:.1f}%") if activated_count == len(production_agents): print("\n๐ŸŽ‰ ALL PRODUCTION AGENTS ACTIVATED!") print("๐Ÿš€ Ready for full MCP functionality") else: missing = len(production_agents) - activated_count print(f"\nโš ๏ธ {missing} agents need attention") return activated_count == len(production_agents) def update_agent_init(): """Update agents/__init__.py to ensure proper discovery.""" print("\n๐Ÿ”ง UPDATING AGENT DISCOVERY") print("=" * 50) init_file = Path("agents/__init__.py") # Content for __init__.py init_content = '''""" MCP Agents Package Production agents for the Model Context Protocol system """ # Production agents auto-discovery PRODUCTION_AGENTS = [ "realtime_weather_agent", "math_agent", "calendar_agent", "real_gmail_agent", "document_processor" ] def get_production_agents(): """Get list of production agent names.""" return PRODUCTION_AGENTS def is_production_agent(agent_name): """Check if an agent is a production agent.""" return agent_name in PRODUCTION_AGENTS ''' try: with open(init_file, 'w') as f: f.write(init_content) print(f"โœ… Updated {init_file}") print("๐Ÿ“‹ Production agents registered for auto-discovery") return True except Exception as e: print(f"โŒ Error updating {init_file}: {e}") return False def clean_cache(): """Clean Python cache files.""" print("\n๐Ÿงน CLEANING CACHE FILES") print("=" * 50) cache_dirs = [] # Find all __pycache__ directories for cache_dir in Path("agents").rglob("__pycache__"): cache_dirs.append(cache_dir) print(f"๐Ÿ” Found {len(cache_dirs)} cache directories") cleaned = 0 for cache_dir in cache_dirs: try: import shutil shutil.rmtree(cache_dir) print(f" โœ… Cleaned: {cache_dir}") cleaned += 1 except Exception as e: print(f" โŒ Error cleaning {cache_dir}: {e}") print(f"๐Ÿงน Cleaned {cleaned}/{len(cache_dirs)} cache directories") return cleaned == len(cache_dirs) def verify_gmail_config(): """Verify Gmail configuration.""" print("\n๐Ÿ“ง CHECKING GMAIL CONFIGURATION") print("=" * 50) from dotenv import load_dotenv load_dotenv() gmail_email = os.getenv('GMAIL_EMAIL', '').strip() gmail_password = os.getenv('GMAIL_APP_PASSWORD', '').strip() if gmail_email and gmail_password: if gmail_email != 'your-email@gmail.com' and gmail_password != 'your-app-password': print(f"โœ… Gmail email configured: {gmail_email}") print(f"โœ… Gmail app password configured: {'*' * len(gmail_password)}") print("๐ŸŽ‰ Gmail integration ready!") return True else: print("โš ๏ธ Gmail credentials are placeholder values") print("๐Ÿ”ง Please update .env file with real Gmail credentials") return False else: print("โŒ Gmail credentials not found in .env file") print("๐Ÿ’ก Add GMAIL_EMAIL and GMAIL_APP_PASSWORD to .env") return False def test_agent_loading(): """Test if agents can be loaded by the system.""" print("\n๐Ÿงช TESTING AGENT LOADING") print("=" * 50) try: # Import the agent loader sys.path.append('.') from agents.agent_loader import MCPAgentLoader # Create loader and load agents loader = MCPAgentLoader() loaded_agents = loader.load_all_agents() print(f"๐Ÿ“Š Loaded agents: {len(loaded_agents)}") production_agents = ["realtime_weather_agent", "math_agent", "calendar_agent", "real_gmail_agent", "document_processor"] loaded_production = [name for name in production_agents if name in loaded_agents] print(f"๐Ÿš€ Production agents loaded: {len(loaded_production)}/{len(production_agents)}") for agent_name in loaded_production: print(f" โœ… {agent_name}") missing = [name for name in production_agents if name not in loaded_agents] for agent_name in missing: print(f" โŒ {agent_name} (not loaded)") return len(loaded_production) == len(production_agents) except Exception as e: print(f"โŒ Error testing agent loading: {e}") return False def main(): """Main activation function.""" print("๐Ÿš€ MCP PRODUCTION AGENT ACTIVATION") print("=" * 80) success_count = 0 total_steps = 5 # Step 1: Clean cache if clean_cache(): success_count += 1 print("โœ… Step 1: Cache cleaned") else: print("โŒ Step 1: Cache cleaning failed") # Step 2: Update agent discovery if update_agent_init(): success_count += 1 print("โœ… Step 2: Agent discovery updated") else: print("โŒ Step 2: Agent discovery update failed") # Step 3: Ensure agent registration if ensure_agent_registration(): success_count += 1 print("โœ… Step 3: All agents registered") else: print("โŒ Step 3: Some agents failed registration") # Step 4: Verify Gmail config if verify_gmail_config(): success_count += 1 print("โœ… Step 4: Gmail configuration verified") else: print("โš ๏ธ Step 4: Gmail configuration needs attention") # Step 5: Test agent loading if test_agent_loading(): success_count += 1 print("โœ… Step 5: Agent loading test passed") else: print("โŒ Step 5: Agent loading test failed") print("\n" + "=" * 80) print("๐Ÿ“Š ACTIVATION RESULTS") print("=" * 80) print(f"โœ… Successful steps: {success_count}/{total_steps}") print(f"๐Ÿ“ˆ Success rate: {(success_count/total_steps)*100:.1f}%") if success_count == total_steps: print("\n๐ŸŽ‰ PRODUCTION AGENTS FULLY ACTIVATED!") print("๐Ÿš€ MCP system ready for production use") print("\n๐Ÿ’ก NEXT STEPS:") print(" 1. Start MCP server: python start_mcp.py") print(" 2. Test commands: python mcp_client.py") print(" 3. Use web interface: http://localhost:8000") elif success_count >= 3: print("\n๐ŸŽฏ MOSTLY SUCCESSFUL!") print("๐Ÿ”ง Minor issues need attention") print("๐Ÿ’ก System should work with current configuration") else: print("\nโš ๏ธ ACTIVATION INCOMPLETE") print("๐Ÿ”ง Several issues need to be resolved") print("๐Ÿ’ก Check error messages above and fix issues") return success_count >= 3 if __name__ == "__main__": try: success = main() if success: print("\n๐ŸŽ‰ Activation completed successfully!") else: print("\n๐Ÿ”ง Activation needs attention. Check errors above.") except Exception as e: print(f"\nโŒ Activation failed: {e}") 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/tensorwhiz141/MCP2'

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