a1d-mcp-server / demo.py
yuxh1996's picture
Fix Gradio compatibility issues
2ca01e7
#!/usr/bin/env python3
"""
Demo script for A1D MCP Server
Shows how to use the tools programmatically
"""
import os
from app import (
remove_bg,
image_upscaler,
video_upscaler,
image_vectorization,
image_extends,
image_generator
)
def demo_tools():
"""Demonstrate all available tools"""
print("🎨 A1D MCP Server - Tool Demonstration")
print("=" * 50)
# Set a demo API key (you should use a real one)
os.environ['A1D_API_KEY'] = 'demo_key_replace_with_real'
print("\nπŸ“‹ Available Tools:")
# Demo URLs (these are example URLs - replace with real ones for testing)
demo_image_url = "https://example.com/sample-image.jpg"
demo_video_url = "https://example.com/sample-video.mp4"
demo_prompt = "A beautiful sunset over mountains with vibrant colors"
tools_demo = [
("🎭 Background Removal", lambda: remove_bg(demo_image_url)),
("πŸ” Image Upscaler (2x)", lambda: image_upscaler(demo_image_url, 2)),
("πŸ” Image Upscaler (4x)", lambda: image_upscaler(demo_image_url, 4)),
("🎬 Video Upscaler", lambda: video_upscaler(demo_video_url)),
("πŸ“ Image Vectorization", lambda: image_vectorization(demo_image_url)),
("πŸ–ΌοΈ Image Extension", lambda: image_extends(demo_image_url)),
("🎨 Image Generator", lambda: image_generator(demo_prompt)),
]
for tool_name, tool_func in tools_demo:
print(f"\n{tool_name}:")
try:
result = tool_func()
print(f" Result: {result}")
except Exception as e:
print(f" Error: {e}")
print("\n" + "=" * 50)
print("πŸ’‘ Note: This demo uses example URLs and a demo API key.")
print(" For real usage, set A1D_API_KEY environment variable")
print(" and use actual image/video URLs.")
def show_mcp_config():
"""Show MCP client configuration"""
print("\nπŸ”§ MCP Client Configuration:")
print("Add this to your Claude Desktop config:")
print("""
{
"mcpServers": {
"a1d-gradio": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:7860/gradio_api/mcp/sse"
]
}
}
}
""")
if __name__ == "__main__":
demo_tools()
show_mcp_config()