a1d-mcp-server / README.md
yuxh1996's picture
Implement official Gradio MCP server
d45a618
|
raw
history blame
8.3 kB
metadata
title: A1d Mcp Server
emoji: πŸ€–
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.33.0
app_file: official_app.py
pinned: false
license: mit
tags:
  - mcp-server-track

A1D MCP Server - Universal AI Tools

A powerful MCP (Model Context Protocol) server built with Gradio that provides AI image and video processing tools for any MCP-compatible client. This server implements the same tools as the original A1D MCP Server but uses Gradio for easy deployment and hosting.

πŸŽ₯ Demo

MCP Server in Action: View Demo Recording

The demo shows the A1D MCP Server working with Claude Desktop and other MCP clients, featuring real-time AI image processing, seamless integration, and live preview of results.

πŸ€– Available AI Tools

Tool Description Use Cases
remove_bg AI background removal Remove backgrounds from photos, product images
image_upscaler AI image enhancement Upscale images 2x, 4x, 8x, 16x resolution
video_upscaler AI video enhancement Improve video quality and resolution
image_vectorization Convert to vectors Turn images into scalable SVG graphics
image_extends Smart image extension Expand image boundaries intelligently
image_generator Text-to-image AI Generate images from text descriptions

πŸš€ Quick Setup

1. Get Your API Key

2. Set Environment Variable

export A1D_API_KEY=your_api_key_here

3. Install Dependencies

pip install -r requirements.txt

4. Run the Server

Option 1: Using the startup script (Recommended)

python start_server.py

Option 2: Direct execution

python app.py

Option 3: Using virtual environment

source venv/bin/activate  # On Windows: venv\Scripts\activate
python start_server.py

The server will start on http://localhost:7860 with MCP server enabled.

5. Test the Installation

python test_app.py

This will run a comprehensive test suite to verify everything is working correctly.

πŸ”§ MCP Server Features

This Gradio app serves as both a web interface and a full MCP server, providing:

βœ… Dual Interface Support

  • Web UI: Interactive Gradio interface at http://localhost:7860
  • MCP Server: Protocol-compliant server at http://localhost:7860/gradio_api/mcp/sse

βœ… Real-time Processing

  • Async Task Handling: Uses SSE for real-time status updates
  • Live Preview: Immediate media preview in both web and MCP clients
  • Progress Tracking: Detailed logs of API calls and processing status

βœ… Production Ready

  • Error Handling: Comprehensive error management and user feedback
  • API Integration: Direct integration with A1D.ai services
  • Scalable: Can handle multiple concurrent requests

πŸ”§ MCP Client Configuration

Method 1: With API Key in Headers (Recommended)

Add this to your Claude Desktop configuration file:

{
  "mcpServers": {
    "a1d": {
      "command": "npx",
      "args": [
        "mcp-remote@latest",
        "http://localhost:7860/gradio_api/mcp/sse",
        "--header",
        "API_KEY:${MCP_API_KEY}"
      ],
      "env": {
        "MCP_API_KEY": "your_a1d_api_key_here"
      }
    }
  }
}

Method 2: With Environment Variable (Fallback)

{
  "mcpServers": {
    "a1d-gradio": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://localhost:7860/gradio_api/mcp/sse"
      ]
    }
  }
}

Note: Requires A1D_API_KEY environment variable to be set.

For Other MCP Clients

  • Server URL: http://localhost:7860/gradio_api/mcp/sse
  • Transport Type: SSE (Server-Sent Events)
  • Protocol: MCP 1.0 compatible
  • Authentication: API key via API_KEY header or environment variable

Configuration File Locations

Windows: %APPDATA%\Claude\claude_desktop_config.json macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Linux: ~/.config/Claude/claude_desktop_config.json

🌐 Hosted Version

This server is also available as a hosted Hugging Face Space:

πŸ”§ Environment Variables for Hugging Face Space

To deploy this on your own Hugging Face Space:

  1. Fork or duplicate this Space
  2. Go to Settings β†’ Variables and secrets
  3. Add the following environment variable:
    • Name: A1D_API_KEY
    • Value: Your A1D API key from A1D.ai
    • Type: Secret (recommended for security)
  4. Save and restart the Space

πŸ”— MCP Client Configuration for Hosted Version

Method 1: With API Key in Headers (Recommended)

{
  "mcpServers": {
    "a1d-hosted": {
      "command": "npx",
      "args": [
        "mcp-remote@latest",
        "https://aigchacker-a1d-mcp-server.hf.space/gradio_api/mcp/sse",
        "--header",
        "API_KEY:${MCP_API_KEY}"
      ],
      "env": {
        "MCP_API_KEY": "your_a1d_api_key_here"
      }
    }
  }
}

Method 2: Environment Variable (if Space has API key configured)

{
  "mcpServers": {
    "a1d-hosted": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://aigchacker-a1d-mcp-server.hf.space/gradio_api/mcp/sse"
      ]
    }
  }
}

πŸ’‘ How to Use

Once configured, simply ask your AI assistant to help with image or video tasks:

πŸ› οΈ Development

Local Development

git clone https://github.com/your-repo/a1d-mcp-server-hf.git
cd a1d-mcp-server-hf
pip install -r requirements.txt
export A1D_API_KEY=your_api_key_here
python app.py

Project Structure

a1d-mcp-server-hf/
β”œβ”€β”€ app.py              # Main Gradio application
β”œβ”€β”€ config.py           # Configuration settings
β”œβ”€β”€ utils.py            # Utility functions and API client
β”œβ”€β”€ mcp_handler.py      # MCP request handler with header-based API keys
β”œβ”€β”€ start_server.py     # Server startup script
β”œβ”€β”€ test_app.py         # Test suite
β”œβ”€β”€ requirements.txt    # Python dependencies
β”œβ”€β”€ .env.example        # Environment variables example
β”œβ”€β”€ .gitignore          # Git ignore file
β”œβ”€β”€ LICENSE             # MIT license
└── README.md          # This file

πŸ” Security

  • User-provided credentials: This server supports multiple API key methods:
    • Header-based: API keys passed via MCP client headers (recommended)
    • Environment variables: Server-side API key configuration
  • No stored secrets: All API keys are handled per-request, nothing is stored server-side
  • Multi-user support: Each user can use their own API key via headers
  • HTTPS recommended: Use HTTPS in production environments

🀝 Contributing

We welcome contributions! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Follow the existing code style
  4. Add tests for new features
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ”— Related Projects


Built with ❀️ by the A1D Team A1D.ai β€’ GitHub β€’ API Docs