#!/usr/bin/env python3 """ Startup script for A1D MCP Server """ import os import sys from app import create_gradio_app def main(): """Start the A1D MCP Server""" print("šŸš€ Starting A1D MCP Server...") print("=" * 50) # Check for API key api_key = os.getenv("A1D_API_KEY") if not api_key: print("āŒ Error: A1D_API_KEY environment variable is required") print("\nšŸ“ To set your API key:") print(" export A1D_API_KEY=your_api_key_here") print("\nšŸ”— Get your API key at: https://a1d.ai/home/api") return 1 print(f"āœ… API key found: {api_key[:8]}...") # Create and launch the app try: demo = create_gradio_app() print("\nšŸŽÆ Server Configuration:") print(f" - Title: {demo.title}") print(f" - MCP Server: Enabled") print(f" - Server: http://localhost:7860") print(f" - MCP Endpoint: http://localhost:7860/gradio_api/mcp/sse") print("\nšŸ“‹ Available Tools:") from config import TOOLS_CONFIG for tool_name, config in TOOLS_CONFIG.items(): print(f" - {tool_name}: {config['description']}") print("\nšŸ”§ MCP Client Configuration:") print("Add this to your MCP client config:") print(""" { "mcpServers": { "a1d-gradio": { "command": "npx", "args": [ "mcp-remote", "http://localhost:7860/gradio_api/mcp/sse" ] } } } """) print("\n🌐 Starting server...") # Launch with MCP server enabled demo.launch( mcp_server=True, server_name="0.0.0.0", server_port=7860, share=False, show_error=True ) except KeyboardInterrupt: print("\nšŸ‘‹ Server stopped by user") return 0 except Exception as e: print(f"\nāŒ Error starting server: {e}") return 1 if __name__ == "__main__": sys.exit(main())