File size: 6,150 Bytes
5849687
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Recovery Compass MCP Hub - Complete Setup Guide

## 🎯 Overview

This guide will help you set up the Recovery Compass MCP Hub with full Hugging Face integration, OAuth login, and MCP server capabilities.

## πŸ“‹ Prerequisites

- Python 3.9+
- Git
- Hugging Face account
- Hugging Face access token (with read/write permissions)

## πŸš€ Quick Setup

### 1. Clone the Repository

```bash
git clone https://huggingface.co/spaces/Recovery-Compass-79/README recovery-compass-space
cd recovery-compass-space
```

### 2. Run Setup Script

```bash
chmod +x setup.sh
./setup.sh
```

### 3. Configure Environment

Edit `.env` file with your credentials:

```bash
HF_TOKEN=your_token_here
OAUTH_CLIENT_SECRET=your_secret_here
```

### 4. Test Locally

```bash
uvicorn app:app --host 0.0.0.0 --port 7860
```

Visit: http://localhost:7860

### 5. Deploy to Hugging Face

```bash
git add .
git commit -m "Configure deployment"
git push
```

## πŸ”Œ MCP Integration Setup

### Connect to Hugging Face MCP Server

1. **OAuth Authentication**
   - Visit: https://huggingface.co/mcp?login
   - Authorize the application
   - Token will be stored automatically

2. **Configure MCP Client**

Add to your MCP client configuration (e.g., Claude Desktop):

```json
{
  "mcpServers": {
    "huggingface": {
      "url": "https://huggingface.co/mcp",
      "oauth": true
    },
    "recovery-compass": {
      "url": "https://huggingface.co/spaces/Recovery-Compass-79/README",
      "oauth": true
    }
  }
}
```

### Available MCP Tools

1. **Spaces Semantic Search**
   - Find AI Apps via natural language
   - Example: "Find mental health support spaces"

2. **Papers Semantic Search**
   - Search ML research papers
   - Example: "Papers about recovery prediction models"

3. **Model Search**
   - Find ML models with filters
   - Example: "Find sentiment analysis models"

4. **Dataset Search**
   - Search datasets
   - Example: "Mental health conversation datasets"

5. **Documentation Search**
   - Search HF documentation
   - Example: "How to fine-tune a model"

6. **Hub Repository Details**
   - Get info about repos
   - Include README files

## πŸ”— Connect Valuable Apps

### Recommended Spaces to Connect

1. **evalstate/flux1_schnell** - Fast image generation
2. **Mental Health Support Spaces** - Crisis counseling
3. **Wellness Tracking** - Progress monitoring
4. **Mindfulness Tools** - Meditation guidance

### How to Connect Apps

1. Visit: https://huggingface.co/settings/connected-applications
2. Authorize each app
3. Grant appropriate permissions:
   - Public profile (always)
   - View repo contents (for integration)
   - Edit repo contents (if needed)
   - List MCP tools (for MCP access)

### Currently Connected Apps

Based on your setup:
- βœ… Claude (MCP tools + repo access)
- βœ… DeepSite (repo management)

## πŸ“± API Endpoints

### Health Check
```bash
curl https://Recovery-Compass-79-README.hf.space/health
```

### Search Resources
```bash
curl "https://Recovery-Compass-79-README.hf.space/api/search?query=recovery"
```

### List Models
```bash
curl "https://Recovery-Compass-79-README.hf.space/api/models?task=text-generation&limit=5"
```

### List Datasets
```bash
curl "https://Recovery-Compass-79-README.hf.space/api/datasets?task=text-classification&limit=5"
```

### AI Chat
```bash
curl -X POST https://Recovery-Compass-79-README.hf.space/api/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "I need support today"}'
```

### List Recovery Spaces
```bash
curl https://Recovery-Compass-79-README.hf.space/api/spaces
```

## πŸ” OAuth Configuration

### Set Up OAuth App

1. Go to: https://huggingface.co/settings/applications
2. Create new OAuth application
3. Set redirect URI: `https://huggingface.co/spaces/Recovery-Compass-79/README/callback`
4. Get client ID and secret
5. Add to `.env` file

### Required Scopes

- `profile` - User profile information
- `read` - Read access to repos
- `write` - Write access for data storage
- `mcp` - MCP tools access

## πŸ› οΈ Advanced Configuration

### Enable All MCP Tools

Edit `mcp-config.json` to enable/disable tools:

```json
{
  "capabilities": {
    "semantic_search": { "enabled": true },
    "model_inference": { "enabled": true },
    "dataset_access": { "enabled": true },
    "space_integration": { "enabled": true },
    "progress_tracking": { "enabled": true }
  }
}
```

### Add Custom Spaces

Add recommended spaces in `mcp-config.json`:

```json
{
  "integration": {
    "recommended_spaces": [
      "your-space-1",
      "your-space-2"
    ]
  }
}
```

## πŸ§ͺ Testing

### Local Testing

```bash
# Test health endpoint
curl http://localhost:7860/health

# Test MCP info
curl http://localhost:7860/mcp

# Test search
curl "http://localhost:7860/api/search?query=test"
```

### Production Testing

Replace `localhost:7860` with `Recovery-Compass-79-README.hf.space`

## πŸ“Š Monitoring

### Check Space Status

Visit: https://huggingface.co/spaces/Recovery-Compass-79/README/logs

### API Usage

Monitor requests through FastAPI docs:
https://Recovery-Compass-79-README.hf.space/docs

## πŸ”§ Troubleshooting

### OAuth Issues
- Verify redirect URI matches exactly
- Check token permissions
- Ensure client secret is correct

### MCP Connection Issues
- Confirm OAuth is completed
- Check MCP client configuration
- Verify Space is running

### API Errors
- Check Space logs
- Verify HF token is valid
- Test endpoints locally first

## πŸ“š Resources

- [Hugging Face MCP Server](https://huggingface.co/mcp)
- [OAuth Documentation](https://huggingface.co/docs/hub/oauth)
- [Spaces Documentation](https://huggingface.co/docs/hub/spaces)
- [FastAPI Documentation](https://fastapi.tiangolo.com/)
- [MCP Protocol](https://modelcontextprotocol.io/)

## 🀝 Support

For issues or questions:
- GitHub Issues: [Create an issue]
- Hugging Face Discussions: [Community forum]
- Email: support@recoverycompass.example

## πŸŽ‰ Next Steps

1. βœ… Complete OAuth setup
2. βœ… Connect recommended apps
3. βœ… Test all API endpoints
4. βœ… Configure MCP client
5. βœ… Start using with AI assistants!

---

Built with ❀️ for the recovery community