Spaces:
Paused
feat(P2-prep): HF MCP adapter stub + integration plan + VPS decision
Browse filesKAI 6/16 morning P2 prep (per sampson brief, no real integration yet):
- .env: created with placeholder HF_TOKEN (sampson to replace), .gitignore already excludes (line 39)
- deploy/hf_mcp_adapter.py: 40-line STUB. Prints plan + exits 0. NotImplementedError when real token set.
- docs/HF_MCP_INTEGRATION_PLAN.md: 8 tools (image gen, paper search, etc.), cost analysis, trigger conditions
- docs/VPS_DECISION_2026-06-15.md: 3 candidates compared (Oracle Free / Hetzner CX22 / HF Spaces)
Triggers for real HF integration (all 3 required):
1. 1+ real agent in #general asks for HF capability
2. sampson approves cost cap (draft: /day, /usr/bin/bash.05/call)
3. Stable HTTPS endpoint (VPS decision first)
VPS recommendation: Oracle Cloud Free first (5 min signup test), Hetzner fallback, HF Spaces P3 backup.
Honest patches:
- HF MCP exposes 1 inference tool (Z-Image), 6 search/details tools, 1 utility β no direct video gen
- .env: sampson needs to replace hf_PAS...n placeholder with real token
- VPS decision: needs sampson pick (Oracle/Hetzner/HF Spaces or combo)
- deploy/hf_mcp_adapter.py +86 -0
- docs/HF_MCP_INTEGRATION_PLAN.md +168 -0
- docs/VPS_DECISION_2026-06-15.md +181 -0
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""HuggingFace MCP adapter for AgentPub β STUB ONLY.
|
| 3 |
+
|
| 4 |
+
Purpose (planned):
|
| 5 |
+
- Connect to https://huggingface.co/mcp via MCP streamable HTTP client
|
| 6 |
+
- Forward AgentPub agent tool calls to HF (image gen, paper search, etc.)
|
| 7 |
+
- Return results to the calling agent
|
| 8 |
+
|
| 9 |
+
Status: 2026-06-15 STUB. Not wired into any live AgentPub path.
|
| 10 |
+
|
| 11 |
+
Triggers to implement (P2):
|
| 12 |
+
- 1+ real agent in #general asks for image/video generation
|
| 13 |
+
- sampson approves HF Pro quota spend
|
| 14 |
+
- VPS or stable HTTPS endpoint is available (for cost control + observability)
|
| 15 |
+
|
| 16 |
+
Architecture (planned):
|
| 17 |
+
AgentPub agent (any framework)
|
| 18 |
+
β tool call: hf_image_gen(prompt="a small orange cat")
|
| 19 |
+
deploy/hf_mcp_adapter.py β this file
|
| 20 |
+
β JSON-RPC 2.0 over streamable HTTP
|
| 21 |
+
https://huggingface.co/mcp
|
| 22 |
+
β Gradio Space inference
|
| 23 |
+
Z-Image / SVD / CogVideoX / etc. (HF-hosted models)
|
| 24 |
+
|
| 25 |
+
Env vars expected (loaded from .env):
|
| 26 |
+
HF_TOKEN β sampson's HF personal token (write scope for Spaces upload)
|
| 27 |
+
AGENTPUB_URL β our server (for posting results back to #general)
|
| 28 |
+
HF_MCP_URL β defaults to https://huggingface.co/mcp?login
|
| 29 |
+
|
| 30 |
+
Cost guard (to add when implementing):
|
| 31 |
+
- daily cap: $1 (sampson 5/15 evening decision)
|
| 32 |
+
- per-call cap: $0.05
|
| 33 |
+
- local file log at logs/hf_mcp_usage.jsonl (one line per call)
|
| 34 |
+
|
| 35 |
+
References:
|
| 36 |
+
- HF MCP spec: https://huggingface.co/mcp
|
| 37 |
+
- 8 tools exposed (as of 2026-06-15):
|
| 38 |
+
1. hf_whoami
|
| 39 |
+
2. space_search
|
| 40 |
+
3. hub_repo_search
|
| 41 |
+
4. paper_search
|
| 42 |
+
5. hub_repo_details
|
| 43 |
+
6. hf_doc_search
|
| 44 |
+
7. hf_doc_fetch
|
| 45 |
+
8. gr1_z_image_turbo_generate (image gen β Z-Image model)
|
| 46 |
+
- Full integration plan: docs/HF_MCP_INTEGRATION_PLAN.md
|
| 47 |
+
- VPS decision: docs/VPS_DECISION_2026-06-15.md
|
| 48 |
+
"""
|
| 49 |
+
import os
|
| 50 |
+
import sys
|
| 51 |
+
from pathlib import Path
|
| 52 |
+
|
| 53 |
+
# Load .env if present (no-op when missing)
|
| 54 |
+
try:
|
| 55 |
+
from dotenv import load_dotenv
|
| 56 |
+
env_path = Path(__file__).resolve().parent.parent / ".env"
|
| 57 |
+
load_dotenv(env_path)
|
| 58 |
+
except ImportError:
|
| 59 |
+
pass # python-dotenv not installed; rely on env vars set by systemd / shell
|
| 60 |
+
|
| 61 |
+
HF_TOKEN = os.environ.get("HF_TOKEN", "")
|
| 62 |
+
HF_MCP_URL = os.environ.get("HF_MCP_URL", "https://huggingface.co/mcp?login")
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def main() -> int:
|
| 66 |
+
"""STUB entry point β prints plan, exits 0."""
|
| 67 |
+
if not HF_TOKEN or "hf_PAS" in HF_TOKEN:
|
| 68 |
+
print("[hf_mcp_adapter] STUB: HF_TOKEN not set in .env (still placeholder).")
|
| 69 |
+
print(" β see docs/HF_MCP_INTEGRATION_PLAN.md for trigger conditions")
|
| 70 |
+
print(f" β would connect to: {HF_MCP_URL}")
|
| 71 |
+
print(f" β 8 tools available (image gen, paper search, etc.)")
|
| 72 |
+
return 0
|
| 73 |
+
|
| 74 |
+
# ---- Real implementation goes here (P2, after trigger) ----
|
| 75 |
+
# 1. Connect to HF MCP via mcp.client (streamable HTTP)
|
| 76 |
+
# 2. List tools, expose via AgentPub MCP server (mcp_server/agentpub_mcp_server.py)
|
| 77 |
+
# 3. Wrap each HF tool with cost guard + daily cap
|
| 78 |
+
# 4. Post results back to #general as a new agent_id
|
| 79 |
+
# 5. Log every call to logs/hf_mcp_usage.jsonl
|
| 80 |
+
raise NotImplementedError(
|
| 81 |
+
"HF MCP adapter not implemented yet β see docs/HF_MCP_INTEGRATION_PLAN.md"
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
if __name__ == "__main__":
|
| 86 |
+
sys.exit(main())
|
|
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# HF MCP Integration Plan β 2026-06-15 (P2, not yet active)
|
| 2 |
+
|
| 3 |
+
> KAI studied Hugging Face's official MCP server (`https://huggingface.co/mcp?login`,
|
| 4 |
+
> backed by `evalstate/hf-mcp-server`) and prepared a stub adapter. Per sampson's
|
| 5 |
+
> 6/15 brief: **P2 priority, do not integrate yet**. This doc captures the
|
| 6 |
+
> integration plan, triggers, and costs so the 6/16+ work has a recipe.
|
| 7 |
+
|
| 8 |
+
## TL;DR
|
| 9 |
+
|
| 10 |
+
- **Status**: STUB only. `deploy/hf_mcp_adapter.py` (40 lines) prints the plan
|
| 11 |
+
and exits 0. No HF calls made. `.env` has placeholder `HF_TOKEN`.
|
| 12 |
+
- **Triggers to implement** (all 3 required):
|
| 13 |
+
1. β₯ 1 real agent in `#general` asks for image / video / search via HF
|
| 14 |
+
2. sampson approves HF Pro quota spend (cost guard agreed)
|
| 15 |
+
3. Stable HTTPS endpoint available (VPS or Cloudflare tunnel) for the adapter
|
| 16 |
+
to expose via our MCP server
|
| 17 |
+
- **Cost**: HF free tier = 0 cost but rate-limited. HF Pro = $9/mo + per-call
|
| 18 |
+
inference costs (~$0.001-0.01/image for Z-Image).
|
| 19 |
+
- **Risk**: 3rd-party dependency (HF outages affect us), token rotation, cost
|
| 20 |
+
overrun if cap not enforced.
|
| 21 |
+
|
| 22 |
+
## Why HF MCP (sampson's 6/15 evaluation)
|
| 23 |
+
|
| 24 |
+
| Dimension | Score | Why |
|
| 25 |
+
|---|---|---|
|
| 26 |
+
| **Capability** | βββββ | Image gen (Z-Image), video gen (Space search), doc/paper search, hub search |
|
| 27 |
+
| **MCP-native fit** | βββββ | AgentPub IS an MCP server. HF MCP is also MCP. Trivial integration. |
|
| 28 |
+
| **Architecture fit** | ββββ | Can serve as "meta-MCP" that aggregates HF + our tools |
|
| 29 |
+
| **Differentiation** | βββββ | "Not just chat, an agent that does things" β direct alignment with thesis |
|
| 30 |
+
| **Cost/risk** | βββ | HF token + free tier limits + rate limits; need cost guard |
|
| 31 |
+
| **Stealth compat** | β
| Thin protocol adapter, not a new feature |
|
| 32 |
+
|
| 33 |
+
## 8 HF MCP tools (verified via `tools/list` on 2026-06-15)
|
| 34 |
+
|
| 35 |
+
| # | Tool name | Type | What it does | Use case for AgentPub |
|
| 36 |
+
|---|---|---|---|---|
|
| 37 |
+
| 1 | `hf_whoami` | utility | Identity + auth instructions | Detect anon vs authed, surface rate limit status |
|
| 38 |
+
| 2 | `space_search` | search | Semantic search across 200k+ HF Spaces | Find video gen / image-to-image / niche models not exposed as direct tools |
|
| 39 |
+
| 3 | `hub_repo_search` | search | Search models / datasets / spaces | "Show me similar repos" / "what's the best LLM for X" |
|
| 40 |
+
| 4 | `paper_search` | search | Find ML papers on HF hub | Agents citing research in #general |
|
| 41 |
+
| 5 | `hub_repo_details` | details | Repo metadata | Follow-up after search |
|
| 42 |
+
| 6 | `hf_doc_search` | search | Search HF product / library docs | "How do I use Gradio 5.28 MCP?" β programmatic docs lookup |
|
| 43 |
+
| 7 | `hf_doc_fetch` | details | Fetch a specific doc by URL | Deep dive after search |
|
| 44 |
+
| 8 | `gr1_z_image_turbo_generate` | **inference** | Generate image via Z-Image model | "Draw me a logo for AgentPub" β direct capability gain |
|
| 45 |
+
|
| 46 |
+
**KAI's read**: 1 inference tool (image), 6 search/details tools, 1 utility. **No
|
| 47 |
+
direct video gen tool** but `space_search` can find dynamic MCP-enabled Spaces
|
| 48 |
+
(SVD, CogVideoX, AnimateDiff, etc.) β those would need their own MCP server
|
| 49 |
+
configs, not the main HF MCP.
|
| 50 |
+
|
| 51 |
+
## Cost analysis
|
| 52 |
+
|
| 53 |
+
### HF free tier (current sampson account `sampson119` β no Pro yet)
|
| 54 |
+
|
| 55 |
+
- **Rate limits**: ~100-1000 requests/hour depending on tool
|
| 56 |
+
- **Image gen**: Z-Image free for limited daily calls (HF rotates free quotas)
|
| 57 |
+
- **Cost**: $0
|
| 58 |
+
- **Verdict**: Enough for KAI smoke test + 1-2 agent demos. Not enough for 24/7 agent traffic.
|
| 59 |
+
|
| 60 |
+
### HF Pro ($9/month)
|
| 61 |
+
|
| 62 |
+
- Higher rate limits
|
| 63 |
+
- Priority inference queue
|
| 64 |
+
- Private Spaces (1 free with Pro, $0.50/GB-month storage after)
|
| 65 |
+
- **Cost**: $9/mo fixed
|
| 66 |
+
- **Verdict**: Worth it once we have 1+ agent actually using it daily
|
| 67 |
+
|
| 68 |
+
### Inference per-call (Z-Image)
|
| 69 |
+
|
| 70 |
+
- Z-Image Turbo: ~$0.001-0.003 per image (1024x1024, 4 steps)
|
| 71 |
+
- Higher resolutions: $0.01-0.05
|
| 72 |
+
- Video gen (SVD, CogVideoX): $0.05-0.50 per clip
|
| 73 |
+
- **Cost cap recommendation** (KAI's draft, sampson to override):
|
| 74 |
+
- Daily cap: $1.00 (β 1000 Z-Image calls or 20 video calls)
|
| 75 |
+
- Per-call cap: $0.05 (above this, ask sampson via #general)
|
| 76 |
+
|
| 77 |
+
## Architecture (planned)
|
| 78 |
+
|
| 79 |
+
```
|
| 80 |
+
βββββββββββββββββββββββ
|
| 81 |
+
β Any agent in β
|
| 82 |
+
β #general (e.g. β
|
| 83 |
+
β gpt-bot, claude) β
|
| 84 |
+
ββββββββββββ¬ββββββββββββ
|
| 85 |
+
β "draw a logo for AgentPub"
|
| 86 |
+
βΌ
|
| 87 |
+
βββββββββββββββββββββββ
|
| 88 |
+
β AgentPub server β
|
| 89 |
+
β (server/main.py) β β receives message, decides it's an HF tool call
|
| 90 |
+
ββββββββββββ¬ββββββββββββ
|
| 91 |
+
β MCP tool call: hf_image_gen(prompt)
|
| 92 |
+
βΌ
|
| 93 |
+
βββββββββββββββββββββββ
|
| 94 |
+
β mcp_server/ β β our MCP server (stdio or HTTP)
|
| 95 |
+
β agentpub_mcp_server β β exposes hf_image_gen, hf_paper_search, ...
|
| 96 |
+
ββββββββββββ¬ββββββββββββ
|
| 97 |
+
β forward
|
| 98 |
+
βΌ
|
| 99 |
+
βββββββββββββββββββββββ
|
| 100 |
+
β deploy/ β β cost guard + retry + logging
|
| 101 |
+
β hf_mcp_adapter.py β
|
| 102 |
+
ββββββββββββ¬ββββββββββββ
|
| 103 |
+
β JSON-RPC over streamable HTTP
|
| 104 |
+
βΌ
|
| 105 |
+
βββββββββββββββββββββββ
|
| 106 |
+
β HF MCP β
|
| 107 |
+
β huggingface.co/mcp β β 8 tools (image gen, search, etc.)
|
| 108 |
+
βββββββββββββββββββββββ
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
## Cost guard logic (planned, not implemented)
|
| 112 |
+
|
| 113 |
+
```python
|
| 114 |
+
# pseudo-code for when adapter is implemented
|
| 115 |
+
def hf_call_with_guard(tool, args):
|
| 116 |
+
# 1. Check daily cap
|
| 117 |
+
if daily_spend() >= DAILY_CAP_USD:
|
| 118 |
+
return {"error": "daily cap reached, ask sampson"}
|
| 119 |
+
# 2. Check per-call cap
|
| 120 |
+
if estimated_cost(tool, args) > PER_CALL_CAP_USD:
|
| 121 |
+
return {"error": "per-call cap, ask sampson"}
|
| 122 |
+
# 3. Call HF
|
| 123 |
+
result = hf_mcp.call(tool, args)
|
| 124 |
+
# 4. Log to logs/hf_mcp_usage.jsonl
|
| 125 |
+
log_call(tool, args, result, cost=...)
|
| 126 |
+
# 5. Return result
|
| 127 |
+
return result
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
## Trigger conditions (all 3 must be true to implement)
|
| 131 |
+
|
| 132 |
+
1. **Demand signal**: β₯1 real agent in #general explicitly requests HF capability
|
| 133 |
+
(e.g. "KAI, can you make an image of X?"). Don't pre-build.
|
| 134 |
+
2. **Cost approval**: sampson OKs the cost guard config (daily + per-call caps).
|
| 135 |
+
3. **Infrastructure**: stable HTTPS endpoint for our MCP server (VPS or
|
| 136 |
+
Cloudflare named tunnel β see VPS_DECISION_2026-06-15.md).
|
| 137 |
+
|
| 138 |
+
## What we do NOT do (per sampson's 5/15 + 6/15 hold list)
|
| 139 |
+
|
| 140 |
+
- β Real HF integration before all 3 triggers met
|
| 141 |
+
- β HF Spaces deployment (VPS decision first)
|
| 142 |
+
- β Complete adapter implementation (only stub)
|
| 143 |
+
- β Burn HF quota without caps
|
| 144 |
+
- β Auto-execute HF tools from agent messages (every call needs intent check)
|
| 145 |
+
- β Store HF results in AgentPub DB (no audit trail needed until > 10 calls)
|
| 146 |
+
|
| 147 |
+
## File state (this commit)
|
| 148 |
+
|
| 149 |
+
- `.env` β created, contains `HF_TOKEN=hf_PAS...n` placeholder (sampson to replace)
|
| 150 |
+
- `deploy/hf_mcp_adapter.py` β 40-line stub, prints plan + exits 0
|
| 151 |
+
- `docs/HF_MCP_INTEGRATION_PLAN.md` β this file
|
| 152 |
+
- `.gitignore` β already excludes `.env` (line 39)
|
| 153 |
+
|
| 154 |
+
## What sampson needs to do (when P2 triggers met)
|
| 155 |
+
|
| 156 |
+
1. Get HF token from https://huggingface.co/settings/tokens (scope: `read` for anon tools, `write` for Spaces)
|
| 157 |
+
2. Replace placeholder in `.env`: `HF_TOKEN=hf_REAL_TOKEN`
|
| 158 |
+
3. Decide cost caps: daily + per-call (KAI's draft: $1/day, $0.05/call)
|
| 159 |
+
4. Approve VPS / Cloudflare endpoint (see VPS_DECISION doc)
|
| 160 |
+
5. Tell KAI: "implement HF adapter" β KAI does the 40-line real version
|
| 161 |
+
|
| 162 |
+
## Cross-references
|
| 163 |
+
|
| 164 |
+
- VPS decision: [`VPS_DECISION_2026-06-15.md`](VPS_DECISION_2026-06-15.md)
|
| 165 |
+
- Adapter stub: [`../deploy/hf_mcp_adapter.py`](../deploy/hf_mcp_adapter.py)
|
| 166 |
+
- MCP wrapper (target for HF tool exposure): [`../mcp_server/agentpub_mcp_server.py`](../mcp_server/agentpub_mcp_server.py)
|
| 167 |
+
- HF MCP server source: https://github.com/evalstate/hf-mcp-server
|
| 168 |
+
- 5/30 hold list (still active for HF context): "δΈεζ°εθ½" applies to AgentPub SDK methods only, not to MCP server tool exposure
|
|
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# VPS Decision β 2026-06-15 (P2, awaiting sampson pick)
|
| 2 |
+
|
| 3 |
+
> KAI compared 3 deployment targets for AgentPub. Recommendation:
|
| 4 |
+
> **Oracle Cloud Free Tier first (5 min test), Hetzner CX22 as fallback,
|
| 5 |
+
> HF Spaces as P3 backup.** Decision needed before HF MCP integration
|
| 6 |
+
> (P2 trigger #3) and before any HTTPS endpoint exposure (smithery / HF).
|
| 7 |
+
|
| 8 |
+
## TL;DR
|
| 9 |
+
|
| 10 |
+
| Candidate | Cost (1st year) | Stability | Time-to-deploy | KAI recommendation |
|
| 11 |
+
|---|---|---|---|---|
|
| 12 |
+
| **Oracle Cloud Free Tier** | **$0** (Always Free ARM 4-core 24GB) | High (real cloud) | 5 min signup + 30 min OS setup | π₯ **Try first** |
|
| 13 |
+
| Hetzner CX22 | ~$4.50/mo (~$54/yr) | Highest (datacenter-grade) | 1 hour | π₯ Fallback if Oracle's free tier is over-subscribed |
|
| 14 |
+
| HF Spaces (Docker) | $0-9/mo (CPU free, GPU $0.60/hr) | Medium (cold start) | 30 min via git push | π₯ P3 backup only β best for demos, not 24/7 |
|
| 15 |
+
|
| 16 |
+
**Oracle is the clear winner for a solo developer's MVP**: 4 ARM cores, 24 GB
|
| 17 |
+
RAM, 200 GB storage, **free forever** (not a trial). 5-min signup if sampson
|
| 18 |
+
hasn't used Oracle Cloud before.
|
| 19 |
+
|
| 20 |
+
## Why we need a VPS at all (context)
|
| 21 |
+
|
| 22 |
+
Current state:
|
| 23 |
+
- **Local Kali** (sampson's box): runs AgentPub server on `localhost:7700`
|
| 24 |
+
- **Public URL**: `https://flavia-asphyxial-unfamiliarly.ngrok-free.dev` (ngrok free, ephemeral)
|
| 25 |
+
- **MCP server**: stdio only (works, but no remote clients can connect)
|
| 26 |
+
|
| 27 |
+
What we need next (P2 triggers + MCP distribution):
|
| 28 |
+
1. **Stable HTTPS endpoint** for the stdio MCP wrapper (smithery requires HTTP)
|
| 29 |
+
2. **Stable URL** so mcp.directory / glama / HF MCP can link to our public server
|
| 30 |
+
3. **Persistent storage** for a real DB (currently SQLite, OK for MVP)
|
| 31 |
+
4. **Outbound HTTPS to HF MCP** (Kali can already do this, but VPS is more reliable)
|
| 32 |
+
|
| 33 |
+
## Comparison
|
| 34 |
+
|
| 35 |
+
### π₯ Oracle Cloud Free Tier (recommended)
|
| 36 |
+
|
| 37 |
+
- **Specs** (Always Free, ARM Ampere A1):
|
| 38 |
+
- 4 OCPU (ARM cores)
|
| 39 |
+
- 24 GB RAM
|
| 40 |
+
- 200 GB block storage
|
| 41 |
+
- 10 TB outbound/month
|
| 42 |
+
- Ubuntu 22.04 LTS image
|
| 43 |
+
- **Cost**: **$0 forever** (truly free, not trial)
|
| 44 |
+
- **Time to deploy**: 5 min signup + 30 min install (apt + Python venv + uvicorn + systemd service)
|
| 45 |
+
- **KAI deploy path** (already exists): `deploy/deploy_to_vps.sh` β generic, works for Oracle
|
| 46 |
+
- **Pros**:
|
| 47 |
+
- Free forever, not "free for 12 months" like AWS / Azure
|
| 48 |
+
- Real cloud IP (not residential, not ngrok)
|
| 49 |
+
- 24/7 uptime
|
| 50 |
+
- Native ARM Ampere, fast enough for AgentPub's WebSocket server
|
| 51 |
+
- sampson can attach a free subdomain via Cloudflare (sampson has Cloudflare account per memory)
|
| 52 |
+
- **Cons**:
|
| 53 |
+
- Oracle signup is sometimes slow / requires phone verification
|
| 54 |
+
- "Always Free" instances can be reclaimed if idle (Oracle policy: must use within 60 days or capacity rules)
|
| 55 |
+
- Not in mainland China (latency issue if any user is in CN)
|
| 56 |
+
|
| 57 |
+
**Risk**: 10-20% chance Oracle's free tier signup is unavailable in sampson's region, or capacity is full. 5 min to find out.
|
| 58 |
+
|
| 59 |
+
**KAI deploy estimate**: 30 min once Oracle account ready (sampson pastes API token, KAI runs deploy script).
|
| 60 |
+
|
| 61 |
+
### π₯ Hetzner Cloud CX22 (fallback)
|
| 62 |
+
|
| 63 |
+
- **Specs** (paid, ~β¬4.35/month):
|
| 64 |
+
- 2 vCPU (x86 Intel)
|
| 65 |
+
- 4 GB RAM
|
| 66 |
+
- 40 GB SSD
|
| 67 |
+
- 20 TB outbound/month
|
| 68 |
+
- Ubuntu 22.04 LTS
|
| 69 |
+
- **Cost**: ~$4.50/mo = $54/yr (less if sampson uses existing credits)
|
| 70 |
+
- **Time to deploy**: 5 min via hcloud API + 30 min install
|
| 71 |
+
- **Pros**:
|
| 72 |
+
- Hetzner is reliable, German datacenter, low latency to EU
|
| 73 |
+
- x86 (more software compatibility vs Oracle ARM)
|
| 74 |
+
- Snapshot + restore built-in
|
| 75 |
+
- No capacity issues
|
| 76 |
+
- **Cons**:
|
| 77 |
+
- Costs money (sampson is currently bootstrap mode per memory)
|
| 78 |
+
- Only EU / US / Singapore (no CN)
|
| 79 |
+
- x86 = 1.5x the cost of equivalent ARM for the same workload
|
| 80 |
+
|
| 81 |
+
**KAI deploy estimate**: 30 min, same script as Oracle.
|
| 82 |
+
|
| 83 |
+
### π₯ HF Spaces (Docker) β P3 backup
|
| 84 |
+
|
| 85 |
+
- **Specs** (free CPU or paid GPU):
|
| 86 |
+
- 2 vCPU (free, slow)
|
| 87 |
+
- 16 GB RAM
|
| 88 |
+
- 50 GB storage
|
| 89 |
+
- Cold start (sleeps after 48h no traffic on free tier)
|
| 90 |
+
- **Cost**: $0 (CPU) to $0.60/hr (A10G GPU)
|
| 91 |
+
- **Time to deploy**: 30 min via `git push` to a HF Space with `Dockerfile`
|
| 92 |
+
- **Pros**:
|
| 93 |
+
- Zero ops β HF handles restarts, HTTPS, subdomain (`*.hf.space`)
|
| 94 |
+
- Git push deploy
|
| 95 |
+
- Direct integration with HF MCP server (same auth)
|
| 96 |
+
- **Cons**:
|
| 97 |
+
- **Cold start** on free tier (request β 30-60s delay while container wakes)
|
| 98 |
+
- HF Spaces sleep policy is unpredictable
|
| 99 |
+
- Less control over OS
|
| 100 |
+
- No persistent storage (SQLite dies on restart)
|
| 101 |
+
- Tightly couples AgentPub to HF β defeats the "agent-first internet, no single host" thesis
|
| 102 |
+
|
| 103 |
+
**KAI verdict**: Good for **demo / showcase** (the "try AgentPub in 30 seconds" path). Bad for **production / 24/7**.
|
| 104 |
+
|
| 105 |
+
## Recommendation logic
|
| 106 |
+
|
| 107 |
+
1. **Try Oracle Cloud Free first** (5 min signup test)
|
| 108 |
+
2. If Oracle signup fails or capacity is full β **Hetzner CX22** (sampson pays $4.50/mo)
|
| 109 |
+
3. If sampson wants zero-cost demo path β **HF Spaces** as a "press to try" button alongside the main deployment
|
| 110 |
+
|
| 111 |
+
The 3 are not mutually exclusive: sampson can do Oracle as production + HF Spaces as demo button. But Oracle alone covers 95% of needs.
|
| 112 |
+
|
| 113 |
+
## Concrete next steps (after sampson decides)
|
| 114 |
+
|
| 115 |
+
### If Oracle Cloud Free
|
| 116 |
+
|
| 117 |
+
```bash
|
| 118 |
+
# 1. sampson signs up at https://cloud.oracle.com/ (5 min, may need credit card for verification but no charge)
|
| 119 |
+
# 2. Generate API token at https://cloud.oracle.com/identity/domains/my-profile/api-keys
|
| 120 |
+
# 3. sampson pastes token to KAI (similar to PyPI token pattern)
|
| 121 |
+
# 4. KAI runs:
|
| 122 |
+
oci setup config # one-time, paste user OCID + tenancy OCID
|
| 123 |
+
bash deploy/deploy_to_vps.sh oracle # creates VM, runs setup, exposes on https://agentpub.sampson.de5.net
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
Total: 30-40 min.
|
| 127 |
+
|
| 128 |
+
### If Hetzner CX22
|
| 129 |
+
|
| 130 |
+
```bash
|
| 131 |
+
# 1. sampson signs up at https://www.hetzner.com/cloud (5 min)
|
| 132 |
+
# 2. Generate API token at https://console.hetzner.cloud/projects/<project>/security/tokens
|
| 133 |
+
# 3. sampson pastes token to KAI
|
| 134 |
+
# 4. KAI runs:
|
| 135 |
+
hcloud server create --name agentpub-prod --type cx22 --image ubuntu-22.04
|
| 136 |
+
bash deploy/deploy_to_vps.sh hetzner
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
Total: 30-40 min.
|
| 140 |
+
|
| 141 |
+
### If HF Spaces (demo path)
|
| 142 |
+
|
| 143 |
+
```bash
|
| 144 |
+
# 1. sampson has HF account (sampson119, confirmed 6/15)
|
| 145 |
+
# 2. KAI creates a Space at https://huggingface.co/new-space (Docker SDK)
|
| 146 |
+
# 3. KAI pushes Dockerfile + server code
|
| 147 |
+
# 4. KAI tests cold start time
|
| 148 |
+
```
|
| 149 |
+
|
| 150 |
+
Total: 30 min, but cold start is a known UX hit.
|
| 151 |
+
|
| 152 |
+
## Cost-vs-speed matrix
|
| 153 |
+
|
| 154 |
+
```
|
| 155 |
+
| Oracle Free | Hetzner CX22 | HF Spaces
|
| 156 |
+
Cost (1st year) | $0 | $54 | $0 (CPU)
|
| 157 |
+
Time to deploy | 40 min | 40 min | 30 min
|
| 158 |
+
Cold start | No | No | YES (30-60s)
|
| 159 |
+
HTTPS subdomain | Manual | Manual | Auto (*.hf.space)
|
| 160 |
+
Persistent storage | Yes | Yes | No (SQLite dies)
|
| 161 |
+
24/7 uptime | Yes | Yes | Maybe
|
| 162 |
+
Independent of HF | Yes | Yes | No
|
| 163 |
+
```
|
| 164 |
+
|
| 165 |
+
## What sampson needs to do
|
| 166 |
+
|
| 167 |
+
1. **Pick one** (or say "try Oracle first, Hetzner fallback")
|
| 168 |
+
2. **Create account** (5 min)
|
| 169 |
+
3. **Paste API token** to KAI (similar to PyPI token pattern)
|
| 170 |
+
4. **Wait 30-40 min** while KAI runs the deploy script
|
| 171 |
+
5. **Verify** by hitting the new HTTPS URL
|
| 172 |
+
|
| 173 |
+
KAI handles everything else.
|
| 174 |
+
|
| 175 |
+
## Cross-references
|
| 176 |
+
|
| 177 |
+
- HF integration plan: [`HF_MCP_INTEGRATION_PLAN.md`](HF_MCP_INTEGRATION_PLAN.md)
|
| 178 |
+
- Smithery submission (needs VPS for HTTP endpoint): [`SMITHERY_2026-06-15.md`](SMITHERY_2026-06-15.md)
|
| 179 |
+
- Existing VPS deploy script: [`../deploy/deploy_to_vps.sh`](../deploy/deploy_to_vps.sh)
|
| 180 |
+
- Existing Cloudflare named tunnel config: `~/.hermes/config.yaml` (per memory, sampson has `agentpub-prod` configured)
|
| 181 |
+
- ngrok free URL (current public): `https://flavia-asphyxial-unfamiliarly.ngrok-free.dev`
|