Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(workflows): return metadata-only workflow list over MCP (#70296)

posthog[bot]aa573d40f763
diff --git a/products/workflows/backend/api/hog_flow.py b/products/workflows/backend/api/hog_flow.py
index d3459afc675d..bf301f9a5570 100644
--- a/products/workflows/backend/api/hog_flow.py
+++ b/products/workflows/backend/api/hog_flow.py
@@ -839,6 +839,27 @@ class HogFlowMinimalSerializer(UserAccessControlSerializerMixin, serializers.Mod
read_only_fields = fields
+class HogFlowSummarySerializer(HogFlowMinimalSerializer):
+ # Metadata-only listing view. Deliberately omits the action graph (actions/edges) and other
+ # detail-only fields: an action's `config` can hold credential-like values (e.g. a webhook
+ # Authorization header), and a workflow *listing* must not broaden their visibility. Full
+ # definitions stay behind retrieve. Used for MCP list requests; see get_serializer_class.
+ class Meta(HogFlowMinimalSerializer.Meta):
+ fields = [
+ "id",
+ "name",
+ "description",
+ "version",
+ "status",
+ "created_at",
+ "created_by",
+ "updated_at",
+ "trigger",
+ "user_access_level",
+ ]
+ read_only_fields = fields
+
+
class HogFlowSerializer(HogFlowMinimalSerializer):
name = serializers.CharField(
max_length=400, required=False, allow_null=True, allow_blank=True, help_text="Workflow name."
@@ -1308,7 +1329,15 @@ class HogFlowViewSet(
return None
def get_serializer_class(self) -> type[BaseSerializer]:
- return HogFlowMinimalSerializer if self.action == "list" else HogFlowSerializer
+ if self.action == "list":
+ # MCP list ("workflows-list") is a discovery/summary tool — return metadata only so it
+ # never exposes action config bodies (which can hold credential-like values). The web app
+ # and raw API keep the full graph, which they legitimately need (e.g. client-side
+ # duplication); MCP callers drill into a single workflow via retrieve instead.
+ if self.request is not None and self._is_mcp_request(self.request):
+ return HogFlowSummarySerializer
+ return HogFlowMinimalSerializer
+ return HogFlowSerializer
def get_serializer_context(self) -> dict:
# Drives draft strictness in the serializers: web-builder drafts stay lenient, programmatic
diff --git a/products/workflows/backend/api/test/test_hog_flow.py b/products/workflows/backend/api/test/test_hog_flow.py
index 45aa748c549c..ce801ea9e4ab 100644
--- a/products/workflows/backend/api/test/test_hog_flow.py
+++ b/products/workflows/backend/api/test/test_hog_flow.py
@@ -94,6 +94,37 @@ class TestHogFlowAPI(APIBaseTest):
assert response.status_code == 201, response.json()
return response.json()["id"]
+ def test_mcp_list_is_metadata_only_and_hides_action_secrets(self):
+ # A webhook action whose headers carry a bearer token — the kind of credential-like value
+ # that must not leak from a workflow *listing*.
+ secret = "Bearer super-secret-token-abc123"
+ hog_flow, _ = self._create_hog_flow_with_action(
+ {
+ "template_id": "template-webhook",
+ "inputs": {
+ "url": {"value": "https://example.com"},
+ "headers": {"value": {"Authorization": secret}},
+ },
+ }
+ )
+ create_response = self.client.post(f"/api/projects/{self.team.id}/hog_flows", hog_flow)
+ assert create_response.status_code == 201, create_response.json()
+
+ mcp_response = self.client.get(f"/api/projects/{self.team.id}/hog_flows", HTTP_X_POSTHOG_CLIENT="mcp")
+ assert mcp_response.status_code == 200, mcp_response.json()
+ result = mcp_response.json()["results"][0]
+ assert "actions" not in result
+ assert "edges" not in result
+ assert secret not in mcp_response.content.decode()
+
+ # The web app / raw API still get the full graph they rely on (e.g. client-side duplication) —
+ # and it does carry the secret, proving the MCP omission above is the summary serializer at
+ # work, not validation quietly dropping the header.
+ web_response = self.client.get(f"/api/projects/{self.team.id}/hog_flows")
+ assert web_response.status_code == 200, web_response.json()
+ assert "actions" in web_response.json()["results"][0]
+ assert secret in web_response.content.decode()
+
def test_stale_update_is_rejected_with_409(self):
flow_id = self._create_simple_flow()
flow = HogFlow.objects.get(pk=flow_id)