Spaces:
Running
Running
File size: 8,379 Bytes
aaa3e82 d45a618 0466140 aaa3e82 afb386c aaa3e82 afb386c aaa3e82 afb386c aaa3e82 afb386c aaa3e82 afb386c aaa3e82 afb386c aaa3e82 565a26a aaa3e82 |
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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
---
title: A1d Mcp Server
emoji: π€
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.33.0
app_file: 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](https://github.com/AIGC-Hackers/mcp-server) but uses Gradio for easy deployment and hosting.
## π₯ Demo
**MCP Server in Action**: [View Demo Recording](https://huggingface.co/spaces/aigchacker/a1d-mcp-server)
*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
- Visit [A1D.ai](https://a1d.ai/home/api) to get your free API key
- Optional: [Purchase credits](https://a1d.ai/pricing) for extended usage
### 2. Set Environment Variable
```bash
export A1D_API_KEY=your_api_key_here
```
### 3. Install Dependencies
```bash
pip install -r requirements.txt
```
### 4. Run the Server
**Option 1: Using the startup script (Recommended)**
```bash
python start_server.py
```
**Option 2: Direct execution**
```bash
python app.py
```
**Option 3: Using virtual environment**
```bash
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
```bash
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
### β οΈ API Key Required for Client Usage
When using with your own MCP client (Claude Desktop, Cursor, etc.), you **must** provide your API key:
```json
{
"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"
}
}
}
}
```
**π API key is mandatory for client usage.** Get your API key at [A1D.ai](https://a1d.ai/home/api).
### 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:
- **Space URL:** [https://huggingface.co/spaces/aigchacker/a1d-mcp-server](https://huggingface.co/spaces/aigchacker/a1d-mcp-server)
- **MCP Endpoint:** `https://aigchacker-a1d-mcp-server.hf.space/gradio_api/mcp/sse`
### π§ 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](https://a1d.ai/home/api)
- **Type**: Secret (recommended for security)
4. **Save and restart the Space**
### π MCP Client Configuration for Hosted Version
#### β οΈ API Key Required for Client Usage
When using with your own MCP client (Claude Desktop, Cursor, etc.), you **must** provide your API key:
```json
{
"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"
}
}
}
}
```
**π API key is mandatory for client usage.** Get your API key at [A1D.ai](https://a1d.ai/home/api).
#### π Using the Hosted Demo on Hugging Face Space
The hosted demo at [https://huggingface.co/spaces/aigchacker/a1d-mcp-server](https://huggingface.co/spaces/aigchacker/a1d-mcp-server) uses our provided API key for demonstration purposes only, with limited usage. For production use, please obtain your own API key.
## π‘ How to Use
Once configured, simply ask your AI assistant to help with image or video tasks:
- *"Remove the background from this image: https://example.com/photo.jpg"*
- *"Upscale this image to 4x resolution: https://example.com/image.png"*
- *"Convert this photo to a vector graphic: https://example.com/logo.jpg"*
- *"Generate an image of a sunset over mountains"*
## π οΈ Development
### Local Development
```bash
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](LICENSE) file for details.
## π Related Projects
- **Original MCP Server:** [AIGC-Hackers/mcp-server](https://github.com/AIGC-Hackers/mcp-server)
- **A1D API Documentation:** [A1D.ai API Docs](https://a1d.ai/api/quick-start)
- **Gradio MCP Guide:** [Building MCP Server with Gradio](https://www.gradio.app/guides/building-mcp-server-with-gradio)
---
**Built with β€οΈ by the A1D Team**
[A1D.ai](https://a1d.ai) β’ [GitHub](https://github.com/AIGC-Hackers) β’ [API Docs](https://a1d.ai/api/quick-start)
|