Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	File size: 10,788 Bytes
			
			| 03687eb 6cca3b1 03687eb 6cca3b1 03687eb 6cca3b1 03687eb 6cca3b1 03687eb 6cca3b1 03687eb 6cca3b1 03687eb 6cca3b1 03687eb 6cca3b1 03687eb 6cca3b1 03687eb 6cca3b1 03687eb 6cca3b1 03687eb 6cca3b1 03687eb 6cca3b1 03687eb | 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 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | # DeepSite MCP Server
DeepSite is now available as an MCP (Model Context Protocol) server, enabling AI assistants like Claude to create websites directly using natural language.
## Two Ways to Use DeepSite MCP
**Quick Comparison:**
| Feature | Option 1: HTTP Server | Option 2: Local Server |
|---------|----------------------|------------------------|
| **Setup Difficulty** | β
 Easy (just config) | β οΈ Requires installation |
| **Authentication** | HF Token in config header | HF Token or session cookie in env |
| **Best For** | Most users | Developers, custom modifications |
| **Maintenance** | β
 Always up-to-date | Need to rebuild for updates |
**Recommendation:** Use Option 1 (HTTP Server) unless you need to modify the MCP server code.
---
### π Option 1: HTTP Server (Recommended)
**No installation required!** Use DeepSite's hosted MCP server.
#### Setup for Claude Desktop
Add to your Claude Desktop configuration file:
**MacOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`  
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
```json
{
  "mcpServers": {
    "deepsite": {
      "url": "https://huggingface.co/deepsite/api/mcp",
      "transport": {
        "type": "sse"
      },
      "headers": {
        "Authorization": "Bearer hf_your_token_here"
      }
    }
  }
}
```
**Getting Your Hugging Face Token:**
1. Go to https://huggingface.co/settings/tokens
2. Create a new token with `write` access
3. Copy the token
4. Add it to the `Authorization` header in your config (recommended for security)
5. Alternatively, you can pass it as the `hf_token` parameter when using the tool
**β οΈ Security Recommendation:** Use the `Authorization` header in your config instead of passing the token in chat. This keeps your token secure and out of conversation history.
#### Example Usage with Claude
> "Create a portfolio website using DeepSite. Include a hero section, about section, and contact form."
Claude will automatically:
1. Use the `create_project` tool
2. Authenticate using the token from your config
3. Create the website on Hugging Face Spaces
4. Return the URLs to access your new site
---
### π» Option 2: Local Server
Run the MCP server locally for more control or offline use.
> **Note:** Most users should use Option 1 (HTTP Server) instead. Option 2 is only needed if you want to run the MCP server locally or modify its behavior.
#### Installation
```bash
cd mcp-server
npm install
npm run build
```
#### Setup for Claude Desktop
**Method A: Using HF Token (Recommended)**
```json
{
  "mcpServers": {
    "deepsite-local": {
      "command": "node",
      "args": ["/absolute/path/to/deepsite-v3/mcp-server/dist/index.js"],
      "env": {
        "HF_TOKEN": "hf_your_token_here",
        "DEEPSITE_API_URL": "https://huggingface.co/deepsite"
      }
    }
  }
}
```
**Method B: Using Session Cookie (Alternative)**
```json
{
  "mcpServers": {
    "deepsite-local": {
      "command": "node",
      "args": ["/absolute/path/to/deepsite-v3/mcp-server/dist/index.js"],
      "env": {
        "DEEPSITE_AUTH_COOKIE": "your-session-cookie",
        "DEEPSITE_API_URL": "https://huggingface.co/deepsite"
      }
    }
  }
}
```
**Getting Your Session Cookie (Method B only):**
1. Log in to https://huggingface.co/deepsite
2. Open Developer Tools (F12)
3. Go to Application β Cookies
4. Copy the session cookie value
5. Set as `DEEPSITE_AUTH_COOKIE` in the config
---
## Available Tools
### `create_project`
Creates a new DeepSite project with HTML/CSS/JS files.
**Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `title` | string | No | Project title (defaults to "DeepSite Project") |
| `pages` | array | Yes | Array of file objects with `path` and `html` |
| `prompt` | string | No | Commit message/description |
| `hf_token` | string | No* | Hugging Face API token (*optional if provided via Authorization header in config) |
**Page Object:**
```typescript
{
  path: string;  // e.g., "index.html", "styles.css", "script.js"
  html: string;  // File content
}
```
**Returns:**
```json
{
  "success": true,
  "message": "Project created successfully!",
  "projectUrl": "https://huggingface.co/deepsite/username/project-name",
  "spaceUrl": "https://huggingface.co/spaces/username/project-name",
  "liveUrl": "https://username-project-name.hf.space",
  "spaceId": "username/project-name",
  "projectId": "space-id",
  "files": ["index.html", "styles.css"]
}
```
---
## Example Prompts for Claude
### Simple Landing Page
> "Create a modern landing page for my SaaS product using DeepSite. Include a hero section with CTA, features grid, and footer. Use gradient background."
### Portfolio Website
> "Build a portfolio website with DeepSite. I need:
> - Hero section with my name and photo
> - Projects gallery with 3 sample projects
> - Skills section with tech stack
> - Contact form
> Use dark mode with accent colors."
### Blog Homepage
> "Create a blog homepage using DeepSite. Include:
> - Header with navigation
> - Featured post section
> - Grid of recent posts (3 cards)
> - Sidebar with categories
> - Footer with social links
> Clean, minimal design."
### Interactive Dashboard
> "Make an analytics dashboard with DeepSite:
> - Sidebar navigation
> - 4 metric cards at top
> - 2 chart placeholders
> - Data table
> - Modern, professional UI with charts.css"
---
## Direct API Usage
You can also call the HTTP endpoint directly:
### Using Authorization Header (Recommended)
```bash
curl -X POST https://huggingface.co/deepsite/api/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer hf_your_token_here" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "create_project",
      "arguments": {
        "title": "My Website",
        "pages": [
          {
            "path": "index.html",
            "html": "<!DOCTYPE html><html><head><title>Hello</title></head><body><h1>Hello World!</h1></body></html>"
          }
        ]
      }
    }
  }'
