File size: 2,043 Bytes
aaa3e82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/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())