File size: 8,009 Bytes
9434d3d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
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
# 🚀 Deployment Guide

This guide covers deploying the EU AI Act Compliance Suite for the MCP 1st Birthday Hackathon.

## 📋 Table of Contents

- [Deployment Options](#deployment-options)
- [Hugging Face Spaces (Recommended)](#hugging-face-spaces-recommended)
- [Manual Deployment](#manual-deployment)
- [GitHub Actions CI/CD](#github-actions-cicd)
- [Environment Variables](#environment-variables)
- [Hackathon Submission Checklist](#hackathon-submission-checklist)

---

## 🎯 Deployment Options

| Option | Best For | Difficulty |
|--------|----------|------------|
| **Hugging Face Spaces** | Hackathon submission, public demos | ⭐ Easy |
| **Docker** | Self-hosted, production | ⭐⭐ Medium |
| **Local Development** | Testing, development | ⭐ Easy |

---

## 🤗 Hugging Face Spaces (Recommended)

The easiest way to deploy for the hackathon is using **Hugging Face Spaces**.

### Method 1: Automated Deployment (GitHub Actions)

1. **Fork this repository** to your GitHub account

2. **Add GitHub Secrets:**
   - Go to your repo → Settings → Secrets and variables → Actions
   - Add `HF_TOKEN`: Your Hugging Face token with write access
   
   ```bash
   # Get your HF token from: https://huggingface.co/settings/tokens
   # Required scopes: write access to spaces
   ```

3. **Join the Hackathon Organization:**
   - Go to [MCP-1st-Birthday](https://huggingface.co/MCP-1st-Birthday)
   - Click "Request to join this org"
   - Wait for approval

4. **Trigger Deployment:**
   - Push to `main` branch (auto-deploys on changes to `spaces/` directory)
   - Or manually trigger via GitHub Actions → "Deploy to Hugging Face Spaces" → "Run workflow"

5. **Configure Space Secrets:**
   - Go to your Space settings: `https://huggingface.co/spaces/MCP-1st-Birthday/eu-ai-act-compliance/settings`
   - Add secrets:
     - `XAI_API_KEY` (required) - Get from [x.ai](https://x.ai/)
     - `TAVILY_API_KEY` (optional) - Get from [tavily.com](https://app.tavily.com/)

### Method 2: Manual Upload

1. **Create a new Space:**
   ```bash
   # Install huggingface_hub
   pip install huggingface_hub
   
   # Login
   huggingface-cli login
   
   # Create space
   huggingface-cli repo create eu-ai-act-compliance --type space --space-sdk gradio
   ```

2. **Upload files:**
   ```bash
   cd spaces/eu-ai-act-compliance
   
   # Clone the space
   git clone https://huggingface.co/spaces/YOUR_USERNAME/eu-ai-act-compliance
   
   # Copy files
   cp -r . eu-ai-act-compliance/
   
   # Push
   cd eu-ai-act-compliance
   git add .
   git commit -m "Initial deployment"
   git push
   ```

3. **Transfer to hackathon org** (for submission):
   - Go to Space Settings → Transfer
   - Transfer to `MCP-1st-Birthday` organization

### Method 3: Using the Deploy Script

```bash
# Run the deployment script
./scripts/deploy-hf.sh

# With custom org/name
./scripts/deploy-hf.sh --org MCP-1st-Birthday --name eu-ai-act-compliance
```

---

## 🐳 Docker Deployment

### Build and Run

```bash
# Build the image
docker build -t eu-ai-act-compliance -f Dockerfile .

# Run with environment variables
docker run -p 7860:7860 \
  -e XAI_API_KEY=your-key \
  -e TAVILY_API_KEY=your-key \
  eu-ai-act-compliance
```

### Docker Compose

```yaml
version: '3.8'
services:
  eu-ai-act-agent:
    build: .
    ports:
      - "7860:7860"
    environment:
      - XAI_API_KEY=${XAI_API_KEY}
      - TAVILY_API_KEY=${TAVILY_API_KEY}
    restart: unless-stopped
```

---

## 🔧 Manual Deployment

### Prerequisites

- Node.js 18+
- Python 3.9+
- pnpm 8+

### Steps

```bash
# 1. Clone the repository
git clone https://github.com/your-org/eu-ai-act-compliance.git
cd eu-ai-act-compliance

# 2. Install dependencies
pnpm install

# 3. Set up environment variables
cp .env.example .env
# Edit .env and add your API keys

# 4. Build the MCP server
pnpm --filter @eu-ai-act/mcp-server build

# 5. Start the agent (API + Gradio)
cd apps/eu-ai-act-agent
./start.sh
```

### Production Mode

```bash
# Build everything
pnpm build

# Start in production
cd apps/eu-ai-act-agent
NODE_ENV=production node dist/server.js &
python src/gradio_app.py
```

---

## 🔄 GitHub Actions CI/CD

### Workflows

| Workflow | Trigger | Purpose |
|----------|---------|---------|
| `ci.yml` | Push/PR | Lint, typecheck, build |
| `deploy-hf-space.yml` | Push to main + `spaces/` changes | Deploy to HF Spaces |

### Required Secrets

| Secret | Required | Description |
|--------|----------|-------------|
| `HF_TOKEN` | Yes | Hugging Face token with write access |

### Manual Deployment Trigger

1. Go to Actions → "Deploy to Hugging Face Spaces"
2. Click "Run workflow"
3. Select branch and environment
4. Click "Run workflow"

---

## 🔐 Environment Variables

### Required

| Variable | Description | Where to Get |
|----------|-------------|--------------|
| `XAI_API_KEY` | xAI API key for Grok model | [console.x.ai](https://console.x.ai/) |

### Optional

| Variable | Description | Where to Get |
|----------|-------------|--------------|
| `TAVILY_API_KEY` | Tavily API for web research | [app.tavily.com](https://app.tavily.com/) |
| `PORT` | API server port (default: 3001) | - |

### Setting Secrets in Hugging Face Spaces

1. Go to your Space: `https://huggingface.co/spaces/ORG/SPACE_NAME`
2. Click ⚙️ Settings
3. Scroll to "Repository secrets"
4. Add each secret:
   - Name: `XAI_API_KEY`
   - Value: Your API key
   - Click "Add"

---

## ✅ Hackathon Submission Checklist

### Before Submission (Nov 30, 2025 11:59 PM UTC)

- [ ] **Join the organization**: [Request to join MCP-1st-Birthday](https://huggingface.co/MCP-1st-Birthday)
- [ ] **Deploy your Space**: Make sure it's running and accessible
- [ ] **Configure secrets**: Add `XAI_API_KEY` (and optionally `TAVILY_API_KEY`)
- [ ] **Test the demo**: Verify all features work

### README Requirements

Your Space README must include:

- [ ] **Hackathon tags** in frontmatter:
  ```yaml
  tags:
    - mcp
    - agents
    - track-1-mcp-servers
    - track-2-agentic-applications
  ```

- [ ] **Social media link**: Share your project and include the link
  ```markdown
  [🐦 Twitter Post](https://twitter.com/your-post-link)
  ```

### Track Tags

| Track | Tags |
|-------|------|
| Track 1: Building MCP | `track-1-mcp-servers`, `mcp` |
| Track 2: MCP in Action | `track-2-agentic-applications`, `agents` |

### Social Media Post Template

```
🇪🇺 Excited to share my #MCPHackathon submission!

EU AI Act Compliance Agent - AI-powered compliance assessment with MCP tools

✅ Discover organization profiles
✅ Classify AI systems by risk
✅ Generate compliance documentation

Try it: [HF Space Link]

#MCP #AIAct #Gradio @huggingface
```

---

## 🔍 Troubleshooting

### Space Not Building

1. Check `requirements.txt` for valid packages
2. Verify Python version compatibility
3. Check build logs in Space settings

### API Key Errors

1. Verify secrets are set in Space settings
2. Check secret names match exactly (case-sensitive)
3. Ensure API keys are valid and have required permissions

### Deployment Failing

1. Check GitHub Actions logs
2. Verify `HF_TOKEN` has write access
3. Ensure you're a member of the target organization

### Space Sleeping

Free HF Spaces sleep after inactivity. To wake:
1. Visit the Space URL
2. Wait for it to build/start
3. Consider upgrading for persistent uptime

---

## 📞 Support

- **Hackathon Discord**: [#agents-mcp-hackathon-winter25🏆](https://discord.gg/huggingface)
- **GitHub Issues**: [Create an issue](https://github.com/your-org/eu-ai-act-compliance/issues)
- **Email**: gradio-team@huggingface.co

---

## 📚 Additional Resources

- [Hugging Face Spaces Documentation](https://huggingface.co/docs/hub/spaces)
- [Gradio Deployment Guide](https://www.gradio.app/guides/sharing-your-app)
- [MCP Course](https://huggingface.co/learn/mcp-course)
- [Hackathon Page](https://huggingface.co/MCP-1st-Birthday)

---

<div align="center">

**Good luck with your submission! 🎂**

</div>