yuxh1996 commited on
Commit
f4114e2
Β·
1 Parent(s): 0466140

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

Files changed (1) hide show
  1. app.py +209 -104
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
- # Create individual interfaces for each tool
298
- remove_bg_interface = gr.Interface(
299
- fn=remove_bg_wrapper,
300
- inputs=[
301
- gr.Textbox(
302
- label="Image URL",
303
- placeholder="https://example.com/image.jpg",
304
- info="Enter the URL of the image to remove background from"
305
- )
306
- ],
307
- outputs=[
308
- gr.Textbox(label="Result"),
309
- gr.Image(label="Preview")
310
- ],
311
- title="🎭 Background Removal",
312
- description="Remove background from images using AI"
313
- )
 
 
 
 
 
314
 
315
- image_upscaler_interface = gr.Interface(
316
- fn=image_upscaler_wrapper,
317
- inputs=[
318
- gr.Textbox(
319
- label="Image URL",
320
- placeholder="https://example.com/image.jpg",
321
- info="Enter the URL of the image to upscale"
322
- ),
323
- gr.Dropdown(
324
- choices=[2, 4, 8, 16],
325
- value=2,
326
- label="Scale Factor",
327
- info="Choose the upscaling factor"
328
- )
329
- ],
330
- outputs=[
331
- gr.Textbox(label="Result"),
332
- gr.Image(label="Preview")
333
- ],
334
- title="πŸ” Image Upscaler",
335
- description="Upscale images using AI with specified scale factor"
336
- )
 
 
 
 
 
 
 
 
 
337
 
338
- video_upscaler_interface = gr.Interface(
339
- fn=video_upscaler_wrapper,
340
- inputs=[
341
- gr.Textbox(
342
- label="Video URL",
343
- placeholder="https://example.com/video.mp4",
344
- info="Enter the URL of the video to upscale"
345
- )
346
- ],
347
- outputs=[
348
- gr.Textbox(label="Result"),
349
- gr.Video(label="Preview")
350
- ],
351
- title="🎬 Video Upscaler",
352
- description="Upscale videos using AI"
353
- )
 
 
 
 
 
 
 
 
 
354
 
355
- image_vectorization_interface = gr.Interface(
356
- fn=image_vectorization_wrapper,
357
- inputs=[
358
- gr.Textbox(
359
- label="Image URL",
360
- placeholder="https://example.com/image.jpg",
361
- info="Enter the URL of the image to convert to vector format"
362
- )
363
- ],
364
- outputs=[
365
- gr.Textbox(label="Result"),
366
- gr.Image(label="Preview")
367
- ],
368
- title="πŸ“ Image Vectorization",
369
- description="Convert images to vector format using AI"
370
- )
 
 
 
 
 
 
 
 
 
371
 
372
- image_extends_interface = gr.Interface(
373
- fn=image_extends_wrapper,
374
- inputs=[
375
- gr.Textbox(
376
- label="Image URL",
377
- placeholder="https://example.com/image.jpg",
378
- info="Enter the URL of the image to extend"
379
- )
380
- ],
381
- outputs=[
382
- gr.Textbox(label="Result"),
383
- gr.Image(label="Preview")
384
- ],
385
- title="πŸ–ΌοΈ Image Extension",
386
- description="Extend images using AI"
387
- )
 
 
 
 
 
 
 
 
 
388
 
389
- image_generator_interface = gr.Interface(
390
- fn=image_generator_wrapper,
391
- inputs=[
392
- gr.Textbox(
393
- label="Text Prompt",
394
- placeholder="A beautiful sunset over mountains",
395
- info="Enter a text description to generate an image",
396
- lines=3
397
- )
398
- ],
399
- outputs=[
400
- gr.Textbox(label="Result"),
401
- gr.Image(label="Preview")
402
- ],
403
- title="🎨 Image Generator",
404
- description="Generate images using AI from text prompts"
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(