#!/usr/bin/env python3
"""
π― Complete POEditor MCP System Demo
Demonstrates a typical workflow using the POEditor MCP server
"""
import asyncio
import subprocess
import sys
from pathlib import Path
from datetime import datetime
async def run_command(command: str, description: str):
"""Execute command and show result."""
print(f"\n{'='*60}")
print(f"π {description}")
print('='*60)
print(f"π» Command: {command}")
print()
try:
# Execute command
result = subprocess.run(
command.split(),
capture_output=True,
text=True,
timeout=60
)
if result.returncode == 0:
print(result.stdout)
print("β
Command executed successfully")
else:
print("β Execution error:")
print(result.stderr)
except subprocess.TimeoutExpired:
print("β° Command timed out")
except Exception as e:
print(f"β Error executing command: {e}")
# Pause for reading
input("\nπ Press Enter to continue...")
async def demo_workflow():
"""Demo of complete workflow."""
print("π― COMPLETE WORKFLOW DEMO")
print("=" * 60)
print("This demo simulates a typical day working with POEditor MCP:")
print("1. π
Initial setup")
print("2. π Morning monitoring")
print("3. π Daily reports")
print("4. π€ Translation automation")
print("5. π Workflow optimization")
print("6. π¦ Export for developers")
print()
response = input("Continue with demo? (y/N): ").lower().strip()
if response not in ['y', 'yes']:
print("Demo cancelled.")
return
# Change to scripts directory
scripts_dir = Path(__file__).parent
print(f"π Working directory: {scripts_dir}")
# 1. Check MCP server status
await run_command(
"python -m mcp_poeditor --help",
"1. π§ MCP Server Status Check"
)
# 2. Run basic example
await run_command(
"python examples/basic_usage.py",
"2. π¨ Basic Usage Example"
)
print(f"\n{'='*60}")
print("π DEMO COMPLETED!")
print('='*60)
print("π Available directories:")
# List available directories
output_dirs = ["logs", "reports", "exports", "examples", "docs"]
for dir_name in output_dirs:
dir_path = scripts_dir / dir_name
if dir_path.exists():
files = list(dir_path.glob("*"))
if files:
print(f"\nπ {dir_name}/:")
for file in files[:3]: # First 3 files
if file.is_file():
size = file.stat().st_size / 1024
print(f" π {file.name} ({size:.1f} KB)")
print("\nπ‘ RECOMMENDED NEXT STEPS:")
print(" 1. π§ Configure notifications (SMTP/Slack)")
print(" 2. π Set up automatic scheduling (cron)")
print(" 3. π― Customize thresholds for your project")
print(" 4. π± Integrate exports with your CI/CD")
print("\nπ USEFUL LINKS:")
print(" β’ π Documentation: docs/INSTALLATION.md")
print(" β’ βοΈ Configuration: .env.template")
print(" β’ π Examples: examples/")
print(" β’ ποΈ Logs: logs/")
async def demo_api_usage():
"""Demo direct MCP API usage."""
print("\n" + "="*60)
print("π DIRECT MCP API USAGE DEMO")
print("="*60)
print("Running some MCP commands directly...")
# Use the basic example
try:
await run_command(
"python examples/basic_usage.py",
"Running Basic Usage Example"
)
except Exception as e:
print(f"β Error running API demo: {e}")
print("π‘ Make sure the MCP server is working properly")
def show_project_structure():
"""Show project structure."""
print("\n" + "="*60)
print("π POEDITOR MCP PROJECT STRUCTURE")
print("="*60)
structure = """
poeditor-mcp/
βββ π README.md # Main documentation
βββ π requirements.txt # Python dependencies
βββ π setup.py # Automated setup script
βββ π .env.template # Environment template
βββ π LICENSE # MIT License
β
βββ π mcp_poeditor/ # Main MCP package
β βββ π __init__.py
β βββ π __main__.py # Entry point
β βββ π server.py # MCP server
β βββ π poeditor_client.py # POEditor API client
β β
β βββ π tools/ # MCP tools
β β βββ π projects.py # Project management
β β βββ π languages.py # Language management
β β βββ π terms.py # Term management
β β βββ π translations.py # Translation management
β β βββ π stats.py # Statistics
β β
β βββ π utils/ # Utilities
β βββ π config.py # Configuration
β βββ π helpers.py # Helper functions
β
βββ π examples/ # π USAGE EXAMPLES
β βββ π basic_usage.py # Basic usage example
β
βββ π docs/ # π DOCUMENTATION
β βββ π INSTALLATION.md # Installation guide
β
βββ π scripts/ # π οΈ AUTOMATION SCRIPTS
β βββ π demo_workflow.py # This demo script
β
βββ π logs/ # Execution logs (created by setup)
βββ π reports/ # Generated reports (created by setup)
βββ π exports/ # Mass exports (created by setup)
βββ π backups/ # Automatic backups (created by setup)
"""
print(structure)
print("π― MAIN FEATURES:")
print(" β’ π Complete MCP server for POEditor")
print(" β’ π οΈ Full API client with all endpoints")
print(" β’ π Rich tool set for translation management")
print(" β’ π¨ Professional project structure")
print(" β’ π€ Automated setup and configuration")
print(" β’ π§ Extensible for notifications and automation")
print(" β’ π Ready for CI/CD integration")
print(" β’ π¦ Professional packaging and documentation")
async def main():
"""Main demo function."""
print("π― COMPLETE DEMO - POEDITOR MCP SYSTEM")
print("=" * 60)
print("Welcome to the complete POEditor automation system!")
print()
while True:
print("\nποΈ AVAILABLE OPTIONS:")
print(" 1. π View project structure")
print(" 2. π― Complete workflow demo")
print(" 3. π Direct MCP API usage demo")
print(" 4. π Help and documentation")
print(" 5. πͺ Exit")
choice = input("\nπ’ Select an option (1-5): ").strip()
if choice == "1":
show_project_structure()
elif choice == "2":
await demo_workflow()
elif choice == "3":
await demo_api_usage()
elif choice == "4":
print("\nπ HELP AND DOCUMENTATION:")
print(" β’ Main README: README.md")
print(" β’ Installation: docs/INSTALLATION.md")
print(" β’ Basic usage: examples/basic_usage.py")
print(" β’ Configuration: .env.template")
print("\nπ§ SETUP:")
print(" β’ Run: python setup.py")
print(" β’ Configure: edit .env file")
print(" β’ Test: python examples/basic_usage.py")
elif choice == "5":
print("\nπ Thanks for using POEditor MCP!")
print("π Hope you enjoy translation automation")
break
else:
print("β Invalid option. Please select 1-5.")
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
print("\n\nπ Demo interrupted. See you later!")
except Exception as e:
print(f"\nβ Demo error: {e}")
sys.exit(1)