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): drop step inputs from workflow write responses over MCP (#125372)

Meikel Ratz51ecc4da4d06
diff --git a/products/workflows/mcp/tools.yaml b/products/workflows/mcp/tools.yaml
index 59d786f0fb18..b2c5e8aabb2b 100644
--- a/products/workflows/mcp/tools.yaml
+++ b/products/workflows/mcp/tools.yaml
@@ -60,6 +60,10 @@ tools:
inject_body:
origin_product: broadcasts
url_prefix: /broadcasts
+ response:
+ exclude:
+ - actions.*.config.inputs
+ - draft.actions.*.config.inputs
workflows-convert-to-broadcast:
operation: hog_flows_convert_to_broadcast
enabled: true
@@ -120,6 +124,10 @@ tools:
least N times over the last M days') is unsupported; reject it and explain why.
ui_app: workflow
hooks: workflows/broadcastLinkHooks
+ response:
+ exclude:
+ - actions.*.config.inputs
+ - draft.actions.*.config.inputs
workflows-data-suggestions-create:
operation: workflow_data_suggestions_build
enabled: true
@@ -218,6 +226,10 @@ tools:
Throw away a workflow's staged draft without touching the live config. Idempotent — discarding when nothing
is staged is a no-op. Returns the workflow.
ui_app: workflow
+ response:
+ exclude:
+ - actions.*.config.inputs
+ - draft.actions.*.config.inputs
workflows-email-drafts-create:
operation: workflow_data_suggestions_build_for_events
enabled: true
@@ -484,9 +496,14 @@ tools:
email_patch to change subject, preheader, text, or recipients. After design ops the HTML is re-rendered
server-side, so the sent email always matches the design. Edits apply atomically: an invalid batch changes
nothing. On an active workflow, edits stage a draft (composing with any staged graph edits) and nothing
- reaches real people until workflows-publish. The full updated workflow is returned. Prefer this over
- workflows-patch-graph update_action for email content - it's smaller to send and keeps design and HTML in
- sync. For library templates use workflows-patch-email-template instead.
+ reaches real people until workflows-publish. The updated workflow is returned without step inputs; read one
+ back with workflows-get. Prefer this over workflows-patch-graph update_action for email content - it's
+ smaller to send and keeps design and HTML in sync. For library templates use workflows-patch-email-template
+ instead.
+ response:
+ exclude:
+ - actions.*.config.inputs
+ - draft.actions.*.config.inputs
workflows-patch-graph:
operation: hog_flows_graph_partial_update
enabled: true
@@ -507,10 +524,14 @@ tools:
validated (dangling edges, branch indexes, single trigger), and saved only if valid — otherwise nothing
changes. On an active workflow, patches stage a draft instead of changing what's running: the first patch
copies the live graph into the draft, later patches compose onto it, and nothing reaches real people until
- workflows-publish. The full updated workflow is returned, so you don't need to re-fetch before the next
- edit. When adding or editing a conditional_branch, each condition needs a 'filters' wrapper:
- {filters:{properties:[...]}}, not {properties:[...]} on the condition. Re-test the changed path with
- workflows-test-run after patching.
+ workflows-publish. The updated workflow is returned without step inputs, so you can confirm every step's id
+ and type without re-fetching; read a step's inputs back with workflows-get. When adding or editing a
+ conditional_branch, each condition needs a 'filters' wrapper: {filters:{properties:[...]}}, not
+ {properties:[...]} on the condition. Re-test the changed path with workflows-test-run after patching.
+ response:
+ exclude:
+ - actions.*.config.inputs
+ - draft.actions.*.config.inputs
workflows-publish:
operation: hog_flows_publish_create
enabled: true
@@ -533,6 +554,10 @@ tools:
delays apply to parked runs via a spread sweep: runs already waking soon keep their original time, and wakes
moved earlier by the sweep trickle in from a few minutes after publish rather than all at once - so runs
still parked shortly after publishing are normal, not a sign of a failed publish.
+ response:
+ exclude:
+ - workflow.actions.*.config.inputs
+ - workflow.draft.actions.*.config.inputs
workflows-reputation-get:
operation: hog_flows_reputation_retrieve
enabled: true
@@ -579,6 +604,10 @@ tools:
in-flight. A 409 means a draft is already open — publish or discard it, or pass overwrite=true to replace
it. Note what a rollback can't undo: runs that already moved on while the newer version was live keep their
positions.
+ response:
+ exclude:
+ - actions.*.config.inputs
+ - draft.actions.*.config.inputs
workflows-sending-rules-get:
operation: workflow_sending_rules_retrieve
enabled: true
@@ -710,6 +739,10 @@ tools:
- edges
ui_app: workflow
hooks: workflows/broadcastLinkHooks
+ response:
+ exclude:
+ - actions.*.config.inputs
+ - draft.actions.*.config.inputs
workflows-update-schedule:
operation: hog_flows_schedules_partial_update
enabled: true
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index d16f981ac305..96227a34d3d8 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -17052,7 +17052,7 @@
"feature_flag": "workflows-transactional-email-api"
},
"workflows-patch-action-email": {
- "description": "Surgically edit the email inside one function_email step - the fastest path for copy tweaks and design changes on a workflow email. Use operations (the same design ops as workflows-patch-email-template, addressing blocks by id from the step's config.inputs.email.value.design) to edit the design, and email_patch to change subject, preheader, text, or recipients. After design ops the HTML is re-rendered server-side, so the sent email always matches the design. Edits apply atomically: an invalid batch changes nothing. On an active workflow, edits stage a draft (composing with any staged graph edits) and nothing reaches real people until workflows-publish. The full updated workflow is returned. Prefer this over workflows-patch-graph update_action for email content - it's smaller to send and keeps design and HTML in sync. For library templates use workflows-patch-email-template instead.",
+ "description": "Surgically edit the email inside one function_email step - the fastest path for copy tweaks and design changes on a workflow email. Use operations (the same design ops as workflows-patch-email-template, addressing blocks by id from the step's config.inputs.email.value.design) to edit the design, and email_patch to change subject, preheader, text, or recipients. After design ops the HTML is re-rendered server-side, so the sent email always matches the design. Edits apply atomically: an invalid batch changes nothing. On an active workflow, edits stage a draft (composing with any staged graph edits) and nothing reaches real people until workflows-publish. The updated workflow is returned without step inputs; read one back with workflows-get. Prefer this over workflows-patch-graph update_action for email content - it's smaller to send and keeps design and HTML in sync. For library templates use workflows-patch-email-template instead.",
"category": "Workflows",
"feature": "workflows",
"summary": "Patch a workflow step's email",
@@ -17082,7 +17082,7 @@
}
},
"workflows-patch-graph": {
- "description": "Surgically edit a workflow's graph by sending a small, ordered list of operations instead of resending every action and edge. Prefer this over workflows-update for any graph change — to tweak one node's config use update_action with a deep-merge patch (e.g. change just an email subject), and use add_action / remove_action / add_edge / remove_edge / replace_action_edges for structural changes. Reference nodes and edges by id. Operations apply atomically: the graph is read, the ops applied in order, the result fully validated (dangling edges, branch indexes, single trigger), and saved only if valid — otherwise nothing changes. On an active workflow, patches stage a draft instead of changing what's running: the first patch copies the live graph into the draft, later patches compose onto it, and nothing reaches real people until workflows-publish. The full updated workflow is returned, so you don't need to re-fetch before the next edit. When adding or editing a conditional_branch, each condition needs a 'filters' wrapper: {filters:{properties:[...]}}, not {properties:[...]} on the condition. Re-test the changed path with workflows-test-run after patching.",
+ "description": "Surgically edit a workflow's graph by sending a small, ordered list of operations instead of resending every action and edge. Prefer this over workflows-update for any graph change — to tweak one node's config use update_action with a deep-merge patch (e.g. change just an email subject), and use add_action / remove_action / add_edge / remove_edge / replace_action_edges for structural changes. Reference nodes and edges by id. Operations apply atomically: the graph is read, the ops applied in order, the result fully validated (dangling edges, branch indexes, single trigger), and saved only if valid — otherwise nothing changes. On an active workflow, patches stage a draft instead of changing what's running: the first patch copies the live graph into the draft, later patches compose onto it, and nothing reaches real people until workflows-publish. The updated workflow is returned without step inputs, so you can confirm every step's id and type without re-fetching; read a step's inputs back with workflows-get. When adding or editing a conditional_branch, each condition needs a 'filters' wrapper: {filters:{properties:[...]}}, not {properties:[...]} on the condition. Re-test the changed path with workflows-test-run after patching.",
"category": "Workflows",
"feature": "workflows",
"summary": "Patch workflow graph",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index b18862a4420b..5c94a4f5f855 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -17871,7 +17871,7 @@
"feature_flag": "workflows-transactional-email-api"
},
"workflows-patch-action-email": {
- "description": "Surgically edit the email inside one function_email step - the fastest path for copy tweaks and design changes on a workflow email. Use operations (the same design ops as workflows-patch-email-template, addressing blocks by id from the step's config.inputs.email.value.design) to edit the design, and email_patch to change subject, preheader, text, or recipients. After design ops the HTML is re-rendered server-side, so the sent email always matches the design. Edits apply atomically: an invalid batch changes nothing. On an active workflow, edits stage a draft (composing with any staged graph edits) and nothing reaches real people until workflows-publish. The full updated workflow is returned. Prefer this over workflows-patch-graph update_action for email content - it's smaller to send and keeps design and HTML in sync. For library templates use workflows-patch-email-template instead.",
+ "description": "Surgically edit the email inside one function_email step - the fastest path for copy tweaks and design changes on a workflow email. Use operations (the same design ops as workflows-patch-email-template, addressing blocks by id from the step's config.inputs.email.value.design) to edit the design, and email_patch to change subject, preheader, text, or recipients. After design ops the HTML is re-rendered server-side, so the sent email always matches the design. Edits apply atomically: an invalid batch changes nothing. On an active workflow, edits stage a draft (composing with any staged graph edits) and nothing reaches real people until workflows-publish. The updated workflow is returned without step inputs; read one back with workflows-get. Prefer this over workflows-patch-graph update_action for email content - it's smaller to send and keeps design and HTML in sync. For library templates use workflows-patch-email-template instead.",
"category": "Workflows",
"feature": "workflows",
"summary": "Patch a workflow step's email",
@@ -17901,7 +17901,7 @@
}
},
"workflows-patch-graph": {
- "description": "Surgically edit a workflow's graph by sending a small, ordered list of operations instead of resending every action and edge. Prefer this over workflows-update for any graph change — to tweak one node's config use update_action with a deep-merge patch (e.g. change just an email subject), and use add_action / remove_action / add_edge / remove_edge / replace_action_edges for structural changes. Reference nodes and edges by id. Operations apply atomically: the graph is read, the ops applied in order, the result fully validated (dangling edges, branch indexes, single trigger), and saved only if valid — otherwise nothing changes. On an active workflow, patches stage a draft instead of changing what's running: the first patch copies the live graph into the draft, later patches compose onto it, and nothing reaches real people until workflows-publish. The full updated workflow is returned, so you don't need to re-fetch before the next edit. When adding or editing a conditional_branch, each condition needs a 'filters' wrapper: {filters:{properties:[...]}}, not {properties:[...]} on the condition. Re-test the changed path with workflows-test-run after patching.",
+ "description": "Surgically edit a workflow's graph by sending a small, ordered list of operations instead of resending every action and edge. Prefer this over workflows-update for any graph change — to tweak one node's config use update_action with a deep-merge patch (e.g. change just an email subject), and use add_action / remove_action / add_edge / remove_edge / replace_action_edges for structural changes. Reference nodes and edges by id. Operations apply atomically: the graph is read, the ops applied in order, the result fully validated (dangling edges, branch indexes, single trigger), and saved only if valid — otherwise nothing changes. On an active workflow, patches stage a draft instead of changing what's running: the first patch copies the live graph into the draft, later patches compose onto it, and nothing reaches real people until workflows-publish. The updated workflow is returned without step inputs, so you can confirm every step's id and type without re-fetching; read a step's inputs back with workflows-get. When adding or editing a conditional_branch, each condition needs a 'filters' wrapper: {filters:{properties:[...]}}, not {properties:[...]} on the condition. Re-test the changed path with workflows-test-run after patching.",
"category": "Workflows",
"feature": "workflows",
"summary": "Patch workflow graph",
diff --git a/services/mcp/src/tools/generated/workflows.ts b/services/mcp/src/tools/generated/workflows.ts
index 2f7fdd3a4fb3..6639564f8b2d 100644
--- a/services/mcp/src/tools/generated/workflows.ts
+++ b/services/mcp/src/tools/generated/workflows.ts
@@ -6,7 +6,7 @@ import * as orvalSchemas from '@/generated/workflows/api'
import { withUiApp } from '@/resources/ui-apps'
import { WorkflowActionEmailPatchSchema, WorkflowGraphPatchSchema } from '@/schema/tool-inputs'
import { transformRequestBody, withToolHooks } from '@/tools/tool-hooks'
-import { withPostHogUrl, pickResponseFields, type WithPostHogUrl } from '@/tools/tool-utils'
+import { withPostHogUrl, omitResponseFields, pickResponseFields, type WithPostHogUrl } from '@/tools/tool-utils'
import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'
import hooks_workflowsCreate from '@/tools/workflows/broadcastLinkHooks'
import hooks_workflowsGet from '@/tools/workflows/broadcastLinkHooks'
@@ -69,7 +69,11 @@ const broadcastsCreate = (): ToolBase<ReturnType<typeof BroadcastsCreateSchema>,
path: `/api/projects/${encodeURIComponent(String(projectId))}/hog_flows/`,
body,
})
- return await withPostHogUrl(context, result, `/broadcasts/${result.id}`)
+ const filtered = omitResponseFields(result, [
+ 'actions.*.config.inputs',
+ 'draft.actions.*.config.inputs',
+ ]) as typeof result
+ return await withPostHogUrl(context, filtered, `/broadcasts/${filtered.id}`)
},
})
@@ -152,7 +156,11 @@ const workflowsCreate = (): ToolBase<ReturnType<typeof WorkflowsCreateSchema>, W
path: `/api/projects/${encodeURIComponent(String(projectId))}/hog_flows/`,
body: await transformRequestBody(hooks_workflowsCreate, context, params, body),
})
- return await withPostHogUrl(context, result, `/workflows/${result.id}/workflow`)
+ const filtered = omitResponseFields(result, [
+ 'actions.*.config.inputs',
+ 'draft.actions.*.config.inputs',
+ ]) as typeof result
+ return await withPostHogUrl(context, filtered, `/workflows/${filtered.id}/workflow`)
}
),
})
@@ -278,7 +286,11 @@ const workflowsDiscardDraft = (): ToolBase<ReturnType<typeof WorkflowsDiscardDra
method: 'POST',
path: `/api/projects/${encodeURIComponent(String(projectId))}/hog_flows/${encodeURIComponent(String(params.id))}/discard_draft/`,
})
- return result
+ const filtered = omitResponseFields(result, [
+ 'actions.*.config.inputs',
+ 'draft.actions.*.config.inputs',
+ ]) as typeof result
+ return filtered
},
})
@@ -685,7 +697,11 @@ const workflowsPatchActionEmail = (): ToolBase<
path: `/api/projects/${encodeURIComponent(String(projectId))}/hog_flows/${encodeURIComponent(String(id))}/actions/${encodeURIComponent(String(action_id))}/email/`,
body,
})
- return result
+ const filtered = omitResponseFields(result, [
+ 'actions.*.config.inputs',
+ 'draft.actions.*.config.inputs',
+ ]) as typeof result
+ return filtered
},
})
@@ -703,7 +719,11 @@ const workflowsPatchGraph = (): ToolBase<ReturnType<typeof WorkflowsPatchGraphSc
path: `/api/projects/${encodeURIComponent(String(projectId))}/hog_flows/${encodeURIComponent(String(id))}/graph/`,
body,
})
- return result
+ const filtered = omitResponseFields(result, [
+ 'actions.*.config.inputs',
+ 'draft.actions.*.config.inputs',
+ ]) as typeof result
+ return filtered
},
})
@@ -730,7 +750,11 @@ const workflowsPublish = (): ToolBase<ReturnType<typeof WorkflowsPublishSchema>,
path: `/api/projects/${encodeURIComponent(String(projectId))}/hog_flows/${encodeURIComponent(String(params.id))}/publish/`,
body,
})
- return result
+ const filtered = omitResponseFields(result, [
+ 'workflow.actions.*.config.inputs',
+ 'workflow.draft.actions.*.config.inputs',
+ ]) as typeof result
+ return filtered
},
})
@@ -821,7 +845,11 @@ const workflowsRestoreRevision = (): ToolBase<ReturnType<typeof WorkflowsRestore
path: `/api/projects/${encodeURIComponent(String(projectId))}/hog_flows/${encodeURIComponent(String(params.id))}/revisions/${encodeURIComponent(String(params.version))}/restore/`,
body,
})
- return result
+ const filtered = omitResponseFields(result, [
+ 'actions.*.config.inputs',
+ 'draft.actions.*.config.inputs',
+ ]) as typeof result
+ return filtered
},
})
@@ -1046,7 +1074,11 @@ const workflowsUpdate = (): ToolBase<ReturnType<typeof WorkflowsUpdateSchema>, W
path: `/api/projects/${encodeURIComponent(String(projectId))}/hog_flows/${encodeURIComponent(String(params.id))}/`,
body: await transformRequestBody(hooks_workflowsUpdate, context, params, body),
})
- return await withPostHogUrl(context, result, `/workflows/${result.id}/workflow`)
+ const filtered = omitResponseFields(result, [
+ 'actions.*.config.inputs',
+ 'draft.actions.*.config.inputs',
+ ]) as typeof result
+ return await withPostHogUrl(context, filtered, `/workflows/${filtered.id}/workflow`)
}
),
})
diff --git a/services/mcp/src/tools/workflows/lifecycle.ts b/services/mcp/src/tools/workflows/lifecycle.ts
index abd516486e0e..e72a590b104a 100644
--- a/services/mcp/src/tools/workflows/lifecycle.ts
+++ b/services/mcp/src/tools/workflows/lifecycle.ts
@@ -3,7 +3,7 @@ import { z } from 'zod'
import type { Schemas } from '@/api/generated'
import { HogFlowsPartialUpdateParams } from '@/generated/workflows/api'
import { withUiApp } from '@/resources/ui-apps'
-import { withPostHogUrl, type WithPostHogUrl } from '@/tools/tool-utils'
+import { omitResponseFields, withPostHogUrl, type WithPostHogUrl } from '@/tools/tool-utils'
import type { Context, ToolBase } from '@/tools/types'
import { hogFlowPath } from '@/tools/workflows/hogFlowLink'
@@ -12,6 +12,9 @@ const LifecycleSchema = HogFlowsPartialUpdateParams().omit({ project_id: true })
type LifecycleParams = z.infer<typeof LifecycleSchema>
type LifecycleResult = WithPostHogUrl<Schemas.HogFlow>
+// Kept in sync with response.exclude on the generated workflow write tools in products/workflows/mcp/tools.yaml.
+const WITHOUT_STEP_INPUTS = ['actions.*.config.inputs', 'draft.actions.*.config.inputs']
+
const patchStatus = async (
context: Context,
params: LifecycleParams,
@@ -23,7 +26,8 @@ const patchStatus = async (
path: `/api/projects/${encodeURIComponent(String(projectId))}/hog_flows/${encodeURIComponent(String(params.id))}/`,
body: { status },
})
- return await withPostHogUrl(context, result, hogFlowPath(result))
+ const compact = omitResponseFields(result, WITHOUT_STEP_INPUTS) as Schemas.HogFlow
+ return await withPostHogUrl(context, compact, hogFlowPath(compact))
}
export const workflowsEnable = (): ToolBase<typeof LifecycleSchema, LifecycleResult> =>
diff --git a/services/mcp/tests/unit/workflow-write-response-shape.test.ts b/services/mcp/tests/unit/workflow-write-response-shape.test.ts
new file mode 100644
index 000000000000..3489f3abb5bc
--- /dev/null
+++ b/services/mcp/tests/unit/workflow-write-response-shape.test.ts
@@ -0,0 +1,87 @@
+import { describe, expect, it, vi } from 'vitest'
+
+import { GENERATED_TOOLS } from '@/tools/generated/workflows'
+import type { Context } from '@/tools/types'
+import { workflowsEnable } from '@/tools/workflows/lifecycle'
+
+function createMockContext(requestMock: ReturnType<typeof vi.fn>): Context {
+ return {
+ api: {
+ request: requestMock,
+ getProjectBaseUrl: (projectId: string) => `https://us.posthog.com/project/${projectId}`,
+ } as any,
+ stateManager: { getProjectId: vi.fn().mockResolvedValue('42') } as any,
+ env: {} as any,
+ sessionManager: {} as any,
+ cache: {} as any,
+ getDistinctId: async () => 'test-distinct-id',
+ trackEvent: async () => {},
+ }
+}
+
+const emailStep = (): Record<string, unknown> => ({
+ id: 'email_1',
+ type: 'function_email',
+ name: 'Day 1: welcome',
+ config: {
+ type: 'function_email',
+ template_id: 'template-email',
+ inputs: { email: { value: { html: 'x'.repeat(20000), design: { body: { rows: [] } } } } },
+ },
+})
+
+const workflow = (): Record<string, unknown> => ({
+ id: 'wf-1',
+ name: 'Onboarding',
+ status: 'active',
+ version: 28,
+ actions: [emailStep()],
+ edges: [{ from: 'trigger', to: 'email_1' }],
+ draft: { actions: [emailStep()], edges: [] },
+})
+
+function expectStepWithoutInputs(step: any): void {
+ expect(step).toMatchObject({ id: 'email_1', type: 'function_email', name: 'Day 1: welcome' })
+ expect(step.config).not.toHaveProperty('inputs')
+ // broadcastLinkHooks reads config.type to offer the broadcast conversion, so the omit
+ // has to take `config.inputs` and not `config`.
+ expect(step.config).toMatchObject({ type: 'function_email' })
+}
+
+describe('workflow write response shape', () => {
+ it('drops step inputs from a graph patch response', async () => {
+ const request = vi.fn().mockResolvedValue(workflow())
+
+ const result: any = await GENERATED_TOOLS['workflows-patch-graph']!().handler(createMockContext(request), {
+ id: 'wf-1',
+ operations: [{ op: 'remove_action', id: 'email_2' }],
+ } as any)
+
+ expectStepWithoutInputs(result.actions[0])
+ expectStepWithoutInputs(result.draft.actions[0])
+ })
+
+ it('drops step inputs from an enable response', async () => {
+ const request = vi.fn().mockResolvedValue(workflow())
+
+ const result: any = await workflowsEnable().handler(createMockContext(request), { id: 'wf-1' } as any)
+
+ expect(result.status).toBe('active')
+ expectStepWithoutInputs(result.actions[0])
+ expectStepWithoutInputs(result.draft.actions[0])
+ })
+
+ it('drops step inputs from the workflow nested in a publish response', async () => {
+ // An unmatched omit path is dropped with no error, which would put the whole graph back on the wire.
+ const request = vi.fn().mockResolvedValue({ published: true, impact: null, workflow: workflow() })
+
+ const result: any = await GENERATED_TOOLS['workflows-publish']!().handler(createMockContext(request), {
+ id: 'wf-1',
+ confirm: true,
+ } as any)
+
+ expect(result.published).toBe(true)
+ expectStepWithoutInputs(result.workflow.actions[0])
+ expectStepWithoutInputs(result.workflow.draft.actions[0])
+ })
+})