: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(workflows): expose the workflow versions listing as an MCP tool (#109846)
Daniel Marchukc34ad53865c1
diff --git a/products/workflows/mcp/tools.yaml b/products/workflows/mcp/tools.yamlindex 403dba8b2b09..5c5b21e14584 100644--- a/products/workflows/mcp/tools.yaml+++ b/products/workflows/mcp/tools.yaml@@ -374,6 +374,23 @@ tools:List a workflow's revision history, newest first. Every live-content change (publish, direct edit) appends aversion; each entry shows version, when, and by whom. Fetch a version's content with workflows-get-revision;roll back with workflows-restore-revision.+ workflows-list-versions:+ operation: hog_flows_revisions_list+ enabled: true+ scopes:+ - hog_flow:read+ annotations:+ readOnly: true+ destructive: false+ idempotent: true+ list: true+ title: List a workflow's published versions+ description: >+ List the published versions of one workflow, newest first, each with the time it went live. Read it to tell+ how long the live version has been sending before you trust its metrics: a version whose sends began in the+ last two days has not had time to collect opens. A workflow never published since version history began has+ no rows here, so its live version is missing: judge that one's age from when its sends began in+ workflows-stats instead. Takes the workflow id as 'id'.workflows-logs:operation: hog_flows_logs_retrieveenabled: truediff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 0d2ba776b6a0..a66b31f6479d 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -14492,6 +14492,20 @@"readOnlyHint": true}},+ "workflows-list-versions": {+ "description": "List the published versions of one workflow, newest first, each with the time it went live. Read it to tell how long the live version has been sending before you trust its metrics: a version whose sends began in the last two days has not had time to collect opens. A workflow never published since version history began has no rows here, so its live version is missing: judge that one's age from when its sends began in workflows-stats instead. Takes the workflow id as 'id'.",+ "category": "Workflows",+ "feature": "workflows",+ "summary": "List a workflow's published versions",+ "title": "List a workflow's published versions",+ "required_scopes": ["hog_flow:read"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ }+ },"workflows-logs": {"description": "Retrieve execution logs for a specific workflow by ID. Returns log entries with timestamp, level (DEBUG, LOG, INFO, WARN, ERROR), and message. Use to debug why a workflow is failing or not producing expected results. Supports filtering by log level, text search, time range (after/before), and pagination via limit.","category": "Workflows",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 608c941a5e76..dc7559cfcd70 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -15212,6 +15212,20 @@"readOnlyHint": true}},+ "workflows-list-versions": {+ "description": "List the published versions of one workflow, newest first, each with the time it went live. Read it to tell how long the live version has been sending before you trust its metrics: a version whose sends began in the last two days has not had time to collect opens. A workflow never published since version history began has no rows here, so its live version is missing: judge that one's age from when its sends began in workflows-stats instead. Takes the workflow id as 'id'.",+ "category": "Workflows",+ "feature": "workflows",+ "summary": "List a workflow's published versions",+ "title": "List a workflow's published versions",+ "required_scopes": ["hog_flow:read"],+ "annotations": {+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": true,+ "readOnlyHint": true+ }+ },"workflows-logs": {"description": "Retrieve execution logs for a specific workflow by ID. Returns log entries with timestamp, level (DEBUG, LOG, INFO, WARN, ERROR), and message. Use to debug why a workflow is failing or not producing expected results. Supports filtering by log level, text search, time range (after/before), and pagination via limit.","category": "Workflows",diff --git a/services/mcp/src/tools/generated/workflows.ts b/services/mcp/src/tools/generated/workflows.tsindex b250985c0124..8aa5d2050adc 100644--- a/services/mcp/src/tools/generated/workflows.ts+++ b/services/mcp/src/tools/generated/workflows.ts@@ -362,6 +362,32 @@ const workflowsListRevisions = (): ToolBase<},})+const WorkflowsListVersionsSchema = () => {+ const HogFlowsRevisionsListParams = orvalSchemas.HogFlowsRevisionsListParams()+ const HogFlowsRevisionsListQueryParams = orvalSchemas.HogFlowsRevisionsListQueryParams()+ return HogFlowsRevisionsListParams.omit({ project_id: true }).extend(HogFlowsRevisionsListQueryParams.shape)+}++const workflowsListVersions = (): ToolBase<+ ReturnType<typeof WorkflowsListVersionsSchema>,+ WithPostHogUrl<Schemas.PaginatedHogFlowRevisionBasicList>+> => ({+ name: 'workflows-list-versions',+ schema: WorkflowsListVersionsSchema(),+ handler: async (context: Context, params: z.infer<ReturnType<typeof WorkflowsListVersionsSchema>>) => {+ const projectId = await context.stateManager.getProjectId()+ const result = await context.api.request<Schemas.PaginatedHogFlowRevisionBasicList>({+ method: 'GET',+ path: `/api/projects/${encodeURIComponent(String(projectId))}/hog_flows/${encodeURIComponent(String(params.id))}/revisions/`,+ query: {+ limit: params.limit,+ offset: params.offset,+ },+ })+ return await withPostHogUrl(context, result, '/workflows')+ },+})+const WorkflowsLogsSchema = () => {const HogFlowsLogsRetrieveParams = orvalSchemas.HogFlowsLogsRetrieveParams()const HogFlowsLogsRetrieveQueryParams = orvalSchemas.HogFlowsLogsRetrieveQueryParams()@@ -681,6 +707,7 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {'workflows-list-invocations': workflowsListInvocations,'workflows-list-proposals': workflowsListProposals,'workflows-list-revisions': workflowsListRevisions,+ 'workflows-list-versions': workflowsListVersions,'workflows-logs': workflowsLogs,'workflows-patch-action-email': workflowsPatchActionEmail,'workflows-patch-graph': workflowsPatchGraph,diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-list-versions.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-list-versions.jsonnew file mode 100644index 000000000000..42d84da8dd75--- /dev/null+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflows-list-versions.json@@ -0,0 +1,19 @@+{+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "properties": {+ "id": {+ "description": "A UUID string identifying this hog flow.",+ "type": "string"+ },+ "limit": {+ "description": "Number of results to return per page.",+ "type": "number"+ },+ "offset": {+ "description": "The initial index from which to return the results.",+ "type": "number"+ }+ },+ "required": ["id"],+ "type": "object"+}