Spaces:
Running
Running
File size: 2,287 Bytes
2ca01e7 |
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 |
#!/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()
|