a1d-mcp-server / start_server.py
yuxh1996's picture
Initial commit: A1D MCP Server with Gradio interface
aaa3e82
#!/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())