mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
56 lines
1.9 KiB
Python
56 lines
1.9 KiB
Python
"""Remote MCP server schema for mcps.yaml: secret templating, persistence, and
|
|
the resolved JSON the sandbox entrypoint merges into Claude. Shares the
|
|
catalog/user-file YAML format with tools via sandbox_addons.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from pathlib import Path
|
|
|
|
import sandbox_addons
|
|
from sandbox_addons import REGISTRY_DIR, AddonError
|
|
|
|
MCP_FILE = REGISTRY_DIR / "mcps.yaml"
|
|
|
|
|
|
@dataclass
|
|
class Mcp:
|
|
name: str
|
|
server: dict # value Claude expects under mcpServers[name]
|
|
# Catalog-only; never written to the user file.
|
|
description: str | None = None
|
|
# Env vars (set in sandbox.env) that this server's config references via ${VAR}.
|
|
env: list[str] = field(default_factory=list)
|
|
|
|
|
|
def _parse_entry(raw: dict) -> Mcp:
|
|
# name presence/uniqueness is validated by sandbox_addons.load_named_entries.
|
|
name = raw["name"]
|
|
server = raw.get("server")
|
|
if not isinstance(server, dict):
|
|
raise AddonError(f"mcp {name!r}: 'server' is required and must be a mapping.")
|
|
env = raw.get("env") or []
|
|
if not isinstance(env, list) or not all(isinstance(s, str) for s in env):
|
|
raise AddonError(f"mcp {name!r}: 'env' must be a list of strings.")
|
|
return Mcp(name=name, server=server, description=raw.get("description") or None, env=env)
|
|
|
|
|
|
def load_user_mcps() -> list[Mcp]:
|
|
return sandbox_addons.load_entries(MCP_FILE, "mcps", _parse_entry)
|
|
|
|
|
|
def load_catalog(catalog_file: Path) -> dict[str, Mcp]:
|
|
return sandbox_addons.load_catalog(catalog_file, "mcps", _parse_entry)
|
|
|
|
|
|
def save_user_mcps(mcps: list[Mcp]) -> None:
|
|
# Servers reference secrets as ${VAR} (set in sandbox.env), so the file
|
|
# itself holds no tokens.
|
|
entries = [{"name": m.name, "server": m.server} for m in mcps]
|
|
sandbox_addons.save_named_entries(MCP_FILE, "mcps", entries)
|
|
|
|
|
|
def resolve_servers() -> dict[str, dict]:
|
|
return {m.name: m.server for m in load_user_mcps()}
|