auxoppttest / app.py
BruceWayne1's picture
hiii
d8c96b1
#!/usr/bin/env python
"""
Main entry point for PowerPoint MCP Server with Gradio interface
COMPLETE VERSION - uses all existing utils/ and tools/ modules
FIXED IMPORTS - correct file names
"""
import os
import logging
import time
from threading import Thread
# Set up logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def main():
"""Main application entry point"""
try:
logger.info("Starting PowerPoint MCP Server - Complete Edition")
logger.info("Loading all utils/ and tools/ modules...")
# Import our complete modules - CORRECT names
from mcp_server import start_mcp_server, get_mcp_server_info
from gradio_interface import create_gradio_interface
# Log server info
server_info = get_mcp_server_info()
logger.info(f"Server: {server_info['name']} v{server_info['version']}")
logger.info(f"Tools: {server_info['total_tools']} tools across multiple modules")
from config import get_server_config, is_huggingface_spaces
cfg = get_server_config()
if is_huggingface_spaces():
# On Hugging Face, bind ONLY the MCP server to the provided PORT and do not start Gradio
logger.info("Detected Hugging Face Spaces. Running MCP server only on PORT=%s", cfg.get("mcp_port"))
start_mcp_server()
else:
# Start MCP server in background and launch Gradio locally
logger.info("Starting MCP server thread...")
mcp_thread = Thread(target=start_mcp_server, daemon=True)
mcp_thread.start()
time.sleep(3)
logger.info("βœ… MCP Server started with streamable HTTP transport")
logger.info("βœ… All utils/ and tools/ modules loaded successfully")
logger.info("Starting Gradio web interface...")
demo = create_gradio_interface()
demo.launch(
server_name=cfg.get("host", "0.0.0.0"),
server_port=cfg.get("gradio_port", 7860),
share=False,
show_error=True,
show_api=False
)
except ImportError as e:
logger.error(f"Import error - missing module: {str(e)}")
logger.error("Make sure all utils/ and tools/ modules are available")
# Try to show what modules are available
show_available_modules()
raise
except Exception as e:
logger.error(f"Error starting application: {str(e)}")
raise
def show_available_modules():
"""Show what modules are available for debugging"""
logger.info("Checking available modules...")
# Check utils modules
utils_modules = ['core_utils', 'presentation_utils', 'content_utils', 'design_utils', 'template_utils', 'validation_utils']
for module in utils_modules:
try:
exec(f"import utils.{module}")
logger.info(f"βœ… utils.{module} - Available")
except ImportError:
logger.warning(f"❌ utils.{module} - Not found")
# Check tools modules
tools_modules = ['presentation_tools', 'content_tools', 'template_tools', 'structural_tools', 'professional_tools',
'hyperlink_tools', 'chart_tools', 'connector_tools', 'master_tools', 'transition_tools']
for module in tools_modules:
try:
exec(f"import tools.{module}")
logger.info(f"βœ… tools.{module} - Available")
except ImportError:
logger.warning(f"❌ tools.{module} - Not found")
if __name__ == "__main__":
main()