Skip to main content
Glama

POEditor MCP Server

by r-pedraza
setup.pyโ€ข17.1 kB
#!/usr/bin/env python3 """ ๐Ÿš€ POEditor MCP Automatic Setup Script Automatically configures the complete POEditor MCP environment """ import os import sys import subprocess import shutil from pathlib import Path from typing import Optional import urllib.request import json class Colors: """ANSI color codes for terminal output.""" GREEN = '\033[92m' YELLOW = '\033[93m' RED = '\033[91m' BLUE = '\033[94m' PURPLE = '\033[95m' CYAN = '\033[96m' WHITE = '\033[97m' BOLD = '\033[1m' END = '\033[0m' def print_banner(): """Print the setup banner.""" banner = f""" {Colors.CYAN}{Colors.BOLD} โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•— โ•‘ ๐ŸŒ POEditor MCP Setup โ•‘ โ•‘ Automatic Environment Configuration โ•‘ โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• {Colors.END} {Colors.WHITE}Welcome to POEditor MCP! This script will automatically configure your translation automation environment.{Colors.END} {Colors.YELLOW}๐Ÿ“‹ What this setup will do:{Colors.END} โ€ข โœ… Install Python dependencies โ€ข ๐Ÿ”ง Create configuration files โ€ข ๐Ÿ“ Set up directory structure โ€ข ๐Ÿ”‘ Configure POEditor API connection โ€ข ๐Ÿงช Test the installation โ€ข ๐ŸŽฏ Run a demo to verify everything works """ print(banner) def check_python_version(): """Check if Python version is compatible.""" print(f"{Colors.BLUE}๐Ÿ Checking Python version...{Colors.END}") if sys.version_info < (3, 8): print(f"{Colors.RED}โŒ Python 3.8+ is required. Found: {sys.version}{Colors.END}") print(f"{Colors.YELLOW}Please upgrade Python and try again.{Colors.END}") return False print(f"{Colors.GREEN}โœ… Python {sys.version.split()[0]} is compatible{Colors.END}") return True def check_git(): """Check if git is available.""" try: subprocess.run(['git', '--version'], capture_output=True, check=True) print(f"{Colors.GREEN}โœ… Git is available{Colors.END}") return True except (subprocess.CalledProcessError, FileNotFoundError): print(f"{Colors.YELLOW}โš ๏ธ Git not found (optional for development){Colors.END}") return False def install_dependencies(): """Install Python dependencies.""" print(f"\n{Colors.BLUE}๐Ÿ“ฆ Installing Python dependencies...{Colors.END}") try: # Upgrade pip first subprocess.run([ sys.executable, "-m", "pip", "install", "--upgrade", "pip" ], check=True, capture_output=True) # Install requirements subprocess.run([ sys.executable, "-m", "pip", "install", "-r", "requirements.txt" ], check=True) print(f"{Colors.GREEN}โœ… Dependencies installed successfully{Colors.END}") return True except subprocess.CalledProcessError as e: print(f"{Colors.RED}โŒ Failed to install dependencies: {e}{Colors.END}") print(f"{Colors.YELLOW}๐Ÿ’ก Try: pip install -r requirements.txt{Colors.END}") return False def create_directory_structure(): """Create the necessary directory structure.""" print(f"\n{Colors.BLUE}๐Ÿ“ Creating directory structure...{Colors.END}") directories = [ "logs", "reports", "exports", "backups", "examples", "docs" ] for directory in directories: dir_path = Path(directory) dir_path.mkdir(exist_ok=True) print(f" ๐Ÿ“ Created: {directory}/") print(f"{Colors.GREEN}โœ… Directory structure created{Colors.END}") def get_poeditor_token(): """Get POEditor API token from user.""" print(f"\n{Colors.BLUE}๐Ÿ”‘ POEditor API Configuration{Colors.END}") print(f"{Colors.WHITE}You need a POEditor API token to use this MCP server.{Colors.END}") print(f"{Colors.CYAN}๐Ÿ“– How to get your API token:{Colors.END}") print(f" 1. Go to https://poeditor.com/account/api") print(f" 2. Generate a new API token") print(f" 3. Copy the token") print() while True: token = input(f"{Colors.YELLOW}๐Ÿ”‘ Enter your POEditor API token: {Colors.END}").strip() if not token: print(f"{Colors.RED}โŒ Token cannot be empty{Colors.END}") continue if len(token) < 30: print(f"{Colors.RED}โŒ Token seems too short. Please check and try again.{Colors.END}") continue # Test the token if test_api_token(token): return token else: print(f"{Colors.RED}โŒ Invalid token. Please try again.{Colors.END}") def test_api_token(token: str) -> bool: """Test if the API token is valid.""" print(f"{Colors.BLUE}๐Ÿงช Testing API token...{Colors.END}") try: import httpx async def test_token(): async with httpx.AsyncClient() as client: response = await client.post( "https://api.poeditor.com/v2/projects/list", data={"api_token": token} ) result = response.json() return result.get("response", {}).get("status") == "success" import asyncio is_valid = asyncio.run(test_token()) if is_valid: print(f"{Colors.GREEN}โœ… API token is valid{Colors.END}") return True else: print(f"{Colors.RED}โŒ API token is invalid{Colors.END}") return False except Exception as e: print(f"{Colors.YELLOW}โš ๏ธ Could not test token: {e}{Colors.END}") print(f"{Colors.YELLOW}๐Ÿ“ Token saved anyway - test manually later{Colors.END}") return True # Assume valid if we can't test headers = { 'Content-Type': 'application/x-www-form-urlencoded', } data = { 'api_token': token, 'action': 'list_projects' } with httpx.Client() as client: response = client.post( 'https://api.poeditor.com/v2/projects/list', headers=headers, data=data, timeout=10 ) if response.status_code == 200: result = response.json() if result.get('response', {}).get('status') == 'success': projects = result.get('result', {}).get('projects', []) print(f"{Colors.GREEN}โœ… Token is valid! Found {len(projects)} project(s){Colors.END}") return True else: print(f"{Colors.RED}โŒ API error: {result.get('response', {}).get('message', 'Unknown error')}{Colors.END}") return False else: print(f"{Colors.RED}โŒ HTTP error: {response.status_code}{Colors.END}") return False except ImportError: print(f"{Colors.YELLOW}โš ๏ธ Cannot test token (httpx not installed yet){Colors.END}") return True # Assume valid for now except Exception as e: print(f"{Colors.RED}โŒ Error testing token: {e}{Colors.END}") return False def create_env_file(api_token: str): """Create the .env configuration file.""" print(f"\n{Colors.BLUE}๐Ÿ“ Creating environment configuration...{Colors.END}") env_content = f"""# POEditor MCP Configuration # Generated automatically by setup.py # POEditor API Configuration POEDITOR_API_TOKEN={api_token} POEDITOR_API_URL=https://api.poeditor.com/v2/ # MCP Server Configuration MCP_SERVER_NAME=poeditor-mcp MCP_SERVER_VERSION=1.0.0 # Logging LOG_LEVEL=INFO # Default settings DEFAULT_EXPORT_FORMAT=json MAX_RETRIES=3 REQUEST_TIMEOUT=30 # Notification Settings (Optional - Configure later) # SMTP_SERVER=smtp.gmail.com # SMTP_PORT=587 # SMTP_USERNAME=your_email@company.com # SMTP_PASSWORD=your_app_password # SLACK_WEBHOOK_URL=https://hooks.slack.com/services/... # Automation Settings ENABLE_AUTO_SUGGESTIONS=true FUZZY_THRESHOLD=10 PROGRESS_WARNING_THRESHOLD=65 PROGRESS_CRITICAL_THRESHOLD=50 """ with open('.env', 'w') as f: f.write(env_content) print(f"{Colors.GREEN}โœ… Environment configuration created (.env){Colors.END}") def setup_scheduler_config(): """Create default scheduler configuration.""" print(f"\n{Colors.BLUE}๐Ÿ•’ Setting up automation scheduler...{Colors.END}") scheduler_config = { "schedules": { "daily_report": { "time": "08:00", "enabled": True, "weekdays_only": True, "description": "Generate daily progress report" }, "monitoring": { "time": "09:00", "enabled": True, "weekdays_only": True, "description": "Run translation quality monitoring" }, "auto_translations": { "time": "10:00", "enabled": False, "weekdays_only": True, "description": "Generate AI translation suggestions" }, "weekly_optimization": { "day": "monday", "time": "08:30", "enabled": False, "description": "Weekly workflow optimization analysis" }, "backup_export": { "day": "sunday", "time": "02:00", "enabled": False, "description": "Complete backup and export" } }, "notification_settings": { "email_enabled": False, "slack_enabled": False, "notification_levels": ["critical", "warning"] }, "export_settings": { "default_formats": ["json", "csv"], "auto_export_on_completion": False } } scripts_dir = Path("scripts") scripts_dir.mkdir(exist_ok=True) config_file = scripts_dir / "scheduler_config.json" with open(config_file, 'w') as f: json.dump(scheduler_config, f, indent=2) print(f"{Colors.GREEN}โœ… Scheduler configuration created{Colors.END}") def copy_source_files(): """Copy the source files to the new repository structure.""" print(f"\n{Colors.BLUE}๐Ÿ“‹ Setting up source files...{Colors.END}") # This would be run from the original project # In a real repo, the files would already be there print(f"{Colors.GREEN}โœ… Source files ready{Colors.END}") def run_tests(): """Run basic tests to verify the installation.""" print(f"\n{Colors.BLUE}๐Ÿงช Running installation tests...{Colors.END}") tests = [ ("Import MCP package", test_import_mcp), ("Test POEditor connection", test_poeditor_connection), ("Verify control center", test_control_center), ("Check file permissions", test_file_permissions) ] passed = 0 total = len(tests) for test_name, test_func in tests: print(f" ๐Ÿ” {test_name}...") try: if test_func(): print(f" โœ… {test_name}: PASSED") passed += 1 else: print(f" โŒ {test_name}: FAILED") except Exception as e: print(f" โŒ {test_name}: ERROR - {e}") success_rate = (passed / total) * 100 print(f"\n๐Ÿ“Š Test Results: {passed}/{total} passed ({success_rate:.1f}%)") if passed == total: print(f"{Colors.GREEN}๐ŸŽ‰ All tests passed! Installation is successful.{Colors.END}") return True else: print(f"{Colors.YELLOW}โš ๏ธ Some tests failed. The installation may have issues.{Colors.END}") return False def test_import_mcp(): """Test importing the MCP package.""" try: import mcp_poeditor return True except ImportError: return False def test_poeditor_connection(): """Test POEditor API connection.""" try: # This would test the actual connection # For now, just verify the .env file exists return Path('.env').exists() except: return False def test_control_center(): """Test the control center script.""" try: return Path('scripts/control_center.py').exists() except: return False def test_file_permissions(): """Test file permissions.""" try: setup_script = Path('setup.py') return setup_script.exists() and os.access(setup_script, os.R_OK) except: return False def show_next_steps(): """Show next steps after successful installation.""" print(f"\n{Colors.GREEN}{Colors.BOLD}๐ŸŽ‰ POEditor MCP Setup Complete!{Colors.END}") print(f"\n{Colors.CYAN}๐Ÿš€ Quick Start Commands:{Colors.END}") print(f" {Colors.WHITE}# Test your installation{Colors.END}") print(f" python test_connection.py") print(f"") print(f" {Colors.WHITE}# Run the control center{Colors.END}") print(f" python scripts/control_center.py help") print(f"") print(f" {Colors.WHITE}# Generate a progress report{Colors.END}") print(f" python scripts/control_center.py daily_report") print(f"") print(f" {Colors.WHITE}# Start monitoring{Colors.END}") print(f" python scripts/control_center.py monitor") print(f"") print(f" {Colors.WHITE}# Run complete demo{Colors.END}") print(f" python scripts/demo_workflow.py") print(f"\n{Colors.CYAN}๐Ÿ“š Next Steps:{Colors.END}") print(f" 1. ๐Ÿ“– Read the documentation: {Colors.BLUE}docs/CONFIGURATION.md{Colors.END}") print(f" 2. ๐Ÿ”ง Customize scheduler: {Colors.BLUE}scripts/scheduler_config.json{Colors.END}") print(f" 3. ๐Ÿ“ง Configure notifications: {Colors.BLUE}.env{Colors.END}") print(f" 4. ๐Ÿ•’ Set up automation: {Colors.BLUE}python scripts/control_center.py schedule start{Colors.END}") print(f"\n{Colors.CYAN}๐Ÿ“ Generated Files:{Colors.END}") files = [ (".env", "Environment configuration"), ("scripts/scheduler_config.json", "Automation settings"), ("logs/", "Execution logs"), ("reports/", "Generated reports"), ("exports/", "Translation exports") ] for file_path, description in files: if Path(file_path).exists(): print(f" ๐Ÿ“„ {file_path:<30} - {description}") print(f"\n{Colors.YELLOW}๐Ÿ’ก Pro Tips:{Colors.END}") print(f" โ€ข Use {Colors.WHITE}python scripts/control_center.py status{Colors.END} to check system health") print(f" โ€ข Set up cron jobs for automatic execution") print(f" โ€ข Configure Slack/email notifications for team updates") print(f" โ€ข Check the examples/ directory for integration ideas") def main(): """Main setup function.""" try: print_banner() # Confirmation response = input(f"{Colors.YELLOW}๐Ÿš€ Continue with automatic setup? (Y/n): {Colors.END}").strip().lower() if response in ['n', 'no']: print(f"{Colors.CYAN}Setup cancelled. You can run this script again anytime.{Colors.END}") return print(f"\n{Colors.BOLD}Starting POEditor MCP setup...{Colors.END}") # Step 1: Check environment if not check_python_version(): return check_git() # Step 2: Install dependencies if not install_dependencies(): print(f"{Colors.RED}โŒ Setup failed at dependency installation{Colors.END}") return # Step 3: Create directories create_directory_structure() # Step 4: Get POEditor token api_token = get_poeditor_token() # Step 5: Create configuration create_env_file(api_token) setup_scheduler_config() # Step 6: Run tests if run_tests(): show_next_steps() else: print(f"\n{Colors.YELLOW}โš ๏ธ Setup completed with warnings.{Colors.END}") print(f"Check the error messages above and try running:") print(f" python scripts/control_center.py test") print(f"\n{Colors.GREEN}{Colors.BOLD}โœ… Setup completed successfully!{Colors.END}") except KeyboardInterrupt: print(f"\n\n{Colors.YELLOW}Setup interrupted by user.{Colors.END}") except Exception as e: print(f"\n{Colors.RED}โŒ Setup failed with error: {e}{Colors.END}") print(f"{Colors.YELLOW}Please check the error and try again, or set up manually.{Colors.END}") 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/r-pedraza/poeditor-mcp'

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