Spaces:
Sleeping
Private Space Testing Guide
The 404 Problem: Is Your Space Private?
If you're getting 404 errors, your Space might be PRIVATE, which requires authentication to access.
Check Your Space Visibility
The settings page should now be open in your browser. Look for:
π Private Space
Visibility: Private
Only you and approved users can access this Space
π Public Space
Visibility: Public
Anyone can access this Space
Solution 1: Make Your Space Public (Recommended for APIs)
Steps:
- Go to: https://huggingface.co/spaces/ocx2025/basicsearch/settings
- Scroll to "Visibility" section
- Click "Make public"
- Confirm the change
After Making Public:
# Wait 30 seconds, then test again
sleep 30
cd /Users/marjorie/Documents/GitHub/xctopus/mcp2/basicsearch
uv run python test_deployment.py
β Pros:
- No authentication needed
- Easy to test
- Anyone can use your API
- Better for integrations
β Cons:
- Anyone can see your code
- Anyone can use your API
- Public usage counts
Solution 2: Keep Private + Use Authentication Token
If you want to keep the Space private, you'll need a Hugging Face token.
Get Your Token:
- Visit: https://huggingface.co/settings/tokens
- Click "New token"
- Name it:
basicsearch-testing - Select permissions: Read
- Click "Generate"
- Copy the token (starts with
hf_...)
Test with Token:
cd /Users/marjorie/Documents/GitHub/xctopus/mcp2/basicsearch
# Replace YOUR_TOKEN with actual token
python test_private_space.py https://ocx2025-basicsearch.hf.space hf_YourTokenHere
Set as Environment Variable:
# Add to ~/.zshrc or ~/.bashrc
export HF_TOKEN="hf_YourTokenHere"
# Then you can just run:
python test_private_space.py
Update Test Script to Use Token:
# test_deployment.py with auth
import os
import requests
token = os.getenv("HF_TOKEN")
headers = {}
if token:
headers["Authorization"] = f"Bearer {token}"
response = requests.get(
"https://ocx2025-basicsearch.hf.space/health",
headers=headers
)
β Pros:
- Code stays private
- Control who can access
- Better security
β Cons:
- Requires token management
- More complex testing
- Harder to share
Test Right Now
Quick Check:
# Test without auth (works if public)
curl https://ocx2025-basicsearch.hf.space/health
# Test with auth (works if private)
curl -H "Authorization: Bearer YOUR_TOKEN" \
https://ocx2025-basicsearch.hf.space/health
Expected Results:
If Space is Building:
404 - Page not found (with HF branding page)
Action: Wait 5-10 more minutes
If Space is Private:
404 - Page not found
Action: Make public OR use token
If Space is Public and Running:
{"status": "ok"}
Action: Celebrate! π
How to Use Private Space with Claude
If you keep it private, you'll need to configure Claude with your token:
Claude Desktop Config:
{
"mcpServers": {
"basicsearch": {
"url": "https://ocx2025-basicsearch.hf.space",
"headers": {
"Authorization": "Bearer hf_YourTokenHere"
}
}
}
}
Docker App with Authentication
If you want your Docker app to handle authentication, update app.py:
from fastapi import FastAPI, Header, HTTPException
app = FastAPI()
# Simple token check
API_TOKEN = os.getenv("API_TOKEN", "")
@app.get("/health")
async def health(authorization: str = Header(None)):
if API_TOKEN and authorization != f"Bearer {API_TOKEN}":
raise HTTPException(status_code=401, detail="Unauthorized")
return {"status": "ok"}
Comparison: Public vs Private
| Feature | Public | Private |
|---|---|---|
| Access | Anyone | Token required |
| Testing | Easy | Needs token |
| Security | Low | High |
| Sharing | Easy | Controlled |
| API Use | Simple | Complex |
| Best For | Demos, Open APIs | Internal tools |
Recommendation for Your MCP Server
Choose Public If:
- β You want easy testing
- β You plan to share with others
- β Your API is meant to be public
- β No sensitive data involved
- β You want Claude integration to be simple
Choose Private If:
- β You have sensitive code
- β You want to control access
- β You're in development phase
- β You need usage tracking
- β You have private API keys (like YouTube API)
Current Status Check
Run this to determine what's happening:
cd /Users/marjorie/Documents/GitHub/xctopus/mcp2/basicsearch
# Check 1: Is it accessible at all?
curl -I https://ocx2025-basicsearch.hf.space/health
# Check 2: What's the space status?
open https://huggingface.co/spaces/ocx2025/basicsearch
# Check 3: What are the settings?
open https://huggingface.co/spaces/ocx2025/basicsearch/settings
Look for:
- "Building" β Wait and try again
- "Running" + Private β Make public or use token
- "Running" + Public β Should work!
- "Error" β Check logs
Quick Fix Checklist
- Visit: https://huggingface.co/spaces/ocx2025/basicsearch/settings
- Check visibility: Public or Private?
- If Private: Click "Make public"
- If keeping Private: Get HF token from https://huggingface.co/settings/tokens
- Wait 30 seconds after change
- Run:
uv run python test_deployment.py - Should see:
β PASSEDmessages!
Troubleshooting Matrix
| Status | Visibility | Result | Action |
|---|---|---|---|
| Building | Any | 404 | Wait |
| Running | Public | 200 OK | β Success |
| Running | Public | 404 | Check logs |
| Running | Private | 404 | Use token or make public |
| Running | Private | 401 | Invalid token |
| Error | Any | 404 | Check build logs |
After Making Public
Once you make it public, test immediately:
# Should work now!
curl https://ocx2025-basicsearch.hf.space/health
# Full test
uv run python test_deployment.py
# If it works, you'll see:
# β PASSED - Health Check
# β PASSED - Service Info
# ... etc
Security Note
If you make the Space public, your code will be visible. Make sure:
- β No API keys in code (use Hugging Face secrets)
- β No passwords or tokens committed
- β
Your
.gitignoreincludes.envfiles - β Secrets are set in Space settings, not code
Your YOUTUBE_API_KEY is safe because it's in Space secrets, not code! β
Summary
Most likely issue: Your Space is private and needs authentication.
Quick fix:
- Open settings (should be open now)
- Click "Make public"
- Wait 30 seconds
- Run test again
- Profit! π