```
### Using Token Parameter (Fallback)
```bash
curl -X POST https://huggingface.co/deepsite/api/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "create_project",
      "arguments": {
        "title": "My Website",
        "pages": [
          {
            "path": "index.html",
            "html": "<!DOCTYPE html><html><head><title>Hello</title></head><body><h1>Hello World!</h1></body></html>"
          }
        ],
        "hf_token": "hf_xxxxx"
      }
    }
  }'
```
### List Available Tools
```bash
curl -X POST https://huggingface.co/deepsite/api/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/list",
    "params": {}
  }'
```
---
## Testing
### Test Local Server
```bash
cd mcp-server
./test.sh
```
### Test HTTP Server
```bash
curl -X POST https://huggingface.co/deepsite/api/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
```
---
## Migration Guide: From Parameter to Header Auth
If you're currently passing the token as a parameter in your prompts, here's how to migrate to the more secure header-based authentication:
### Step 1: Update Your Config
Edit your Claude Desktop config file and add the `headers` section:
```json
{
  "mcpServers": {
    "deepsite": {
      "url": "https://huggingface.co/deepsite/api/mcp",
      "transport": {
        "type": "sse"
      },
      "headers": {
        "Authorization": "Bearer hf_your_actual_token_here"
      }
    }
  }
}
```
### Step 2: Restart Claude Desktop
Completely quit and restart Claude Desktop for the changes to take effect.
### Step 3: Use Simpler Prompts
Now you can simply say:
> "Create a portfolio website with DeepSite"
Instead of:
> "Create a portfolio website with DeepSite using token `hf_xxxxx`"
Your token is automatically included in all requests via the header!
---
## Security Notes
### HTTP Server (Option 1)
- **β
 Recommended:** Store your HF token in the `Authorization` header in your Claude Desktop config
- The token is stored locally on your machine and never exposed in chat
- The token is sent with each request but only used to authenticate with Hugging Face API
- DeepSite does not store your token
- Use tokens with minimal required permissions (write access to spaces)
- You can revoke tokens anytime at https://huggingface.co/settings/tokens
- **β οΈ Fallback:** You can still pass the token as a parameter, but this is less secure as it appears in conversation history
### Local Server (Option 2)
- Use `HF_TOKEN` environment variable (same security as Option 1)
- Or use `DEEPSITE_AUTH_COOKIE` if you prefer session-based auth
- All authentication data stays on your local machine
- Better for development and testing
- No need for both HTTP Server and Local Server - choose one!
---
## Troubleshooting
### "Invalid Hugging Face token"
- Verify your token at https://huggingface.co/settings/tokens
- Ensure the token has write permissions
- Check that you copied the full token (starts with `hf_`)
### "At least one page is required"
- Make sure you're providing the `pages` array
- Each page must have both `path` and `html` properties
### "Failed to create project"
- Check your token permissions
- Ensure the project title doesn't conflict with existing spaces
- Verify your Hugging Face account is in good standing
### Claude doesn't see the tool
- Restart Claude Desktop after modifying the config
- Check that the JSON config is valid (no trailing commas)
- For HTTP: verify the URL is correct
- For local: check the absolute path to index.js
---
## Architecture
### HTTP Server Flow
```
Claude Desktop
      β
 (HTTP Request)
      β
huggingface.co/deepsite/api/mcp
      β
Hugging Face API (with user's token)
      β
New Space Created
      β
URLs returned to Claude
```
### Local Server Flow
```
Claude Desktop
      β
 (stdio transport)
      β
Local MCP Server
      β
 (HTTP to DeepSite API)
      β
huggingface.co/deepsite/api/me/projects
      β
New Space Created
```
---
## Contributing
The MCP server implementation lives in:
- HTTP Server: `/app/api/mcp/route.ts`
- Local Server: `/mcp-server/index.ts`
Both use the same core DeepSite logic for creating projects - no duplication!
---
## License
MIT
---
## Resources
- [Model Context Protocol Spec](https://modelcontextprotocol.io/)
- [DeepSite Documentation](https://huggingface.co/deepsite)
- [Hugging Face Spaces](https://huggingface.co/docs/hub/spaces)
- [Claude Desktop](https://claude.ai/desktop)
 | 
