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