Spaces:
Running
Running
#!/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()) | |