feat(mcp): built-in playbooks get steward_url from Steward itself
#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:
@@ -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("/")
|
||||
|
||||
Reference in New Issue
Block a user