feat(mcp): built-in playbooks get steward_url from Steward itself
CI / lint (push) Successful in 3s
CI / integration (push) Successful in 48s
CI / unit (push) Successful in 1m11s
CI / publish (push) Successful in 1m23s

#5015 "Built-in host-agent playbooks make an MCP caller supply steward_url"

- run_playbook, create_schedule and set_alert_action fill a steward-builtin
  playbook's steward_url when the caller leaves it out or empty, from
  Settings → General → Public base URL, else the scheme and host the MCP
  request arrived on — the same source the web actions use.
- run_playbook's reply names what it filled (filled_by_steward), and
  get_playbook shows that value as the variable's default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-06 10:30:23 -04:00
co-authored by Claude Opus 5.5
parent 06e89308a8
commit 1d9ac2b46a
4 changed files with 78 additions and 6 deletions
+12
View File
@@ -18,6 +18,8 @@ if TYPE_CHECKING:
_caller_ctx: ContextVar["Caller | None"] = ContextVar("steward_mcp_caller", default=None)
_app_ctx: ContextVar["Quart | None"] = ContextVar("steward_mcp_app", default=None)
# The scheme and host the caller reached /mcp on, e.g. "https://steward.example".
_base_url_ctx: ContextVar[str] = ContextVar("steward_mcp_base_url", default="")
def current_caller() -> "Caller":
@@ -36,3 +38,13 @@ def mcp_app() -> "Quart":
if app is None:
raise RuntimeError("no Steward app in MCP context")
return app
def public_url() -> str:
"""Steward's externally reachable base URL, as the web side's
public_base_url() gives it: Settings → General → Public base URL when set,
else the scheme and host this MCP request arrived on; "" when neither is
known."""
app = _app_ctx.get()
configured = (app.config.get("PUBLIC_BASE_URL") or "").strip() if app is not None else ""
return (configured or _base_url_ctx.get()).rstrip("/")