diff --git a/mcpo/flowagent/Dockerfile b/mcpo/flowagent/Dockerfile new file mode 100644 index 0000000..edfa2d2 --- /dev/null +++ b/mcpo/flowagent/Dockerfile @@ -0,0 +1,21 @@ +FROM ghcr.io/open-webui/mcpo:main + +# Azure CLI — required for non-interactive service-principal auth +# (`az login --service-principal`) performed by entrypoint.sh at container +# start. FlowAgent's auth model is Azure CLI + MSAL; see +# https://github.com/microsoft/power-platform-skills/blob/main/plugins/power-automate/references/connection-patterns.md +RUN apk add --no-cache py3-pip curl \ + && pip install --no-cache-dir --break-system-packages azure-cli + +# FlowAgent self-contained MCP bundle (stdio transport, all tools inlined, +# Node 18+ only — no npm install / remote host needed at runtime). +# Pinned to a ref (commit SHA or tag), NOT `main`, for reproducible builds. +# Bump deliberately via PR when upstream ships updates: +# https://github.com/microsoft/power-platform-skills/tree/main/plugins/power-automate/server +ARG FLOWAGENT_REF=main +RUN mkdir -p /app/flowagent \ + && curl -fsSL "https://raw.githubusercontent.com/microsoft/power-platform-skills/${FLOWAGENT_REF}/plugins/power-automate/server/mcp.mjs" \ + -o /app/flowagent/mcp.mjs + +COPY entrypoint.sh /app/flowagent/entrypoint.sh +RUN chmod +x /app/flowagent/entrypoint.sh diff --git a/mcpo/flowagent/entrypoint.sh b/mcpo/flowagent/entrypoint.sh new file mode 100644 index 0000000..bea9d68 --- /dev/null +++ b/mcpo/flowagent/entrypoint.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# FlowAgent MCP entrypoint — non-interactive Azure service-principal login. +# +# Expects three env vars pointing at Docker secret files (Pattern C, +# _FILE convention, provisioned by Woodpecker — never hand-typed): +# FLOWAGENT_AZURE_CLIENT_ID_FILE +# FLOWAGENT_AZURE_TENANT_ID_FILE +# FLOWAGENT_AZURE_CLIENT_SECRET_FILE +# +# On success, execs into the real command (node /app/flowagent/mcp.mjs), +# replacing this shell so mcpo's stdio pipe talks directly to the MCP process. +set -eu + +: "${FLOWAGENT_AZURE_CLIENT_ID_FILE:?FLOWAGENT_AZURE_CLIENT_ID_FILE not set}" +: "${FLOWAGENT_AZURE_TENANT_ID_FILE:?FLOWAGENT_AZURE_TENANT_ID_FILE not set}" +: "${FLOWAGENT_AZURE_CLIENT_SECRET_FILE:?FLOWAGENT_AZURE_CLIENT_SECRET_FILE not set}" + +CLIENT_ID="$(cat "$FLOWAGENT_AZURE_CLIENT_ID_FILE")" +TENANT_ID="$(cat "$FLOWAGENT_AZURE_TENANT_ID_FILE")" +CLIENT_SECRET="$(cat "$FLOWAGENT_AZURE_CLIENT_SECRET_FILE")" + +az login --service-principal \ + -u "$CLIENT_ID" \ + -p "$CLIENT_SECRET" \ + --tenant "$TENANT_ID" \ + --output none + +unset CLIENT_SECRET + +exec "$@" diff --git a/secrets/flowagent.secrets.example b/secrets/flowagent.secrets.example new file mode 100644 index 0000000..171205b --- /dev/null +++ b/secrets/flowagent.secrets.example @@ -0,0 +1,53 @@ +# flowagent (Power Automate MCP, via mcpo service) — Secrets Reference +# Source: mcpo/flowagent — built into a custom image, consumed by the +# "mcpo" service in ai.yaml (NEVER mcpo-critical). +# +# Add SECRET values to Woodpecker at: +# https://woodpecker.bryanmail.net +# homelab/compose-files → Settings → Secrets +# +# Prerequisite (manual, outside GitOps — Azure Portal): +# 1. Entra ID → App registrations → New registration +# Name: flowagent-mcp-homelab, single tenant +# 2. API permissions → add Power Automate / Flow Service application +# permissions + Dynamics CRM user_impersonation (Dataverse access) +# 3. Grant admin consent +# 4. Certificates & secrets → new client secret → copy value immediately +# 5. Power Platform Admin Center → target environment → S2S apps → +# register the application user for this app ID (required for +# Dataverse/environment access by a service principal) +# +# NOTE: the OLD "powerautomate" mcpo/config.json entry (npm package +# powerautomate-mcp, client_id 84b431ed-..., tenant_id 0f6cf991-...) was +# never onboarded to this secrets pipeline and is being replaced by this. +# Do not reuse those IDs unless you've independently confirmed in Azure +# Portal that the old App Registration still exists, still has valid +# permissions/consent, and you intend to reuse it — otherwise register new. + +# ── SECRETS (add to Woodpecker) ────────────────────────────────────────── + +# Woodpecker secret name: flowagent_azure_client_id +# Used for: Azure AD App Registration client ID +# Env var in entrypoint: FLOWAGENT_AZURE_CLIENT_ID_FILE (Docker secret _FILE) +flowagent_azure_client_id= + +# Woodpecker secret name: flowagent_azure_tenant_id +# Used for: Azure AD tenant ID +# Env var in entrypoint: FLOWAGENT_AZURE_TENANT_ID_FILE (Docker secret _FILE) +flowagent_azure_tenant_id= + +# Woodpecker secret name: flowagent_azure_client_secret +# Used for: Azure AD App Registration client secret (rotate if leaked) +# Env var in entrypoint: FLOWAGENT_AZURE_CLIENT_SECRET_FILE (Docker secret _FILE) +flowagent_azure_client_secret= + +# ── Woodpecker provision-secrets case entry ────────────────────────────── +# Add this to the provision-secrets step in .woodpecker/deploy.yml +# (separate follow-up PR — this file only documents it): +# +# ai) +# ... existing ai-stack secret provisioning ... +# create_or_update_secret "flowagent_azure_client_id" "$FLOWAGENT_AZURE_CLIENT_ID" +# create_or_update_secret "flowagent_azure_tenant_id" "$FLOWAGENT_AZURE_TENANT_ID" +# create_or_update_secret "flowagent_azure_client_secret" "$FLOWAGENT_AZURE_CLIENT_SECRET" +# ;;