mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 04:40:45 +08:00
Ship Cursor-only MCP admin and modular Admin/Chat UI.
Plugins/Skills install and edit via mcpServers JSON, with clearer row actions, soft reloads, and instant loading placeholders; also drop MCP market and harden related scheduler/logging/exec guards. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
2aff012b48
commit
f6f129931f
61 changed files with 18057 additions and 16327 deletions
|
|
@ -1,10 +1,10 @@
|
|||
"""将 oclaw/data/mcp_registry.seed.json 中的 MCP 定义写入本地 SQLite(与管理台 Install 等价)。
|
||||
"""将 Cursor ``mcpServers`` JSON 写入本地 SQLite(与管理台 Install 等价)。
|
||||
|
||||
库表被清空、换库或新环境时:在项目根执行
|
||||
python oclaw/scripts/seed_mcp_registry.py
|
||||
可选:python oclaw/scripts/seed_mcp_registry.py path/to/other.seed.json
|
||||
python -m runtime.operations.scripts.seed_mcp_registry
|
||||
可选:python -m runtime.operations.scripts.seed_mcp_registry path/to/mcp.json
|
||||
|
||||
随后在各 MCP 上点 Health → Sync Tools;Context7 等需在 src/_local/mcp_local.env 配密钥。
|
||||
随后在各 MCP 上点 Health → Sync Tools;密钥放在 oclaw/_local/mcp_local.env。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
|
|
@ -12,13 +12,15 @@ import json
|
|||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
ROOT = Path(__file__).resolve().parents[3]
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from svc.config.paths import PROJECT_ROOT, db_path # noqa: E402
|
||||
from svc.persistence.sqlite_store import SqliteStore # noqa: E402
|
||||
from svc.persistence.assistant_store import get_assistant_store
|
||||
from runtime.tools.mcp.installer import McpServerManifest, _safe_server_id, install_mcp_server # noqa: E402
|
||||
from svc.config.paths import PROJECT_ROOT # noqa: E402
|
||||
from svc.persistence.assistant_store import get_assistant_store # noqa: E402
|
||||
from runtime.tools.mcp.cursor_config import parse_cursor_mcp_document # noqa: E402
|
||||
from runtime.tools.mcp.installer import install_mcp_server # noqa: E402
|
||||
from runtime.tools.mcp.manifest import McpServerManifest # noqa: E402
|
||||
from runtime.operations.mcp_registry_export import persist_mcp_migrated_file # noqa: E402
|
||||
|
||||
|
||||
def _subst_repo(path_str: str) -> str:
|
||||
|
|
@ -34,37 +36,30 @@ def main(argv: list[str]) -> int:
|
|||
print(f"seed file not found: {seed_path}", file=sys.stderr)
|
||||
return 2
|
||||
raw = json.loads(seed_path.read_text(encoding="utf-8"))
|
||||
items = raw.get("servers") if isinstance(raw, dict) else raw
|
||||
if not isinstance(items, list) or not items:
|
||||
print("no servers[] in seed file", file=sys.stderr)
|
||||
try:
|
||||
items = parse_cursor_mcp_document(raw)
|
||||
except ValueError as exc:
|
||||
print(f"invalid Cursor mcpServers document: {exc}", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
store = get_assistant_store()
|
||||
ok_n = 0
|
||||
for payload in items:
|
||||
if not isinstance(payload, dict):
|
||||
continue
|
||||
source_type = str(payload.get("source_type") or "").strip().lower()
|
||||
source_ref = str(payload.get("source_ref") or "").strip()
|
||||
if source_type not in {"github", "npm", "pypi"} or not source_ref:
|
||||
print(f"skip invalid: {payload.get('server_id')!r}")
|
||||
continue
|
||||
server_id = _safe_server_id(str(payload.get("server_id") or source_ref))
|
||||
entry_args = [_subst_repo(x) for x in (payload.get("entry_args") or []) if str(x).strip()]
|
||||
dry_run = bool(payload.get("dry_run", False))
|
||||
manifest = McpServerManifest(
|
||||
server_id=server_id,
|
||||
source_type=source_type,
|
||||
source_ref=source_ref,
|
||||
server_id=str(payload.get("server_id") or ""),
|
||||
source_type=str(payload.get("source_type") or "local"),
|
||||
source_ref=str(payload.get("source_ref") or ""),
|
||||
version=str(payload.get("version") or "").strip(),
|
||||
entry_command=str(payload.get("entry_command") or "").strip(),
|
||||
entry_args=entry_args,
|
||||
env_schema=payload.get("env_schema") if isinstance(payload.get("env_schema"), dict) else {},
|
||||
permissions=[str(x) for x in (payload.get("required_permissions") or [])],
|
||||
risk_level=str(payload.get("risk_level") or "high"),
|
||||
enabled=bool(payload.get("enabled")),
|
||||
enabled=bool(payload.get("enabled", True)),
|
||||
timeout_s=float(payload.get("timeout_s") or 30.0),
|
||||
)
|
||||
dry_run = bool(payload.get("dry_run", False))
|
||||
inst = install_mcp_server(manifest, dry_run=dry_run)
|
||||
store.upsert_mcp_server(
|
||||
server_id=manifest.server_id,
|
||||
|
|
@ -86,10 +81,14 @@ def main(argv: list[str]) -> int:
|
|||
detail={"error": inst.error, **(inst.details or {}), "seed": True},
|
||||
install_command=inst.install_command,
|
||||
)
|
||||
print(f"{server_id}: install_ok={inst.ok} enabled={manifest.enabled if inst.ok else False} cmd={inst.install_command[:120]!r}")
|
||||
print(
|
||||
f"{manifest.server_id}: install_ok={inst.ok} "
|
||||
f"enabled={manifest.enabled if inst.ok else False} cmd={inst.install_command[:120]!r}"
|
||||
)
|
||||
if inst.ok:
|
||||
ok_n += 1
|
||||
print(f"done: {ok_n}/{len(items)} npm/pypi install steps succeeded; rows upserted for all valid entries.")
|
||||
persist_mcp_migrated_file(store)
|
||||
print(f"done: {ok_n}/{len(items)} install steps succeeded; rows upserted for all valid entries.")
|
||||
return 0
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue