Spaces:
Running
Running
Add comprehensive MCP documentation to all tool pages
Browse files- Add MCP client configuration instructions on every tool page
- Include detailed A1D API key acquisition guide
- Show Claude Desktop configuration with proper JSON format
- List all available MCP tools and endpoints
- Use gr.Blocks layout for better documentation integration
- Ensure users can access MCP setup info from any tool tab
Features added:
- Step-by-step A1D API key setup guide
- Complete Claude Desktop MCP configuration
- MCP endpoints and schema URLs
- Tool descriptions for MCP clients
app.py
CHANGED
|
@@ -290,119 +290,224 @@ def image_generator_wrapper(prompt: str):
|
|
| 290 |
return message, media_url if media_url else None
|
| 291 |
|
| 292 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
# Create Gradio interfaces for each tool
|
|
|
|
|
|
|
| 294 |
def create_gradio_app():
|
| 295 |
"""Create the main Gradio application with all tools"""
|
| 296 |
|
| 297 |
-
#
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 354 |
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 388 |
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
|
| 407 |
# Create tabbed interface
|
| 408 |
demo = gr.TabbedInterface(
|
|
|
|
| 290 |
return message, media_url if media_url else None
|
| 291 |
|
| 292 |
|
| 293 |
+
# MCP Documentation Component
|
| 294 |
+
def create_mcp_docs():
|
| 295 |
+
"""Create MCP documentation component"""
|
| 296 |
+
return gr.Markdown("""
|
| 297 |
+
## π§ MCP Client Configuration
|
| 298 |
+
|
| 299 |
+
### For Claude Desktop:
|
| 300 |
+
Add this configuration to your Claude Desktop settings:
|
| 301 |
+
|
| 302 |
+
```json
|
| 303 |
+
{
|
| 304 |
+
"mcpServers": {
|
| 305 |
+
"a1d-hosted": {
|
| 306 |
+
"command": "npx",
|
| 307 |
+
"args": [
|
| 308 |
+
"mcp-remote@latest",
|
| 309 |
+
"https://aigchacker-a1d-mcp-server.hf.space/gradio_api/mcp/sse",
|
| 310 |
+
"--header",
|
| 311 |
+
"API_KEY:${MCP_API_KEY}"
|
| 312 |
+
],
|
| 313 |
+
"env": {
|
| 314 |
+
"MCP_API_KEY": "your_a1d_api_key_here"
|
| 315 |
+
}
|
| 316 |
+
}
|
| 317 |
+
}
|
| 318 |
+
}
|
| 319 |
+
```
|
| 320 |
+
|
| 321 |
+
### π How to Get Your A1D API Key:
|
| 322 |
+
|
| 323 |
+
1. **Visit A1D Website**: Go to [https://a1d.ai](https://a1d.ai)
|
| 324 |
+
2. **Sign Up/Login**: Create an account or login to your existing account
|
| 325 |
+
3. **Access Dashboard**: Navigate to your user dashboard
|
| 326 |
+
4. **Generate API Key**: Look for "API Keys" or "Developer" section
|
| 327 |
+
5. **Copy Your Key**: Copy the generated API key
|
| 328 |
+
6. **Replace in Config**: Replace `your_a1d_api_key_here` with your actual API key
|
| 329 |
+
|
| 330 |
+
### π Available MCP Tools:
|
| 331 |
+
- `remove_bg_wrapper` - Remove background from images
|
| 332 |
+
- `image_upscaler_wrapper` - Upscale images (2x/4x/8x/16x)
|
| 333 |
+
- `video_upscaler_wrapper` - Upscale videos
|
| 334 |
+
- `image_vectorization_wrapper` - Convert images to vector format
|
| 335 |
+
- `image_extends_wrapper` - Extend images using AI
|
| 336 |
+
- `image_generator_wrapper` - Generate images from text prompts
|
| 337 |
+
|
| 338 |
+
### π MCP Endpoints:
|
| 339 |
+
- **SSE Endpoint**: `https://aigchacker-a1d-mcp-server.hf.space/gradio_api/mcp/sse`
|
| 340 |
+
- **Schema**: `https://aigchacker-a1d-mcp-server.hf.space/gradio_api/mcp/schema`
|
| 341 |
+
""")
|
| 342 |
+
|
| 343 |
# Create Gradio interfaces for each tool
|
| 344 |
+
|
| 345 |
+
|
| 346 |
def create_gradio_app():
|
| 347 |
"""Create the main Gradio application with all tools"""
|
| 348 |
|
| 349 |
+
# Background Removal Interface with MCP docs
|
| 350 |
+
with gr.Blocks(title="π Background Removal") as remove_bg_interface:
|
| 351 |
+
gr.Markdown("# π Background Removal")
|
| 352 |
+
gr.Markdown("Remove background from images using AI")
|
| 353 |
+
|
| 354 |
+
with gr.Row():
|
| 355 |
+
with gr.Column():
|
| 356 |
+
bg_input = gr.Textbox(
|
| 357 |
+
label="Image URL",
|
| 358 |
+
placeholder="https://example.com/image.jpg",
|
| 359 |
+
info="Enter the URL of the image to remove background from"
|
| 360 |
+
)
|
| 361 |
+
bg_button = gr.Button("Remove Background", variant="primary")
|
| 362 |
+
with gr.Column():
|
| 363 |
+
bg_result = gr.Textbox(label="Result")
|
| 364 |
+
bg_preview = gr.Image(label="Preview")
|
| 365 |
+
|
| 366 |
+
bg_button.click(
|
| 367 |
+
fn=remove_bg_wrapper,
|
| 368 |
+
inputs=[bg_input],
|
| 369 |
+
outputs=[bg_result, bg_preview]
|
| 370 |
+
)
|
| 371 |
|
| 372 |
+
# Add MCP documentation
|
| 373 |
+
create_mcp_docs()
|
| 374 |
+
|
| 375 |
+
# Image Upscaler Interface with MCP docs
|
| 376 |
+
with gr.Blocks(title="π Image Upscaler") as image_upscaler_interface:
|
| 377 |
+
gr.Markdown("# π Image Upscaler")
|
| 378 |
+
gr.Markdown("Upscale images using AI with specified scale factor")
|
| 379 |
+
|
| 380 |
+
with gr.Row():
|
| 381 |
+
with gr.Column():
|
| 382 |
+
up_input = gr.Textbox(
|
| 383 |
+
label="Image URL",
|
| 384 |
+
placeholder="https://example.com/image.jpg",
|
| 385 |
+
info="Enter the URL of the image to upscale"
|
| 386 |
+
)
|
| 387 |
+
up_scale = gr.Dropdown(
|
| 388 |
+
choices=[2, 4, 8, 16],
|
| 389 |
+
value=2,
|
| 390 |
+
label="Scale Factor",
|
| 391 |
+
info="Choose the upscaling factor"
|
| 392 |
+
)
|
| 393 |
+
up_button = gr.Button("Upscale Image", variant="primary")
|
| 394 |
+
with gr.Column():
|
| 395 |
+
up_result = gr.Textbox(label="Result")
|
| 396 |
+
up_preview = gr.Image(label="Preview")
|
| 397 |
+
|
| 398 |
+
up_button.click(
|
| 399 |
+
fn=image_upscaler_wrapper,
|
| 400 |
+
inputs=[up_input, up_scale],
|
| 401 |
+
outputs=[up_result, up_preview]
|
| 402 |
+
)
|
| 403 |
|
| 404 |
+
# Add MCP documentation
|
| 405 |
+
create_mcp_docs()
|
| 406 |
+
|
| 407 |
+
# Video Upscaler Interface with MCP docs
|
| 408 |
+
with gr.Blocks(title="π¬ Video Upscaler") as video_upscaler_interface:
|
| 409 |
+
gr.Markdown("# π¬ Video Upscaler")
|
| 410 |
+
gr.Markdown("Upscale videos using AI")
|
| 411 |
+
|
| 412 |
+
with gr.Row():
|
| 413 |
+
with gr.Column():
|
| 414 |
+
vid_input = gr.Textbox(
|
| 415 |
+
label="Video URL",
|
| 416 |
+
placeholder="https://example.com/video.mp4",
|
| 417 |
+
info="Enter the URL of the video to upscale"
|
| 418 |
+
)
|
| 419 |
+
vid_button = gr.Button("Upscale Video", variant="primary")
|
| 420 |
+
with gr.Column():
|
| 421 |
+
vid_result = gr.Textbox(label="Result")
|
| 422 |
+
vid_preview = gr.Video(label="Preview")
|
| 423 |
+
|
| 424 |
+
vid_button.click(
|
| 425 |
+
fn=video_upscaler_wrapper,
|
| 426 |
+
inputs=[vid_input],
|
| 427 |
+
outputs=[vid_result, vid_preview]
|
| 428 |
+
)
|
| 429 |
|
| 430 |
+
# Add MCP documentation
|
| 431 |
+
create_mcp_docs()
|
| 432 |
+
|
| 433 |
+
# Image Vectorization Interface with MCP docs
|
| 434 |
+
with gr.Blocks(title="π Image Vectorization") as image_vectorization_interface:
|
| 435 |
+
gr.Markdown("# π Image Vectorization")
|
| 436 |
+
gr.Markdown("Convert images to vector format using AI")
|
| 437 |
+
|
| 438 |
+
with gr.Row():
|
| 439 |
+
with gr.Column():
|
| 440 |
+
vec_input = gr.Textbox(
|
| 441 |
+
label="Image URL",
|
| 442 |
+
placeholder="https://example.com/image.jpg",
|
| 443 |
+
info="Enter the URL of the image to convert to vector format"
|
| 444 |
+
)
|
| 445 |
+
vec_button = gr.Button("Vectorize Image", variant="primary")
|
| 446 |
+
with gr.Column():
|
| 447 |
+
vec_result = gr.Textbox(label="Result")
|
| 448 |
+
vec_preview = gr.Image(label="Preview")
|
| 449 |
+
|
| 450 |
+
vec_button.click(
|
| 451 |
+
fn=image_vectorization_wrapper,
|
| 452 |
+
inputs=[vec_input],
|
| 453 |
+
outputs=[vec_result, vec_preview]
|
| 454 |
+
)
|
| 455 |
|
| 456 |
+
# Add MCP documentation
|
| 457 |
+
create_mcp_docs()
|
| 458 |
+
|
| 459 |
+
# Image Extension Interface with MCP docs
|
| 460 |
+
with gr.Blocks(title="πΌοΈ Image Extension") as image_extends_interface:
|
| 461 |
+
gr.Markdown("# πΌοΈ Image Extension")
|
| 462 |
+
gr.Markdown("Extend images using AI")
|
| 463 |
+
|
| 464 |
+
with gr.Row():
|
| 465 |
+
with gr.Column():
|
| 466 |
+
ext_input = gr.Textbox(
|
| 467 |
+
label="Image URL",
|
| 468 |
+
placeholder="https://example.com/image.jpg",
|
| 469 |
+
info="Enter the URL of the image to extend"
|
| 470 |
+
)
|
| 471 |
+
ext_button = gr.Button("Extend Image", variant="primary")
|
| 472 |
+
with gr.Column():
|
| 473 |
+
ext_result = gr.Textbox(label="Result")
|
| 474 |
+
ext_preview = gr.Image(label="Preview")
|
| 475 |
+
|
| 476 |
+
ext_button.click(
|
| 477 |
+
fn=image_extends_wrapper,
|
| 478 |
+
inputs=[ext_input],
|
| 479 |
+
outputs=[ext_result, ext_preview]
|
| 480 |
+
)
|
| 481 |
|
| 482 |
+
# Add MCP documentation
|
| 483 |
+
create_mcp_docs()
|
| 484 |
+
|
| 485 |
+
# Image Generator Interface with MCP docs
|
| 486 |
+
with gr.Blocks(title="π¨ Image Generator") as image_generator_interface:
|
| 487 |
+
gr.Markdown("# π¨ Image Generator")
|
| 488 |
+
gr.Markdown("Generate images using AI from text prompts")
|
| 489 |
+
|
| 490 |
+
with gr.Row():
|
| 491 |
+
with gr.Column():
|
| 492 |
+
gen_input = gr.Textbox(
|
| 493 |
+
label="Text Prompt",
|
| 494 |
+
placeholder="A beautiful sunset over mountains",
|
| 495 |
+
info="Enter a text description to generate an image",
|
| 496 |
+
lines=3
|
| 497 |
+
)
|
| 498 |
+
gen_button = gr.Button("Generate Image", variant="primary")
|
| 499 |
+
with gr.Column():
|
| 500 |
+
gen_result = gr.Textbox(label="Result")
|
| 501 |
+
gen_preview = gr.Image(label="Preview")
|
| 502 |
+
|
| 503 |
+
gen_button.click(
|
| 504 |
+
fn=image_generator_wrapper,
|
| 505 |
+
inputs=[gen_input],
|
| 506 |
+
outputs=[gen_result, gen_preview]
|
| 507 |
+
)
|
| 508 |
+
|
| 509 |
+
# Add MCP documentation
|
| 510 |
+
create_mcp_docs()
|
| 511 |
|
| 512 |
# Create tabbed interface
|
| 513 |
demo = gr.TabbedInterface(
|