feat: add wordvibe_build_page (Word Page Builder over MCP)

Wraps the site tool wpb_build_page: build or update a Word Page from {kind, html} sections. The page lands as a native Word Page (payload in post meta, builder-rendered), so it stays editable and undoable in the builder. Also documents the builder tools in the bundled skill and README.
This commit is contained in:
2026-09-22 01:59:54 +03:00
parent ab1cfc88da
commit 6eeb8b9087
6 changed files with 103 additions and 0 deletions
+38
View File
@@ -212,3 +212,41 @@ def search(args: dict, **kwargs) -> str:
if args.get("regex"):
payload["regex"] = True
return _call_tool(args.get("site") or "", "codebase_search", payload)
def build_page(args: dict, **kwargs) -> str:
"""Build/update a Word Page Builder page (wraps the site's wpb_build_page tool)."""
title = str(args.get("title") or "").strip()
if not title:
return _err("Missing 'title'.")
sections = args.get("sections")
if isinstance(sections, str):
try:
sections = json.loads(sections)
except Exception as exc: # noqa: BLE001
return _err(f"'sections' must be a JSON array: {exc}")
if not isinstance(sections, list) or not sections:
return _err("'sections' must be a non-empty array of {kind, html}.")
clean = []
for item in sections:
if isinstance(item, str):
clean.append({"kind": "custom", "html": item})
continue
if not isinstance(item, dict) or "html" not in item:
return _err("Each section needs {kind, html}.")
clean.append({"kind": str(item.get("kind") or "custom"), "html": str(item.get("html") or "")})
payload = {"title": title, "sections": clean}
for key in ("slug", "status"):
val = str(args.get(key) or "").strip()
if val:
payload[key] = val
if args.get("post_id"):
try:
payload["post_id"] = int(args["post_id"])
except Exception: # noqa: BLE001
return _err("'post_id' must be an integer.")
return _call_tool(args.get("site") or "", "wpb_build_page", payload)