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.

chore(mcp): remove the legacy loops tools (#114446)

Charles Vien350bd92bec80
diff --git a/frontend/src/lib/agentScopes.generated.ts b/frontend/src/lib/agentScopes.generated.ts
index 5c6f0ed5199a..c2b56034f26f 100644
--- a/frontend/src/lib/agentScopes.generated.ts
+++ b/frontend/src/lib/agentScopes.generated.ts
@@ -93,8 +93,6 @@ export const AGENT_USE_CASE_SCOPES = [
'llm_skill:write',
'logs:read',
'logs:write',
- 'loop:read',
- 'loop:write',
'marketing_analytics:read',
'marketing_analytics:write',
'mcp_analytics:read',
diff --git a/products/context_layer/mcp/tools.yaml b/products/context_layer/mcp/tools.yaml
index db94910b4c87..049a2b38da8d 100644
--- a/products/context_layer/mcp/tools.yaml
+++ b/products/context_layer/mcp/tools.yaml
@@ -54,51 +54,6 @@ tools:
Replace one context wiki page with complete Markdown content. Read it first and pass its head_sha as
base_head. A concurrent wiki change returns a conflict instead of being overwritten.
feature_flag: context-layer
- loop-context-wiki-channel-resolve:
- operation: context_layer_agent_channel_pages_retrieve
- enabled: true
- scopes:
- - task:read
- - loop_context_internal:write
- annotations:
- readOnly: true
- destructive: false
- idempotent: true
- title: Resolve a loop context wiki page
- description: Resolve a channel id to its context wiki page path for an unattended loop run.
- feature_flag: context-layer
- loop-context-wiki-page-retrieve:
- operation: context_layer_agent_pages_retrieve
- enabled: true
- scopes:
- - task:read
- - loop_context_internal:write
- annotations:
- readOnly: true
- destructive: false
- idempotent: true
- title: Read a loop context wiki page
- description: >
- Read a bounded context wiki page chunk and its head_sha for an unattended loop run. Follow next_offset with
- the same head_sha and limit until complete is true. Join all content chunks before editing. On 409, discard
- the chunks and restart at offset zero.
- param_overrides:
- limit:
- input_schema: WikiPageReadLimitSchema
- feature_flag: context-layer
- loop-context-wiki-page-update:
- operation: context_layer_agent_pages_update
- enabled: true
- scopes:
- - task:write
- - loop_context_internal:write
- annotations:
- readOnly: false
- destructive: true
- idempotent: false
- title: Update a loop context wiki page
- description: Replace a context wiki page using base_head concurrency for an unattended loop run.
- feature_flag: context-layer
task-context-wiki-channel-resolve:
operation: context_layer_agent_channel_pages_retrieve
enabled: true
diff --git a/products/tasks/mcp/apps/LoopReviewView.test.ts b/products/tasks/mcp/apps/LoopReviewView.test.ts
deleted file mode 100644
index a23c94064fc3..000000000000
--- a/products/tasks/mcp/apps/LoopReviewView.test.ts
+++ /dev/null
@@ -1,199 +0,0 @@
-jest.mock('@posthog/mcp-ui', () => ({ DescriptionList: () => null }), {
- virtual: true,
-})
-jest.mock('@posthog/quill', () => ({ Button: () => null, Card: () => null, CardContent: () => null }), {
- virtual: true,
-})
-jest.mock('lucide-react', () => ({ Check: () => null }), { virtual: true })
-
-import {
- describeFixReviewComments,
- describePosthogAccess,
- describeRunBehavior,
- type LoopReviewBehaviors,
- type LoopReviewConnectors,
- type LoopReviewData,
-} from './LoopReviewView'
-
-describe('LoopReviewView', () => {
- describe('describeFixReviewComments', () => {
- it.each<[string, LoopReviewBehaviors | undefined, string]>([
- ['fix_review_comments without watch_ci', { fix_review_comments: true, watch_ci: false }, 'Yes'],
- ['fix_review_comments with watch_ci', { fix_review_comments: true, watch_ci: true }, 'Yes'],
- ['watch_ci only', { fix_review_comments: false, watch_ci: true }, 'No'],
- ['neither flag', { fix_review_comments: false, watch_ci: false }, 'No'],
- ['missing behaviors', undefined, 'No'],
- ['iteration cap', { fix_review_comments: true, max_fix_iterations: 5 }, 'Yes (up to 5 iterations)'],
- ['zero iteration cap', { fix_review_comments: true, max_fix_iterations: 0 }, 'Yes (up to 0 iterations)'],
- ])('%s', (_label, behaviors, expected) => {
- expect(describeFixReviewComments(behaviors)).toBe(expected)
- })
- })
-
- describe('describeRunBehavior', () => {
- it.each<[string, Pick<LoopReviewData, 'triggers' | 'enabled' | 'overlap_policy'>, string]>([
- ['no triggers shows the default overlap policy', {}, 'Manual only · skips overlapping runs'],
- [
- 'cron schedule trigger',
- {
- triggers: [
- {
- type: 'schedule',
- config: { cron_expression: '0 9 * * 1' },
- },
- ],
- },
- 'Schedule (0 9 * * 1) · skips overlapping runs',
- ],
- [
- 'github trigger without events',
- {
- triggers: [
- {
- type: 'github',
- config: { repository: 'posthog/code' },
- },
- ],
- },
- 'GitHub (posthog/code) · skips overlapping runs',
- ],
- [
- 'github trigger lists its events',
- {
- triggers: [
- {
- type: 'github',
- config: {
- repository: 'posthog/code',
- events: ['issues', 'pull_request'],
- },
- },
- ],
- },
- 'GitHub (posthog/code: issues, pull_request) · skips overlapping runs',
- ],
- [
- 'github trigger with an actions filter',
- {
- triggers: [
- {
- type: 'github',
- config: {
- repository: 'posthog/code',
- events: ['issues'],
- filters: { actions: ['opened'] },
- },
- },
- ],
- },
- 'GitHub (posthog/code: issues opened) · skips overlapping runs',
- ],
- [
- 'github trigger with singular action alias',
- {
- triggers: [
- {
- type: 'github',
- config: {
- repository: 'posthog/code',
- events: ['issues'],
- filters: { action: 'opened' },
- },
- },
- ],
- },
- 'GitHub (posthog/code: issues opened) · skips overlapping runs',
- ],
- [
- 'github trigger with dotted event shorthand',
- {
- triggers: [
- {
- type: 'github',
- config: {
- repository: 'posthog/code',
- events: ['issues.opened'],
- },
- },
- ],
- },
- 'GitHub (posthog/code: issues opened) · skips overlapping runs',
- ],
- [
- 'github push trigger with a branch filter',
- {
- triggers: [
- {
- type: 'github',
- config: {
- repository: 'posthog/code',
- events: ['push'],
- filters: { branches: ['main'] },
- },
- },
- ],
- },
- 'GitHub (posthog/code: push on main) · skips overlapping runs',
- ],
- [
- 'github trigger with a label filter',
- {
- triggers: [
- {
- type: 'github',
- config: {
- repository: 'posthog/code',
- events: ['issues'],
- filters: { labels: ['bug'] },
- },
- },
- ],
- },
- 'GitHub (posthog/code: issues labeled bug) · skips overlapping runs',
- ],
- [
- 'github trigger with payload conditions',
- {
- triggers: [
- {
- type: 'github',
- config: {
- repository: 'posthog/posthog',
- events: ['pull_request.review_requested'],
- filters: {
- payload: [
- { path: 'requested_team.slug', equals: ['team-security', 'team-infra'] },
- { path: 'pull_request.draft', equals: 'false' },
- ],
- },
- },
- },
- ],
- },
- 'GitHub (posthog/posthog: pull_request review_requested where requested_team.slug is team-security or team-infra and pull_request.draft is false) · skips overlapping runs',
- ],
- ['paused loop', { enabled: false }, 'Manual only · paused · skips overlapping runs'],
- ['allow policy', { overlap_policy: 'allow' }, 'Manual only · allows overlapping runs'],
- ['cancel_previous policy', { overlap_policy: 'cancel_previous' }, 'Manual only · cancels the previous run'],
- [
- 'unknown policy falls back to the raw value',
- {
- overlap_policy: 'defer' as unknown as LoopReviewData['overlap_policy'],
- },
- 'Manual only · defer',
- ],
- ])('%s', (_label, data, expected) => {
- expect(describeRunBehavior(data)).toBe(expected)
- })
- })
-
- describe('describePosthogAccess', () => {
- it.each<[string, LoopReviewConnectors | undefined, string]>([
- ['missing connectors', undefined, 'Read-only'],
- ['read_only scope', { posthog_mcp_scopes: 'read_only' }, 'Read-only'],
- ['full scope', { posthog_mcp_scopes: 'full' }, 'Full (read-write)'],
- ])('%s', (_label, connectors, expected) => {
- expect(describePosthogAccess(connectors)).toBe(expected)
- })
- })
-})
diff --git a/products/tasks/mcp/apps/LoopReviewView.tsx b/products/tasks/mcp/apps/LoopReviewView.tsx
deleted file mode 100644
index 52bfbb48d051..000000000000
--- a/products/tasks/mcp/apps/LoopReviewView.tsx
+++ /dev/null
@@ -1,335 +0,0 @@
-import { Check } from 'lucide-react'
-import { type ReactElement, type ReactNode } from 'react'
-
-import { DescriptionList } from '@posthog/mcp-ui'
-import { Button, Card, CardContent } from '@posthog/quill'
-
-export interface LoopReviewRepository {
- github_integration_id: number
- full_name: string
-}
-
-export interface LoopReviewTrigger {
- type: 'schedule' | 'github' | 'api' | string
- enabled?: boolean
- config?: Record<string, unknown>
-}
-
-export interface LoopReviewBehaviors {
- create_prs?: boolean
- watch_ci?: boolean
- fix_review_comments?: boolean
- max_fix_iterations?: number
-}
-
-export interface LoopReviewContextOutputs {
- post_to_feed?: boolean
- update_context?: boolean
- canvas_id?: string | null
-}
-
-export interface LoopReviewContextTarget {
- name?: string
- folder_id?: string
- outputs?: LoopReviewContextOutputs
-}
-
-export interface LoopReviewNotificationChannel {
- enabled?: boolean
-}
-
-export interface LoopReviewConnectors {
- mcp_installation_ids?: string[]
- posthog_mcp_scopes?: 'read_only' | 'full'
-}
-
-/** The loop config the agent assembled — identical in shape to the `loops-create` tool
- * arguments, so the "Create loop" button can forward it unchanged. */
-export interface LoopReviewData {
- name?: string
- description?: string
- instructions?: string
- runtime_adapter?: string
- model?: string
- reasoning_effort?: string | null
- visibility?: string
- repositories?: LoopReviewRepository[]
- triggers?: LoopReviewTrigger[]
- enabled?: boolean
- overlap_policy?: 'skip' | 'allow' | 'cancel_previous'
- behaviors?: LoopReviewBehaviors
- connectors?: LoopReviewConnectors
- sandbox_environment?: string | null
- notifications?: Record<string, LoopReviewNotificationChannel>
- context_target?: LoopReviewContextTarget | null
- _posthogUrl?: string
-}
-
-export interface LoopReviewState {
- loading: boolean
- error: string | null
- createdName: string | null
-}
-
-export interface LoopReviewViewProps {
- data: LoopReviewData
- onCreate?: () => Promise<void>
- state?: LoopReviewState
-}
-
-const ADAPTER_LABELS: Record<string, string> = {
- claude: 'Claude Code',
- codex: 'Codex',
-}
-
-function stringList(value: unknown): string[] {
- if (typeof value === 'string') {
- return [value]
- }
- if (Array.isArray(value)) {
- return value.filter((item): item is string => typeof item === 'string')
- }
- return []
-}
-
-function describePayloadConditions(value: unknown): string {
- if (!Array.isArray(value)) {
- return ''
- }
- return value
- .map((entry) => {
- const condition = (entry ?? {}) as Record<string, unknown>
- const path = typeof condition.path === 'string' ? condition.path : ''
- const expected = stringList(condition.equals)
- return path && expected.length > 0 ? `${path} is ${expected.join(' or ')}` : ''
- })
- .filter(Boolean)
- .join(' and ')
-}
-
-function describeGithubTrigger(config: Record<string, unknown>): string {
- const repository = typeof config.repository === 'string' ? config.repository : 'a repo'
- const filters = (config.filters ?? {}) as Record<string, unknown>
- const actions = [...stringList(filters.actions), ...stringList(filters.action)]
- const events: string[] = []
- for (const raw of stringList(config.events)) {
- // the API also accepts `issues.opened` shorthand; render it as event + action
- const dot = raw.indexOf('.')
- const event = dot > 0 ? raw.slice(0, dot) : raw
- const action = dot > 0 ? raw.slice(dot + 1) : ''
- if (!events.includes(event)) {
- events.push(event)
- }
- if (action && !actions.includes(action)) {
- actions.push(action)
- }
- }
- if (events.length === 0) {
- return `GitHub (${repository})`
- }
- let summary = events.join(', ')
- if (actions.length > 0) {
- summary += ` ${actions.join('/')}`
- }
- const branches = [...stringList(filters.branches), ...stringList(filters.branch)]
- if (branches.length > 0) {
- summary += ` on ${branches.join(', ')}`
- }
- const labels = [...stringList(filters.labels), ...stringList(filters.label)]
- if (labels.length > 0) {
- summary += ` labeled ${labels.join(', ')}`
- }
- const conditions = describePayloadConditions(filters.payload)
- if (conditions) {
- summary += ` where ${conditions}`
- }
- return `GitHub (${repository}: ${summary})`
-}
-
-function describeTrigger(trigger: LoopReviewTrigger): string {
- if (trigger.type === 'schedule') {
- const config = trigger.config ?? {}
- if (typeof config.run_at === 'string') {
- return 'Once'
- }
- if (typeof config.cron_expression === 'string') {
- return `Schedule (${config.cron_expression})`
- }
- return 'Schedule'
- }
- if (trigger.type === 'github') {
- return describeGithubTrigger(trigger.config ?? {})
- }
- return 'API'
-}
-
-const OVERLAP_LABELS: Record<string, string> = {
- skip: 'skips overlapping runs',
- allow: 'allows overlapping runs',
- cancel_previous: 'cancels the previous run',
-}
-
-export function describeRunBehavior(data: Pick<LoopReviewData, 'triggers' | 'enabled' | 'overlap_policy'>): string {
- const parts: string[] = []
- if (!data.triggers || data.triggers.length === 0) {
- parts.push('Manual only')
- } else {
- parts.push(data.triggers.map(describeTrigger).join(', '))
- }
- if (data.enabled === false) {
- parts.push('paused')
- }
- // the server defaults overlap_policy to 'skip', so always show the effective policy
- const overlapPolicy = data.overlap_policy ?? 'skip'
- parts.push(OVERLAP_LABELS[overlapPolicy] ?? overlapPolicy)
- return parts.join(' · ')
-}
-
-export function describePosthogAccess(connectors: LoopReviewConnectors | undefined): string {
- return connectors?.posthog_mcp_scopes === 'full' ? 'Full (read-write)' : 'Read-only'
-}
-
-function describeConnectors(connectors: LoopReviewConnectors | undefined): string {
- const ids = connectors?.mcp_installation_ids ?? []
- return ids.length > 0 ? ids.join(', ') : 'None'
-}
-
-function describeRepository(repositories: LoopReviewRepository[] | undefined): string {
- if (!repositories || repositories.length === 0) {
- return 'None (report-only)'
- }
- return repositories.map((repository) => repository.full_name).join(', ')
-}
-
-function describeContext(target: LoopReviewContextTarget | null | undefined): string {
- if (!target?.name) {
- return 'Not attached'
- }
- const outputs = target.outputs ?? {}
- const enabled: string[] = []
- if (outputs.post_to_feed) {
- enabled.push('feed')
- }
- if (outputs.update_context) {
- enabled.push('context.md')
- }
- if (outputs.canvas_id) {
- enabled.push('canvas')
- }
- return enabled.length > 0 ? `#${target.name} (${enabled.join(', ')})` : `#${target.name}`
-}
-
-function describeNotifications(notifications: Record<string, LoopReviewNotificationChannel> | undefined): string {
- const enabled = Object.entries(notifications ?? {})
- .filter(([, channel]) => channel?.enabled)
- .map(([name]) => name)
- return enabled.length > 0 ? enabled.join(', ') : 'None'
-}
-
-function describeModel(data: LoopReviewData): string {
- const adapter = data.runtime_adapter ? (ADAPTER_LABELS[data.runtime_adapter] ?? data.runtime_adapter) : 'Default'
- const model = data.model?.trim() ? data.model : 'Default model'
- const reasoning = data.reasoning_effort ?? 'auto'
- return `${adapter} · ${model} · ${reasoning} reasoning`
-}
-
-export function describeFixReviewComments(behaviors: LoopReviewBehaviors | undefined): string {
- if (!behaviors?.fix_review_comments) {
- return 'No'
- }
- const cap = behaviors.max_fix_iterations
- return cap != null ? `Yes (up to ${cap} iterations)` : 'Yes'
-}
-
-export function LoopReviewView({ data, onCreate, state }: LoopReviewViewProps): ReactElement {
- const created = state?.createdName
-
- if (created) {
- return (
- <Card className="m-4">
- <CardContent className="flex flex-col items-center gap-3 p-8 text-center">
- <div className="flex size-12 items-center justify-center rounded-full bg-success">
- <Check className="size-7 text-success-foreground" strokeWidth={2.5} />
- </div>
- <div className="flex flex-col gap-1">
- <h2 className="text-lg font-semibold text-foreground">Loop created</h2>
- <p className="text-base font-medium text-foreground">{created}</p>
- </div>
- <p className="text-sm text-muted-foreground">
- You'll find it on the Loops page. Edit, pause, or run it anytime.
- </p>
- </CardContent>
- </Card>
- )
- }
-
- const items: { label: string; value: ReactNode }[] = [
- { label: 'Name', value: data.name?.trim() || 'Not set' },
- ...(data.description?.trim() ? [{ label: 'Description', value: data.description }] : []),
- {
- label: 'Visibility',
- value: data.visibility === 'team' ? 'Team' : 'Personal',
- },
- {
- label: 'What it does',
- value: <span className="whitespace-pre-wrap">{data.instructions?.trim() || 'No prompt'}</span>,
- },
- { label: 'Runs', value: describeRunBehavior(data) },
- { label: 'Context', value: describeContext(data.context_target) },
- { label: 'Repository', value: describeRepository(data.repositories) },
- { label: 'Model', value: describeModel(data) },
- {
- label: 'Opens PRs',
- value: data.behaviors?.create_prs ? 'Yes' : 'No',
- },
- { label: 'Watches CI', value: data.behaviors?.watch_ci ? 'Yes' : 'No' },
- {
- label: 'Fixes review comments',
- value: describeFixReviewComments(data.behaviors),
- },
- {
- label: 'PostHog access',
- value: describePosthogAccess(data.connectors),
- },
- { label: 'Connectors', value: describeConnectors(data.connectors) },
- { label: 'Sandbox', value: data.sandbox_environment || 'None' },
- {
- label: 'Notifications',
- value: describeNotifications(data.notifications),
- },
- ]
-
- const creating = state?.loading ?? false
- const createDisabled = creating || !onCreate
- const create = (): void => {
- void onCreate?.()
- }
-
- return (
- <Card className="m-4">
- <CardContent className="flex flex-col gap-4 p-4">
- <div className="flex items-center justify-between gap-4">
- <div className="flex flex-col gap-0.5">
- <h2 className="text-base font-semibold text-foreground">Review this loop</h2>
- <p className="text-sm text-muted-foreground">Check the details below, then create it.</p>
- </div>
- <Button
- className="shrink-0 bg-[#f9bd2b] font-semibold text-black hover:opacity-90"
- onClick={create}
- disabled={createDisabled}
- >
- {creating ? 'Creating...' : 'Create loop'}
- </Button>
- </div>
-
- {state?.error ? (
- <p className="rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-foreground">
- {state.error}
- </p>
- ) : null}
-
- <DescriptionList items={items} />
- </CardContent>
- </Card>
- )
-}
diff --git a/products/tasks/mcp/apps/index.ts b/products/tasks/mcp/apps/index.ts
deleted file mode 100644
index c5a2656a67e6..000000000000
--- a/products/tasks/mcp/apps/index.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-export {
- LoopReviewView,
- type LoopReviewBehaviors,
- type LoopReviewConnectors,
- type LoopReviewContextOutputs,
- type LoopReviewContextTarget,
- type LoopReviewData,
- type LoopReviewNotificationChannel,
- type LoopReviewRepository,
- type LoopReviewState,
- type LoopReviewTrigger,
- type LoopReviewViewProps,
-} from './LoopReviewView'
diff --git a/products/tasks/mcp/tools.yaml b/products/tasks/mcp/tools.yaml
index 7def5104e139..a2eb56dcc4ca 100644
--- a/products/tasks/mcp/tools.yaml
+++ b/products/tasks/mcp/tools.yaml
@@ -5,11 +5,7 @@
category: Tasks
feature: tasks
url_prefix: /tasks
-ui_apps:
- loops-review:
- type: custom
- app_name: PostHog Loop Review
- description: Review card for a loop before creation, with a Create loop action.
+ui_apps: {}
tools:
channel-create:
operation: task_channels_create
@@ -101,225 +97,6 @@ tools:
param_overrides:
id:
description: ID of the channel to read.
- loop-channel-instructions-retrieve:
- operation: task_channels_instructions_retrieve
- enabled: true
- scopes:
- - task:read
- - loop_context_internal:write
- annotations:
- readOnly: true
- destructive: false
- idempotent: true
- title: Read fallback loop context
- description: Read legacy channel context when an unattended loop cannot access an initialized context wiki.
- param_overrides:
- id:
- description: ID of the loop's context channel.
- loop-channel-instructions-update:
- operation: task_channels_instructions_update
- enabled: true
- scopes:
- - task:write
- - loop_context_internal:write
- annotations:
- readOnly: false
- destructive: true
- idempotent: false
- title: Update fallback loop context
- description: Update legacy channel context when an unattended loop cannot access an initialized context wiki.
- param_overrides:
- id:
- description: ID of the loop's context channel.
- base_version:
- input_schema: ChannelInstructionsBaseVersionSchema
- loops-create:
- operation: loops_create
- enabled: true
- scopes:
- - loop:write
- annotations:
- readOnly: false
- destructive: false
- idempotent: false
- title: Create loop
- description: >
- Create a new loop: a named, cloud-executed agent automation that runs on a schedule, a GitHub event, or an
- authenticated API call. Set `instructions` (the prompt delivered to the agent on every run),
- `runtime_adapter`/`model`/`reasoning_effort`, `repositories` (at most 1, may be empty for a connector-only
- loop), `visibility` (`personal` or `team`), `behaviors` (PR creation, CI watch, auto-fix) and `triggers`.
- feature_flag: loops
- hidden_when_flag_on: loops-hog-flows
- superseded_by:
- - workflows-create
- redirect_hint:
- 'Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with
- origin_product "loops".'
- confirmed_action:
- message: >
- About to create the loop '{name}', a persistent automation that will run unattended with your GitHub and
- connector access whenever its triggers fire. Reply 'confirm' to create it.
- action_label: create loop
- loops-destroy:
- operation: loops_destroy
- enabled: true
- scopes:
- - loop:write
- annotations:
- readOnly: false
- destructive: true
- idempotent: true
- title: Delete loop
- description: >
- Soft-delete a loop and pause every trigger's schedule so it stops firing. Only the loop owner or a project
- admin can delete a loop.
- feature_flag: loops
- hidden_when_flag_on: loops-hog-flows
- superseded_by:
- - workflows-archive
- redirect_hint:
- 'Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with
- origin_product "loops".'
- loops-list:
- operation: loops_list
- enabled: true
- scopes:
- - loop:read
- annotations:
- readOnly: true
- destructive: false
- idempotent: true
- list: true
- title: List loops
- description: >
- List loops visible to the current user in the project: personal loops the user owns plus every team-visible
- loop. Returns loop config, trigger summaries, and run bookkeeping (`last_run_at`, `last_run_status`,
- `consecutive_failures`).
- feature_flag: loops
- hidden_when_flag_on: loops-hog-flows
- superseded_by:
- - workflows-list
- redirect_hint:
- 'Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with
- origin_product "loops".'
- loops-partial-update:
- operation: loops_partial_update
- enabled: true
- scopes:
- - loop:write
- annotations:
- readOnly: false
- destructive: false
- idempotent: false
- title: Update loop
- description: >
- Update an existing loop's config. On a team loop, identity-bearing fields (`instructions`, `repositories`,
- `connectors`, `behaviors`, `triggers`) are editable only by the current owner: editing them as another
- member takes ownership and re-validates repositories and connectors against that member's own access.
- Editing a loop never affects its in-flight or queued runs; every run snapshots its config at fire time.
- feature_flag: loops
- hidden_when_flag_on: loops-hog-flows
- superseded_by:
- - workflows-patch-graph
- - workflows-update
- redirect_hint:
- 'Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with
- origin_product "loops".'
- loops-preview-create:
- operation: loops_preview_create
- enabled: true
- scopes:
- - loop:read
- annotations:
- readOnly: true
- destructive: false
- idempotent: true
- title: Preview a loop fire
- description: >
- Dry-run a loop: render the assembled instructions and trigger context for a sample payload (or a synthetic
- schedule fire when omitted) without creating a task, run, or any other side effect. Use it to check a loop's
- prompt before enabling it.
- feature_flag: loops
- hidden_when_flag_on: loops-hog-flows
- superseded_by:
- - workflows-test-run
- redirect_hint:
- 'Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with
- origin_product "loops".'
- loops-retrieve:
- operation: loops_retrieve
- enabled: true
- scopes:
- - loop:read
- annotations:
- readOnly: true
- destructive: false
- idempotent: true
- enrich_url: '{id}'
- title: Get loop
- description: >
- Get a specific loop by ID, including its full config (instructions, model, repositories, triggers,
- behaviors, connectors, notifications) and run bookkeeping.
- feature_flag: loops
- hidden_when_flag_on: loops-hog-flows
- superseded_by:
- - workflows-get
- redirect_hint:
- 'Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with
- origin_product "loops".'
- loops-run-create:
- operation: loops_run_create
- enabled: true
- scopes:
- - loop:write
- annotations:
- readOnly: false
- destructive: false
- idempotent: false
- title: Manually run a loop
- description: >
- Manually fire a loop right now, outside its configured triggers. Creates a fresh task run using the loop's
- current config snapshot and returns it. Subject to the same usage-gate, overlap policy and rate limits as
- trigger-fired runs.
- feature_flag: loops
- hidden_when_flag_on: loops-hog-flows
- superseded_by:
- - workflows-test-run
- redirect_hint:
- 'Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with
- origin_product "loops". A test run steps one node at a time and mocks outbound calls, so it checks the graph
- and creates no task run. To fire a loop for real, use Run now on an enabled schedule loop in PostHog
- Desktop, or wait for its trigger.'
- loops-runs-retrieve:
- operation: loops_runs_retrieve
- enabled: true
- scopes:
- - loop:read
- annotations:
- readOnly: true
- destructive: false
- idempotent: true
- enrich_url: '{id}/runs'
- list: true
- title: List loop runs
- description: >
- List a loop's run history, newest first, cursor-paginated. Each entry carries the run's status, branch,
- error message and output (including any PR URL), so an agent can check whether a loop's runs succeeded and
- what they produced. Set status=failed to find failure records without reading canvas state. Keep the status
- filter unchanged when following next_cursor. Use these records and the loop's last_run_status, last_error,
- and consecutive_failures for current health; an enabled schedule alone does not show successful work.
- feature_flag: loops
- hidden_when_flag_on: loops-hog-flows
- superseded_by:
- - tasks-list
- - tasks-runs-retrieve
- - workflows-list-invocations
- redirect_hint:
- 'Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with
- origin_product "loops". For run history, call tasks-list with the hog_flow_id of the loop and archived set
- to all: it lists the tasks the loop created, newest first, each with the status and error of its latest run.
- Then call tasks-runs-retrieve on a run for its branch and output, including any PR URL.
- workflows-list-invocations carries the engine outcome only, with no task output.'
tasks-config-agent-instructions-create:
operation: tasks_config_agent_instructions_create
enabled: true
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 7794f68b232b..d97b51c5021d 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -9077,241 +9077,6 @@
"readOnlyHint": true
}
},
- "loop-channel-instructions-retrieve": {
- "description": "Read legacy channel context when an unattended loop cannot access an initialized context wiki.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Read fallback loop context",
- "title": "Read fallback loop context",
- "required_scopes": ["task:read", "loop_context_internal:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- }
- },
- "loop-channel-instructions-update": {
- "description": "Update legacy channel context when an unattended loop cannot access an initialized context wiki.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Update fallback loop context",
- "title": "Update fallback loop context",
- "required_scopes": ["task:write", "loop_context_internal:write"],
- "annotations": {
- "destructiveHint": true,
- "idempotentHint": false,
- "openWorldHint": true,
- "readOnlyHint": false
- }
- },
- "loop-context-wiki-channel-resolve": {
- "description": "Resolve a channel id to its context wiki page path for an unattended loop run.",
- "category": "Context wiki",
- "feature": "context_layer",
- "summary": "Resolve a loop context wiki page",
- "title": "Resolve a loop context wiki page",
- "required_scopes": ["task:read", "loop_context_internal:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- },
- "feature_flag": "context-layer"
- },
- "loop-context-wiki-page-retrieve": {
- "description": "Read a bounded context wiki page chunk and its head_sha for an unattended loop run. Follow next_offset with the same head_sha and limit until complete is true. Join all content chunks before editing. On 409, discard the chunks and restart at offset zero.",
- "category": "Context wiki",
- "feature": "context_layer",
- "summary": "Read a loop context wiki page",
- "title": "Read a loop context wiki page",
- "required_scopes": ["task:read", "loop_context_internal:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- },
- "feature_flag": "context-layer"
- },
- "loop-context-wiki-page-update": {
- "description": "Replace a context wiki page using base_head concurrency for an unattended loop run.",
- "category": "Context wiki",
- "feature": "context_layer",
- "summary": "Update a loop context wiki page",
- "title": "Update a loop context wiki page",
- "required_scopes": ["task:write", "loop_context_internal:write"],
- "annotations": {
- "destructiveHint": true,
- "idempotentHint": false,
- "openWorldHint": true,
- "readOnlyHint": false
- },
- "feature_flag": "context-layer"
- },
- "loops-create-execute": {
- "description": "Step 2 of 2 for create loop. Verifies the confirmation_hash from -prepare and the literal \"confirm\" string typed by the user, then performs the action. ONLY call this after the user has explicitly typed \"confirm\" in chat. Original action: Create a new loop: a named, cloud-executed agent automation that runs on a schedule, a GitHub event, or an authenticated API call. Set `instructions` (the prompt delivered to the agent on every run), `runtime_adapter`/`model`/`reasoning_effort`, `repositories` (at most 1, may be empty for a connector-only loop), `visibility` (`personal` or `team`), `behaviors` (PR creation, CI watch, auto-fix) and `triggers`.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Create loop (execute)",
- "title": "Create loop (execute)",
- "required_scopes": ["loop:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": false,
- "openWorldHint": true,
- "readOnlyHint": false
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-create"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\"."
- },
- "loops-create-prepare": {
- "description": "Step 1 of 2 for create loop. Validates the arguments and returns a signed confirmation_hash plus a message to surface to the user. The user must reply with the literal word \"confirm\" before you call the matching -execute tool with the hash. Original action: Create a new loop: a named, cloud-executed agent automation that runs on a schedule, a GitHub event, or an authenticated API call. Set `instructions` (the prompt delivered to the agent on every run), `runtime_adapter`/`model`/`reasoning_effort`, `repositories` (at most 1, may be empty for a connector-only loop), `visibility` (`personal` or `team`), `behaviors` (PR creation, CI watch, auto-fix) and `triggers`.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Create loop (prepare)",
- "title": "Create loop (prepare)",
- "required_scopes": ["loop:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-create"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\"."
- },
- "loops-destroy": {
- "description": "Soft-delete a loop and pause every trigger's schedule so it stops firing. Only the loop owner or a project admin can delete a loop.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Delete loop",
- "title": "Delete loop",
- "required_scopes": ["loop:write"],
- "annotations": {
- "destructiveHint": true,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": false
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-archive"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\"."
- },
- "loops-list": {
- "description": "List loops visible to the current user in the project: personal loops the user owns plus every team-visible loop. Returns loop config, trigger summaries, and run bookkeeping (`last_run_at`, `last_run_status`, `consecutive_failures`).",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "List loops",
- "title": "List loops",
- "required_scopes": ["loop:read"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-list"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\"."
- },
- "loops-partial-update": {
- "description": "Update an existing loop's config. On a team loop, identity-bearing fields (`instructions`, `repositories`, `connectors`, `behaviors`, `triggers`) are editable only by the current owner: editing them as another member takes ownership and re-validates repositories and connectors against that member's own access. Editing a loop never affects its in-flight or queued runs; every run snapshots its config at fire time.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Update loop",
- "title": "Update loop",
- "required_scopes": ["loop:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": false,
- "openWorldHint": true,
- "readOnlyHint": false
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-patch-graph", "workflows-update"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\"."
- },
- "loops-preview-create": {
- "description": "Dry-run a loop: render the assembled instructions and trigger context for a sample payload (or a synthetic schedule fire when omitted) without creating a task, run, or any other side effect. Use it to check a loop's prompt before enabling it.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Preview a loop fire",
- "title": "Preview a loop fire",
- "required_scopes": ["loop:read"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-test-run"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\"."
- },
- "loops-retrieve": {
- "description": "Get a specific loop by ID, including its full config (instructions, model, repositories, triggers, behaviors, connectors, notifications) and run bookkeeping.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Get loop",
- "title": "Get loop",
- "required_scopes": ["loop:read"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-get"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\"."
- },
- "loops-run-create": {
- "description": "Manually fire a loop right now, outside its configured triggers. Creates a fresh task run using the loop's current config snapshot and returns it. Subject to the same usage-gate, overlap policy and rate limits as trigger-fired runs.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Manually run a loop",
- "title": "Manually run a loop",
- "required_scopes": ["loop:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": false,
- "openWorldHint": true,
- "readOnlyHint": false
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-test-run"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\". A test run steps one node at a time and mocks outbound calls, so it checks the graph and creates no task run. To fire a loop for real, use Run now on an enabled schedule loop in PostHog Desktop, or wait for its trigger."
- },
- "loops-runs-retrieve": {
- "description": "List a loop's run history, newest first, cursor-paginated. Each entry carries the run's status, branch, error message and output (including any PR URL), so an agent can check whether a loop's runs succeeded and what they produced. Set status=failed to find failure records without reading canvas state. Keep the status filter unchanged when following next_cursor. Use these records and the loop's last_run_status, last_error, and consecutive_failures for current health; an enabled schedule alone does not show successful work.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "List loop runs",
- "title": "List loop runs",
- "required_scopes": ["loop:read"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["tasks-list", "tasks-runs-retrieve", "workflows-list-invocations"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\". For run history, call tasks-list with the hog_flow_id of the loop and archived set to all: it lists the tasks the loop created, newest first, each with the status and error of its latest run. Then call tasks-runs-retrieve on a run for its branch and output, including any PR URL. workflows-list-invocations carries the engine outcome only, with no task output."
- },
"managed-migrations-support-get": {
"description": "Get one batch import (managed migration) job by id, from any PostHog team, including the raw worker `state` and `import_config` blobs. PostHog staff only: the backend requires a staff user AND a personal API key explicitly carrying the `batch_import_support:read` scope (a full-access `*` key is rejected; OAuth sign-in can never grant it).\n\nAdds to the list fields:\n\n- `state`: the worker-owned progress blob, `{\"parts\": [{\"key\", \"current_offset\", \"total_size\"}]}`. A part is done when `current_offset >= total_size`; parts are processed in order, so the first unfinished part is the one in flight. `current_offset` is a byte offset into the DECOMPRESSED part - only meaningful against the exact byte stream it was measured on.\n- `import_config`: the job's source / data format / sink configuration. It references credentials by secret key NAME only; secret values live in an encrypted column that is never returned by any API.\n- `created_by_email`: who started the migration, when known.\n\nTroubleshooting reminders (same semantics as the list tool): `waiting_to_start` = running with no worker lease yet; `lease_expired: true` on a running job = the worker died or the job is about to be re-claimed; a `paused` job keeps its lease and resuming (a Django admin action - this API is read-only) must clear it; `paused` with an invalid-JSON parse error at the resume point usually means the source bytes changed under the committed offset and the in-flight part needs a reset to offset 0 via Django admin's \"Resume + re-import in-flight part\".",
"category": "Managed migrations",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 14ebf29f024e..0bfbb40ae2fc 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -9456,259 +9456,6 @@
"readOnlyHint": true
}
},
- "loop-channel-instructions-retrieve": {
- "description": "Read legacy channel context when an unattended loop cannot access an initialized context wiki.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Read fallback loop context",
- "title": "Read fallback loop context",
- "required_scopes": ["task:read", "loop_context_internal:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- }
- },
- "loop-channel-instructions-update": {
- "description": "Update legacy channel context when an unattended loop cannot access an initialized context wiki.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Update fallback loop context",
- "title": "Update fallback loop context",
- "required_scopes": ["task:write", "loop_context_internal:write"],
- "annotations": {
- "destructiveHint": true,
- "idempotentHint": false,
- "openWorldHint": true,
- "readOnlyHint": false
- }
- },
- "loop-context-wiki-channel-resolve": {
- "description": "Resolve a channel id to its context wiki page path for an unattended loop run.",
- "category": "Context wiki",
- "feature": "context_layer",
- "summary": "Resolve a loop context wiki page",
- "title": "Resolve a loop context wiki page",
- "required_scopes": ["task:read", "loop_context_internal:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- },
- "feature_flag": "context-layer"
- },
- "loop-context-wiki-page-retrieve": {
- "description": "Read a bounded context wiki page chunk and its head_sha for an unattended loop run. Follow next_offset with the same head_sha and limit until complete is true. Join all content chunks before editing. On 409, discard the chunks and restart at offset zero.",
- "category": "Context wiki",
- "feature": "context_layer",
- "summary": "Read a loop context wiki page",
- "title": "Read a loop context wiki page",
- "required_scopes": ["task:read", "loop_context_internal:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- },
- "feature_flag": "context-layer"
- },
- "loop-context-wiki-page-update": {
- "description": "Replace a context wiki page using base_head concurrency for an unattended loop run.",
- "category": "Context wiki",
- "feature": "context_layer",
- "summary": "Update a loop context wiki page",
- "title": "Update a loop context wiki page",
- "required_scopes": ["task:write", "loop_context_internal:write"],
- "annotations": {
- "destructiveHint": true,
- "idempotentHint": false,
- "openWorldHint": true,
- "readOnlyHint": false
- },
- "feature_flag": "context-layer"
- },
- "loops-create-execute": {
- "description": "Step 2 of 2 for create loop. Verifies the confirmation_hash from -prepare and the literal \"confirm\" string typed by the user, then performs the action. ONLY call this after the user has explicitly typed \"confirm\" in chat. Original action: Create a new loop: a named, cloud-executed agent automation that runs on a schedule, a GitHub event, or an authenticated API call. Set `instructions` (the prompt delivered to the agent on every run), `runtime_adapter`/`model`/`reasoning_effort`, `repositories` (at most 1, may be empty for a connector-only loop), `visibility` (`personal` or `team`), `behaviors` (PR creation, CI watch, auto-fix) and `triggers`.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Create loop (execute)",
- "title": "Create loop (execute)",
- "required_scopes": ["loop:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": false,
- "openWorldHint": true,
- "readOnlyHint": false
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-create"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\"."
- },
- "loops-create-prepare": {
- "description": "Step 1 of 2 for create loop. Validates the arguments and returns a signed confirmation_hash plus a message to surface to the user. The user must reply with the literal word \"confirm\" before you call the matching -execute tool with the hash. Original action: Create a new loop: a named, cloud-executed agent automation that runs on a schedule, a GitHub event, or an authenticated API call. Set `instructions` (the prompt delivered to the agent on every run), `runtime_adapter`/`model`/`reasoning_effort`, `repositories` (at most 1, may be empty for a connector-only loop), `visibility` (`personal` or `team`), `behaviors` (PR creation, CI watch, auto-fix) and `triggers`.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Create loop (prepare)",
- "title": "Create loop (prepare)",
- "required_scopes": ["loop:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-create"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\"."
- },
- "loops-destroy": {
- "description": "Soft-delete a loop and pause every trigger's schedule so it stops firing. Only the loop owner or a project admin can delete a loop.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Delete loop",
- "title": "Delete loop",
- "required_scopes": ["loop:write"],
- "annotations": {
- "destructiveHint": true,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": false
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-archive"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\"."
- },
- "loops-list": {
- "description": "List loops visible to the current user in the project: personal loops the user owns plus every team-visible loop. Returns loop config, trigger summaries, and run bookkeeping (`last_run_at`, `last_run_status`, `consecutive_failures`).",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "List loops",
- "title": "List loops",
- "required_scopes": ["loop:read"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-list"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\"."
- },
- "loops-partial-update": {
- "description": "Update an existing loop's config. On a team loop, identity-bearing fields (`instructions`, `repositories`, `connectors`, `behaviors`, `triggers`) are editable only by the current owner: editing them as another member takes ownership and re-validates repositories and connectors against that member's own access. Editing a loop never affects its in-flight or queued runs; every run snapshots its config at fire time.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Update loop",
- "title": "Update loop",
- "required_scopes": ["loop:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": false,
- "openWorldHint": true,
- "readOnlyHint": false
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-patch-graph", "workflows-update"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\"."
- },
- "loops-preview-create": {
- "description": "Dry-run a loop: render the assembled instructions and trigger context for a sample payload (or a synthetic schedule fire when omitted) without creating a task, run, or any other side effect. Use it to check a loop's prompt before enabling it.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Preview a loop fire",
- "title": "Preview a loop fire",
- "required_scopes": ["loop:read"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-test-run"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\"."
- },
- "loops-retrieve": {
- "description": "Get a specific loop by ID, including its full config (instructions, model, repositories, triggers, behaviors, connectors, notifications) and run bookkeeping.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Get loop",
- "title": "Get loop",
- "required_scopes": ["loop:read"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-get"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\"."
- },
- "loops-review": {
- "description": "Show the user an interactive review card for a loop that is about to be created, then let them create it. Call this once you have gathered the loop's details, passing the SAME arguments you would pass to loops-create (name, instructions, runtime_adapter, triggers, behaviors, notifications, context_target, etc.). This renders a card summarizing the loop with a 'Create loop' button. Do NOT call loops-create yourself — the card's button creates the loop after the user confirms.",
- "category": "Tasks",
- "feature": "tasks",
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-create"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\".",
- "summary": "Review a loop with the user before creating it.",
- "title": "Review loop before creating",
- "required_scopes": ["loop:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": false,
- "readOnlyHint": true
- }
- },
- "loops-run-create": {
- "description": "Manually fire a loop right now, outside its configured triggers. Creates a fresh task run using the loop's current config snapshot and returns it. Subject to the same usage-gate, overlap policy and rate limits as trigger-fired runs.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "Manually run a loop",
- "title": "Manually run a loop",
- "required_scopes": ["loop:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": false,
- "openWorldHint": true,
- "readOnlyHint": false
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-test-run"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\". A test run steps one node at a time and mocks outbound calls, so it checks the graph and creates no task run. To fire a loop for real, use Run now on an enabled schedule loop in PostHog Desktop, or wait for its trigger."
- },
- "loops-runs-retrieve": {
- "description": "List a loop's run history, newest first, cursor-paginated. Each entry carries the run's status, branch, error message and output (including any PR URL), so an agent can check whether a loop's runs succeeded and what they produced. Set status=failed to find failure records without reading canvas state. Keep the status filter unchanged when following next_cursor. Use these records and the loop's last_run_status, last_error, and consecutive_failures for current health; an enabled schedule alone does not show successful work.",
- "category": "Tasks",
- "feature": "tasks",
- "summary": "List loop runs",
- "title": "List loop runs",
- "required_scopes": ["loop:read"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": true,
- "readOnlyHint": true
- },
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["tasks-list", "tasks-runs-retrieve", "workflows-list-invocations"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\". For run history, call tasks-list with the hog_flow_id of the loop and archived set to all: it lists the tasks the loop created, newest first, each with the status and error of its latest run. Then call tasks-runs-retrieve on a run for its branch and output, including any PR URL. workflows-list-invocations carries the engine outcome only, with no task output."
- },
"managed-migrations-support-get": {
"description": "Get one batch import (managed migration) job by id, from any PostHog team, including the raw worker `state` and `import_config` blobs. PostHog staff only: the backend requires a staff user AND a personal API key explicitly carrying the `batch_import_support:read` scope (a full-access `*` key is rejected; OAuth sign-in can never grant it).\n\nAdds to the list fields:\n\n- `state`: the worker-owned progress blob, `{\"parts\": [{\"key\", \"current_offset\", \"total_size\"}]}`. A part is done when `current_offset >= total_size`; parts are processed in order, so the first unfinished part is the one in flight. `current_offset` is a byte offset into the DECOMPRESSED part - only meaningful against the exact byte stream it was measured on.\n- `import_config`: the job's source / data format / sink configuration. It references credentials by secret key NAME only; secret values live in an encrypted column that is never returned by any API.\n- `created_by_email`: who started the migration, when known.\n\nTroubleshooting reminders (same semantics as the list tool): `waiting_to_start` = running with no worker lease yet; `lease_expired: true` on a running job = the worker died or the job is about to be re-claimed; a `paused` job keeps its lease and resuming (a Django admin action - this API is read-only) must clear it; `paused` with an invalid-JSON parse error at the resume point usually means the source bytes changed under the committed offset and the in-flight part needs a reset to offset 0 via Django admin's \"Resume + re-import in-flight part\".",
"category": "Managed migrations",
diff --git a/services/mcp/schema/tool-definitions.json b/services/mcp/schema/tool-definitions.json
index fd58622b9430..4957edc1b91d 100644
--- a/services/mcp/schema/tool-definitions.json
+++ b/services/mcp/schema/tool-definitions.json
@@ -575,24 +575,6 @@
"readOnlyHint": true
}
},
- "loops-review": {
- "description": "Show the user an interactive review card for a loop that is about to be created, then let them create it. Call this once you have gathered the loop's details, passing the SAME arguments you would pass to loops-create (name, instructions, runtime_adapter, triggers, behaviors, notifications, context_target, etc.). This renders a card summarizing the loop with a 'Create loop' button. Do NOT call loops-create yourself — the card's button creates the loop after the user confirms.",
- "category": "Tasks",
- "feature": "tasks",
- "feature_flag": "loops",
- "hidden_when_flag_on": "loops-hog-flows",
- "superseded_by": ["workflows-create"],
- "redirect_hint": "Loops in this project run on workflows: read the building-loops skill, then use the workflows tools with origin_product \"loops\".",
- "summary": "Review a loop with the user before creating it.",
- "title": "Review loop before creating",
- "required_scopes": ["loop:write"],
- "annotations": {
- "destructiveHint": false,
- "idempotentHint": true,
- "openWorldHint": false,
- "readOnlyHint": true
- }
- },
"external-data-sources-db-schema": {
"description": "Validate credentials against a remote source and return the list of tables available to sync (works for database sources like Postgres/MySQL and SaaS sources like Stripe/Hubspot alike). Pass source_type and credential fields in the payload object. Each table entry includes: table name, incremental_available, append_available, cdc_available, supports_webhooks, detected_primary_keys, available_columns (name/type/nullable), rows estimate, and incremental_fields (candidate timestamp/integer columns for incremental sync). Use this BEFORE external-data-sources-create so the user can pick a sync_type per table. Returns 400 with a message if credentials are invalid.",
"category": "Data warehouse",
diff --git a/services/mcp/src/generated/tasks/api.ts b/services/mcp/src/generated/tasks/api.ts
index cdc4d32efea8..1ae7c0ec04ad 100644
--- a/services/mcp/src/generated/tasks/api.ts
+++ b/services/mcp/src/generated/tasks/api.ts
@@ -3,785 +3,11 @@
* MCP service uses these Zod schemas for generated tool handlers.
* To regenerate: hogli build:openapi
*
- * PostHog API - MCP 27 enabled ops
+ * PostHog API - MCP 19 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
-/**
- * List loops visible to the caller: personal loops they own, plus every team loop. The response also carries `max_loops_per_team` and `total_loop_count` so a client can show remaining capacity and disable creation at the cap without hardcoding the limit.
- * @summary List loops
- */
-export const LoopsListParams = () => zod.object({
- project_id: zod
- .string()
- .describe(
- "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
- ),
-})
-
-export const LoopsListQueryParams = () => zod.object({
- limit: zod.number().optional().describe('Number of results to return per page.'),
- offset: zod.number().optional().describe('The initial index from which to return the results.'),
-})
-
-/**
- * API for managing loops — named, cloud-executed agent automations triggered by
- * schedule, GitHub events or authenticated API calls.
- * @summary Create a loop
- */
-export const LoopsCreateParams = () => zod.object({
- project_id: zod
- .string()
- .describe(
- "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
- ),
-})
-
-export const loopsCreateBodyNameMax = 400
-
-export const loopsCreateBodyDescriptionDefault = ``
-export const loopsCreateBodyTakeOwnershipDefault = false
-export const loopsCreateBodyVisibilityDefault = `personal`
-export const loopsCreateBodyModelDefault = ``
-export const loopsCreateBodyRepositoriesItemFullNameMax = 255
-
-export const loopsCreateBodyRepositoriesMax = 1
-
-export const loopsCreateBodyEnabledDefault = true
-export const loopsCreateBodyOverlapPolicyDefault = `skip`
-export const loopsCreateBodyBehaviorsOneCreatePrsDefault = false
-export const loopsCreateBodyBehaviorsOneWatchCiDefault = false
-export const loopsCreateBodyBehaviorsOneFixReviewCommentsDefault = false
-export const loopsCreateBodyBehaviorsOneMaxFixIterationsDefault = 3
-export const loopsCreateBodyBehaviorsOneMaxFixIterationsMin = 0
-export const loopsCreateBodyBehaviorsOneMaxFixIterationsMax = 10
-
-export const loopsCreateBodyConnectorsOnePosthogMcpScopesDefault = `read_only`
-export const loopsCreateBodyNotificationsOnePushOneEnabledDefault = false
-export const loopsCreateBodyNotificationsOneEmailOneEnabledDefault = false
-export const loopsCreateBodyNotificationsOneSlackOneEnabledDefault = false
-export const loopsCreateBodyContextTargetOneNameMax = 128
-
-export const loopsCreateBodyContextTargetOneOutputsOnePostToFeedDefault = false
-export const loopsCreateBodyContextTargetOneOutputsOneUpdateContextDefault = false
-export const loopsCreateBodyTriggersItemEnabledDefault = true
-
-export const LoopsCreateBody = () => zod
- .object({
- name: zod.string().max(loopsCreateBodyNameMax).describe('Display name for the loop.'),
- description: zod
- .string()
- .default(loopsCreateBodyDescriptionDefault)
- .describe('Free-form description of what this loop does.'),
- take_ownership: zod
- .boolean()
- .default(loopsCreateBodyTakeOwnershipDefault)
- .describe(
- 'On a team loop, claim ownership as part of this update so you can edit identity-bearing config (instructions, model, triggers, ...) that only the owner may change. Ignored on personal loops and on create.'
- ),
- visibility: zod
- .enum(['personal', 'team'])
- .describe('\* `personal` - personal\n\* `team` - team')
- .default(loopsCreateBodyVisibilityDefault)
- .describe(
- '`personal` (owner-only) or `team` (visible and fireable by any team member).\n\n\* `personal` - personal\n\* `team` - team'
- ),
- instructions: zod.string().describe('The prompt delivered to the agent on every run.'),
- runtime_adapter: zod
- .enum(['claude', 'codex'])
- .describe('\* `claude` - claude\n\* `codex` - codex')
- .describe("Runtime adapter: 'claude' or 'codex'.\n\n\* `claude` - claude\n\* `codex` - codex"),
- model: zod
- .string()
- .default(loopsCreateBodyModelDefault)
- .describe(
- "LLM model identifier, validated against `runtime_adapter`'s catalog. Leave blank to let PostHog pick a sensible default at run time."
- ),
- reasoning_effort: zod
- .union([
- zod
- .enum(['low', 'medium', 'high', 'xhigh', 'max', 'ultracode'])
- .describe(
- '\* `low` - low\n\* `medium` - medium\n\* `high` - high\n\* `xhigh` - xhigh\n\* `max` - max\n\* `ultracode` - ultracode'
- ),
- zod.null(),
- ])
- .optional()
- .describe(
- "Reasoning effort, validated against `runtime_adapter`\/`model`'s supported set.\n\n\* `low` - low\n\* `medium` - medium\n\* `high` - high\n\* `xhigh` - xhigh\n\* `max` - max\n\* `ultracode` - ultracode"
- ),
- repositories: zod
- .array(
- zod.object({
- github_integration_id: zod
- .number()
- .describe('GitHub integration id this repository is accessed through.'),
- full_name: zod
- .string()
- .max(loopsCreateBodyRepositoriesItemFullNameMax)
- .describe('Repository in `organization\/repo` format, e.g. `posthog\/posthog`.'),
- })
- )
- .max(loopsCreateBodyRepositoriesMax)
- .optional()
- .describe(
- 'Repositories this loop operates on, ordered. Capped at 1 until multi-repo execution ships. May be empty for report-only loops.'
- ),
- sandbox_environment: zod
- .string()
- .nullish()
- .describe('Sandbox environment carrying encrypted env vars and the network allowlist into every run.'),
- enabled: zod
- .boolean()
- .default(loopsCreateBodyEnabledDefault)
- .describe("Whether the loop's triggers are active. Pausing disables all triggers."),
- overlap_policy: zod
- .enum(['skip', 'allow', 'cancel_previous'])
- .describe('\* `skip` - skip\n\* `allow` - allow\n\* `cancel_previous` - cancel_previous')
- .default(loopsCreateBodyOverlapPolicyDefault)
- .describe(
- "What happens when a trigger fires while a run is already active: 'skip', 'allow', or 'cancel_previous'.\n\n\* `skip` - skip\n\* `allow` - allow\n\* `cancel_previous` - cancel_previous"
- ),
- behaviors: zod
- .object({
- create_prs: zod
- .boolean()
- .default(loopsCreateBodyBehaviorsOneCreatePrsDefault)
- .describe('Whether the agent may push branches and open PRs. False makes this a report-only loop.'),
- watch_ci: zod
- .boolean()
- .default(loopsCreateBodyBehaviorsOneWatchCiDefault)
- .describe('Whether to watch CI on loop-created PRs and report status.'),
- fix_review_comments: zod
- .boolean()
- .default(loopsCreateBodyBehaviorsOneFixReviewCommentsDefault)
- .describe('Whether to automatically address review comments on loop-created PRs.'),
- max_fix_iterations: zod
- .number()
- .min(loopsCreateBodyBehaviorsOneMaxFixIterationsMin)
- .max(loopsCreateBodyBehaviorsOneMaxFixIterationsMax)
- .default(loopsCreateBodyBehaviorsOneMaxFixIterationsDefault)
- .describe('Ceiling on automatic CI\/review-comment fix iterations, capped at 10.'),
- })
- .optional()
- .describe('PR \/ CI-follow-up behavior configuration.'),
- connectors: zod
- .object({
- mcp_installation_ids: zod
- .array(zod.string())
- .optional()
- .describe("MCP Store installation ids (Slack, Linear, etc.) available to this loop's runs."),
- posthog_mcp_scopes: zod
- .enum(['read_only', 'full'])
- .describe('\* `read_only` - read_only\n\* `full` - full')
- .default(loopsCreateBodyConnectorsOnePosthogMcpScopesDefault)
- .describe(
- "Scope of the PostHog MCP access injected into this loop's runs.\n\n\* `read_only` - read_only\n\* `full` - full"
- ),
- })
- .optional()
- .describe("MCP connector configuration for this loop's runs."),
- notifications: zod
- .object({
- push: zod
- .object({
- enabled: zod
- .boolean()
- .default(loopsCreateBodyNotificationsOnePushOneEnabledDefault)
- .describe('Whether this channel is active.'),
- events: zod
- .array(
- zod
- .enum([
- 'run_completed',
- 'run_failed',
- 'pr_created',
- 'pr_merged',
- 'pr_closed',
- 'needs_attention',
- ])
- .describe(
- '\* `run_completed` - run_completed\n\* `run_failed` - run_failed\n\* `pr_created` - pr_created\n\* `pr_merged` - pr_merged\n\* `pr_closed` - pr_closed\n\* `needs_attention` - needs_attention'
- )
- )
- .optional()
- .describe(
- 'Event kinds this channel notifies on. One or more of: run_completed, run_failed, pr_created, pr_merged, pr_closed, needs_attention.'
- ),
- params: zod
- .record(zod.string(), zod.unknown())
- .optional()
- .describe("Channel-specific parameters, e.g. Slack's `integration_id` and `channel`."),
- })
- .optional()
- .describe('Push notification settings.'),
- email: zod
- .object({
- enabled: zod
- .boolean()
- .default(loopsCreateBodyNotificationsOneEmailOneEnabledDefault)
- .describe('Whether this channel is active.'),
- events: zod
- .array(
- zod
- .enum([
- 'run_completed',
- 'run_failed',
- 'pr_created',
- 'pr_merged',
- 'pr_closed',
- 'needs_attention',
- ])
- .describe(
- '\* `run_completed` - run_completed\n\* `run_failed` - run_failed\n\* `pr_created` - pr_created\n\* `pr_merged` - pr_merged\n\* `pr_closed` - pr_closed\n\* `needs_attention` - needs_attention'
- )
- )
- .optional()
- .describe(
- 'Event kinds this channel notifies on. One or more of: run_completed, run_failed, pr_created, pr_merged, pr_closed, needs_attention.'
- ),
- params: zod
- .record(zod.string(), zod.unknown())
- .optional()
- .describe("Channel-specific parameters, e.g. Slack's `integration_id` and `channel`."),
- })
- .optional()
- .describe('Email notification settings.'),
- slack: zod
- .object({
- enabled: zod
- .boolean()
- .default(loopsCreateBodyNotificationsOneSlackOneEnabledDefault)
- .describe('Whether this channel is active.'),
- events: zod
- .array(
- zod
- .enum([
- 'run_completed',
- 'run_failed',
- 'pr_created',
- 'pr_merged',
- 'pr_closed',
- 'needs_attention',
- ])
- .describe(
- '\* `run_completed` - run_completed\n\* `run_failed` - run_failed\n\* `pr_created` - pr_created\n\* `pr_merged` - pr_merged\n\* `pr_closed` - pr_closed\n\* `needs_attention` - needs_attention'
- )
- )
- .optional()
- .describe(
- 'Event kinds this channel notifies on. One or more of: run_completed, run_failed, pr_created, pr_merged, pr_closed, needs_attention.'
- ),
- params: zod
- .record(zod.string(), zod.unknown())
- .optional()
- .describe("Channel-specific parameters, e.g. Slack's `integration_id` and `channel`."),
- })
- .optional()
- .describe('Slack notification settings.'),
- })
- .optional()
- .describe('Per-channel notification configuration.'),
- context_target: zod
- .union([
- zod.object({
- channel_id: zod.string().describe('Id of the channel (context) this loop is attached to.'),
- name: zod
- .string()
- .max(loopsCreateBodyContextTargetOneNameMax)
- .describe("Display name of the context, shown in the loop's publish prompt."),
- outputs: zod
- .object({
- post_to_feed: zod
- .boolean()
- .default(loopsCreateBodyContextTargetOneOutputsOnePostToFeedDefault)
- .describe(
- "Whether each run is filed into the context's feed as a card (sets the run's channel)."
- ),
- update_context: zod
- .boolean()
- .default(loopsCreateBodyContextTargetOneOutputsOneUpdateContextDefault)
- .describe(
- "Whether each run reads and republishes the context's context.md to reflect the latest state."
- ),
- canvas_id: zod
- .string()
- .nullish()
- .describe(
- 'Id of a canvas in this context the loop keeps up to date each run, or null to maintain none.'
- ),
- })
- .optional()
- .describe('What the loop maintains in this context each run.'),
- }),
- zod.null(),
- ])
- .optional()
- .describe(
- 'Context (channel) this loop is attached to, or null to detach. Drives feed placement and the context.md \/ canvas it keeps up to date.'
- ),
- triggers: zod
- .array(
- zod.object({
- id: zod
- .string()
- .optional()
- .describe('Existing trigger id to update in place. Omit to create a new trigger.'),
- type: zod
- .enum(['schedule', 'github', 'api'])
- .describe('\* `schedule` - schedule\n\* `github` - github\n\* `api` - api')
- .describe(
- 'Trigger type: `schedule` (cron or one-time), `github` (repo webhook events), or `api` (POST to `trigger\/`).\n\n\* `schedule` - schedule\n\* `github` - github\n\* `api` - api'
- ),
- enabled: zod
- .boolean()
- .default(loopsCreateBodyTriggersItemEnabledDefault)
- .describe('Whether this trigger is active. Disabling pauses only this trigger.'),
- config: zod
- .unknown()
- .optional()
- .describe(
- 'Trigger configuration, shape validated per `type`: schedule takes `{cron_expression, timezone}` or `{run_at}` for a one-time run; github takes `{github_integration_id, repository, events, filters}` where `events` is one or more of `issues`, `issue_comment`, `pull_request`, `push` (`event.action` shorthand like `issues.opened` is folded into an `actions` filter, one event per trigger) and `filters` takes `{actions, branches, labels, payload}`. Use `actions` for the event action; `payload` is for anything else in the webhook body, as a list of `{path, equals}` conditions where `path` is a dot-path of object keys and `equals` is a string or list of strings, e.g. `[{\"path\": \"requested_team.slug\", \"equals\": \"team-security\"}]` to run only when that team is asked to review. All filters must match. API triggers take no config.'
- ),
- })
- )
- .optional()
- .describe(
- 'Full desired trigger list, id-stable: entries with a matching `id` are updated in place, entries without one are created, and existing triggers absent from this list are deleted. Omit the field entirely to leave triggers untouched. At most 25 triggers per loop.'
- ),
- })
- .describe(
- 'Request body for creating or updating a loop. Field required\/default semantics match\nthe `Loop` model; partial updates only touch keys present in the payload.'
- )
-
-/**
- * API for managing loops — named, cloud-executed agent automations triggered by
- * schedule, GitHub events or authenticated API calls.
- * @summary Get a loop
- */
-export const LoopsRetrieveParams = () => zod.object({
- id: zod.string(),
- project_id: zod
- .string()
- .describe(
- "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
- ),
-})
-
-/**
- * Partial update. Identity-bearing fields (instructions, repositories, connectors, behaviors, model config, triggers) are owner-only on team loops; name, description, notifications and enable/pause are editable by any team member.
- * @summary Update a loop
- */
-export const LoopsPartialUpdateParams = () => zod.object({
- id: zod.string(),
- project_id: zod
- .string()
- .describe(
- "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
- ),
-})
-
-export const loopsPartialUpdateBodyNameMax = 400
-
-export const loopsPartialUpdateBodyRepositoriesItemFullNameMax = 255
-
-export const loopsPartialUpdateBodyRepositoriesMax = 1
-
-export const loopsPartialUpdateBodyBehaviorsOneCreatePrsDefault = false
-export const loopsPartialUpdateBodyBehaviorsOneWatchCiDefault = false
-export const loopsPartialUpdateBodyBehaviorsOneFixReviewCommentsDefault = false
-export const loopsPartialUpdateBodyBehaviorsOneMaxFixIterationsDefault = 3
-export const loopsPartialUpdateBodyBehaviorsOneMaxFixIterationsMin = 0
-export const loopsPartialUpdateBodyBehaviorsOneMaxFixIterationsMax = 10
-
-export const loopsPartialUpdateBodyConnectorsOnePosthogMcpScopesDefault = `read_only`
-export const loopsPartialUpdateBodyNotificationsOnePushOneEnabledDefault = false
-export const loopsPartialUpdateBodyNotificationsOneEmailOneEnabledDefault = false
-export const loopsPartialUpdateBodyNotificationsOneSlackOneEnabledDefault = false
-export const loopsPartialUpdateBodyContextTargetOneNameMax = 128
-
-export const loopsPartialUpdateBodyContextTargetOneOutputsOnePostToFeedDefault = false
-export const loopsPartialUpdateBodyContextTargetOneOutputsOneUpdateContextDefault = false
-export const loopsPartialUpdateBodyTriggersItemEnabledDefault = true
-
-export const LoopsPartialUpdateBody = () => zod
- .object({
- name: zod.string().max(loopsPartialUpdateBodyNameMax).optional().describe('Display name for the loop.'),
- description: zod.string().optional().describe('Free-form description of what this loop does.'),
- take_ownership: zod
- .boolean()
- .optional()
- .describe(
- 'On a team loop, claim ownership as part of this update so you can edit identity-bearing config (instructions, model, triggers, ...) that only the owner may change. Ignored on personal loops and on create.'
- ),
- visibility: zod
- .enum(['personal', 'team'])
- .describe('\* `personal` - personal\n\* `team` - team')
- .optional()
- .describe(
- '`personal` (owner-only) or `team` (visible and fireable by any team member).\n\n\* `personal` - personal\n\* `team` - team'
- ),
- instructions: zod.string().optional().describe('The prompt delivered to the agent on every run.'),
- runtime_adapter: zod
- .enum(['claude', 'codex'])
- .describe('\* `claude` - claude\n\* `codex` - codex')
- .optional()
- .describe("Runtime adapter: 'claude' or 'codex'.\n\n\* `claude` - claude\n\* `codex` - codex"),
- model: zod
- .string()
- .optional()
- .describe(
- "LLM model identifier, validated against `runtime_adapter`'s catalog. Leave blank to let PostHog pick a sensible default at run time."
- ),
- reasoning_effort: zod
- .union([
- zod
- .enum(['low', 'medium', 'high', 'xhigh', 'max', 'ultracode'])
- .describe(
- '\* `low` - low\n\* `medium` - medium\n\* `high` - high\n\* `xhigh` - xhigh\n\* `max` - max\n\* `ultracode` - ultracode'
- ),
- zod.null(),
- ])
- .optional()
- .describe(
- "Reasoning effort, validated against `runtime_adapter`\/`model`'s supported set.\n\n\* `low` - low\n\* `medium` - medium\n\* `high` - high\n\* `xhigh` - xhigh\n\* `max` - max\n\* `ultracode` - ultracode"
- ),
- repositories: zod
- .array(
- zod.object({
- github_integration_id: zod
- .number()
- .describe('GitHub integration id this repository is accessed through.'),
- full_name: zod
- .string()
- .max(loopsPartialUpdateBodyRepositoriesItemFullNameMax)
- .describe('Repository in `organization\/repo` format, e.g. `posthog\/posthog`.'),
- })
- )
- .max(loopsPartialUpdateBodyRepositoriesMax)
- .optional()
- .describe(
- 'Repositories this loop operates on, ordered. Capped at 1 until multi-repo execution ships. May be empty for report-only loops.'
- ),
- sandbox_environment: zod
- .string()
- .nullish()
- .describe('Sandbox environment carrying encrypted env vars and the network allowlist into every run.'),
- enabled: zod
- .boolean()
- .optional()
- .describe("Whether the loop's triggers are active. Pausing disables all triggers."),
- overlap_policy: zod
- .enum(['skip', 'allow', 'cancel_previous'])
- .describe('\* `skip` - skip\n\* `allow` - allow\n\* `cancel_previous` - cancel_previous')
- .optional()
- .describe(
- "What happens when a trigger fires while a run is already active: 'skip', 'allow', or 'cancel_previous'.\n\n\* `skip` - skip\n\* `allow` - allow\n\* `cancel_previous` - cancel_previous"
- ),
- behaviors: zod
- .object({
- create_prs: zod
- .boolean()
- .default(loopsPartialUpdateBodyBehaviorsOneCreatePrsDefault)
- .describe('Whether the agent may push branches and open PRs. False makes this a report-only loop.'),
- watch_ci: zod
- .boolean()
- .default(loopsPartialUpdateBodyBehaviorsOneWatchCiDefault)
- .describe('Whether to watch CI on loop-created PRs and report status.'),
- fix_review_comments: zod
- .boolean()
- .default(loopsPartialUpdateBodyBehaviorsOneFixReviewCommentsDefault)
- .describe('Whether to automatically address review comments on loop-created PRs.'),
- max_fix_iterations: zod
- .number()
- .min(loopsPartialUpdateBodyBehaviorsOneMaxFixIterationsMin)
- .max(loopsPartialUpdateBodyBehaviorsOneMaxFixIterationsMax)
- .default(loopsPartialUpdateBodyBehaviorsOneMaxFixIterationsDefault)
- .describe('Ceiling on automatic CI\/review-comment fix iterations, capped at 10.'),
- })
- .optional()
- .describe('PR \/ CI-follow-up behavior configuration.'),
- connectors: zod
- .object({
- mcp_installation_ids: zod
- .array(zod.string())
- .optional()
- .describe("MCP Store installation ids (Slack, Linear, etc.) available to this loop's runs."),
- posthog_mcp_scopes: zod
- .enum(['read_only', 'full'])
- .describe('\* `read_only` - read_only\n\* `full` - full')
- .default(loopsPartialUpdateBodyConnectorsOnePosthogMcpScopesDefault)
- .describe(
- "Scope of the PostHog MCP access injected into this loop's runs.\n\n\* `read_only` - read_only\n\* `full` - full"
- ),
- })
- .optional()
- .describe("MCP connector configuration for this loop's runs."),
- notifications: zod
- .object({
- push: zod
- .object({
- enabled: zod
- .boolean()
- .default(loopsPartialUpdateBodyNotificationsOnePushOneEnabledDefault)
- .describe('Whether this channel is active.'),
- events: zod
- .array(
- zod
- .enum([
- 'run_completed',
- 'run_failed',
- 'pr_created',
- 'pr_merged',
- 'pr_closed',
- 'needs_attention',
- ])
- .describe(
- '\* `run_completed` - run_completed\n\* `run_failed` - run_failed\n\* `pr_created` - pr_created\n\* `pr_merged` - pr_merged\n\* `pr_closed` - pr_closed\n\* `needs_attention` - needs_attention'
- )
- )
- .optional()
- .describe(
- 'Event kinds this channel notifies on. One or more of: run_completed, run_failed, pr_created, pr_merged, pr_closed, needs_attention.'
- ),
- params: zod
- .record(zod.string(), zod.unknown())
- .optional()
- .describe("Channel-specific parameters, e.g. Slack's `integration_id` and `channel`."),
- })
- .optional()
- .describe('Push notification settings.'),
- email: zod
- .object({
- enabled: zod
- .boolean()
- .default(loopsPartialUpdateBodyNotificationsOneEmailOneEnabledDefault)
- .describe('Whether this channel is active.'),
- events: zod
- .array(
- zod
- .enum([
- 'run_completed',
- 'run_failed',
- 'pr_created',
- 'pr_merged',
- 'pr_closed',
- 'needs_attention',
- ])
- .describe(
- '\* `run_completed` - run_completed\n\* `run_failed` - run_failed\n\* `pr_created` - pr_created\n\* `pr_merged` - pr_merged\n\* `pr_closed` - pr_closed\n\* `needs_attention` - needs_attention'
- )
- )
- .optional()
- .describe(
- 'Event kinds this channel notifies on. One or more of: run_completed, run_failed, pr_created, pr_merged, pr_closed, needs_attention.'
- ),
- params: zod
- .record(zod.string(), zod.unknown())
- .optional()
- .describe("Channel-specific parameters, e.g. Slack's `integration_id` and `channel`."),
- })
- .optional()
- .describe('Email notification settings.'),
- slack: zod
- .object({
- enabled: zod
- .boolean()
- .default(loopsPartialUpdateBodyNotificationsOneSlackOneEnabledDefault)
- .describe('Whether this channel is active.'),
- events: zod
- .array(
- zod
- .enum([
- 'run_completed',
- 'run_failed',
- 'pr_created',
- 'pr_merged',
- 'pr_closed',
- 'needs_attention',
- ])
- .describe(
- '\* `run_completed` - run_completed\n\* `run_failed` - run_failed\n\* `pr_created` - pr_created\n\* `pr_merged` - pr_merged\n\* `pr_closed` - pr_closed\n\* `needs_attention` - needs_attention'
- )
- )
- .optional()
- .describe(
- 'Event kinds this channel notifies on. One or more of: run_completed, run_failed, pr_created, pr_merged, pr_closed, needs_attention.'
- ),
- params: zod
- .record(zod.string(), zod.unknown())
- .optional()
- .describe("Channel-specific parameters, e.g. Slack's `integration_id` and `channel`."),
- })
- .optional()
- .describe('Slack notification settings.'),
- })
- .optional()
- .describe('Per-channel notification configuration.'),
- context_target: zod
- .union([
- zod.object({
- channel_id: zod.string().describe('Id of the channel (context) this loop is attached to.'),
- name: zod
- .string()
- .max(loopsPartialUpdateBodyContextTargetOneNameMax)
- .describe("Display name of the context, shown in the loop's publish prompt."),
- outputs: zod
- .object({
- post_to_feed: zod
- .boolean()
- .default(loopsPartialUpdateBodyContextTargetOneOutputsOnePostToFeedDefault)
- .describe(
- "Whether each run is filed into the context's feed as a card (sets the run's channel)."
- ),
- update_context: zod
- .boolean()
- .default(loopsPartialUpdateBodyContextTargetOneOutputsOneUpdateContextDefault)
- .describe(
- "Whether each run reads and republishes the context's context.md to reflect the latest state."
- ),
- canvas_id: zod
- .string()
- .nullish()
- .describe(
- 'Id of a canvas in this context the loop keeps up to date each run, or null to maintain none.'
- ),
- })
- .optional()
- .describe('What the loop maintains in this context each run.'),
- }),
- zod.null(),
- ])
- .optional()
- .describe(
- 'Context (channel) this loop is attached to, or null to detach. Drives feed placement and the context.md \/ canvas it keeps up to date.'
- ),
- triggers: zod
- .array(
- zod.object({
- id: zod
- .string()
- .optional()
- .describe('Existing trigger id to update in place. Omit to create a new trigger.'),
- type: zod
- .enum(['schedule', 'github', 'api'])
- .describe('\* `schedule` - schedule\n\* `github` - github\n\* `api` - api')
- .describe(
- 'Trigger type: `schedule` (cron or one-time), `github` (repo webhook events), or `api` (POST to `trigger\/`).\n\n\* `schedule` - schedule\n\* `github` - github\n\* `api` - api'
- ),
- enabled: zod
- .boolean()
- .default(loopsPartialUpdateBodyTriggersItemEnabledDefault)
- .describe('Whether this trigger is active. Disabling pauses only this trigger.'),
- config: zod
- .unknown()
- .optional()
- .describe(
- 'Trigger configuration, shape validated per `type`: schedule takes `{cron_expression, timezone}` or `{run_at}` for a one-time run; github takes `{github_integration_id, repository, events, filters}` where `events` is one or more of `issues`, `issue_comment`, `pull_request`, `push` (`event.action` shorthand like `issues.opened` is folded into an `actions` filter, one event per trigger) and `filters` takes `{actions, branches, labels, payload}`. Use `actions` for the event action; `payload` is for anything else in the webhook body, as a list of `{path, equals}` conditions where `path` is a dot-path of object keys and `equals` is a string or list of strings, e.g. `[{\"path\": \"requested_team.slug\", \"equals\": \"team-security\"}]` to run only when that team is asked to review. All filters must match. API triggers take no config.'
- ),
- })
- )
- .optional()
- .describe(
- 'Full desired trigger list, id-stable: entries with a matching `id` are updated in place, entries without one are created, and existing triggers absent from this list are deleted. Omit the field entirely to leave triggers untouched. At most 25 triggers per loop.'
- ),
- })
- .describe(
- 'Request body for creating or updating a loop. Field required\/default semantics match\nthe `Loop` model; partial updates only touch keys present in the payload.'
- )
-
-/**
- * Soft delete. Pauses every trigger's schedule. Owner or a project admin only.
- * @summary Delete a loop
- */
-export const LoopsDestroyParams = () => zod.object({
- id: zod.string(),
- project_id: zod
- .string()
- .describe(
- "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
- ),
-})
-
-/**
- * Dry run: renders the assembled instructions and trigger context for a supplied sample payload (or a synthetic schedule fire when omitted), without creating a task, run, or any other side effect.
- * @summary Preview a loop fire
- */
-export const LoopsPreviewCreateParams = () => zod.object({
- id: zod.string(),
- project_id: zod
- .string()
- .describe(
- "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
- ),
-})
-
-export const loopsPreviewCreateBodyTriggerTypeDefault = `schedule`
-
-export const LoopsPreviewCreateBody = () => zod.object({
- trigger_type: zod
- .enum(['schedule', 'github', 'api'])
- .describe('\* `schedule` - schedule\n\* `github` - github\n\* `api` - api')
- .default(loopsPreviewCreateBodyTriggerTypeDefault)
- .describe(
- 'Trigger type to simulate. Defaults to a synthetic schedule fire.\n\n\* `schedule` - schedule\n\* `github` - github\n\* `api` - api'
- ),
- payload: zod
- .unknown()
- .optional()
- .describe('Sample trigger payload, e.g. a GitHub webhook body or an API trigger body, to render into context.'),
-})
-
-/**
- * Manual fire from the UI. Owner-only for personal loops; any team member for team loops.
- * @summary Run a loop manually
- */
-export const LoopsRunCreateParams = () => zod.object({
- id: zod.string(),
- project_id: zod
- .string()
- .describe(
- "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
- ),
-})
-
-/**
- * Run history for a loop, newest first, cursor-paginated.
- * @summary List loop runs
- */
-export const LoopsRunsRetrieveParams = () => zod.object({
- id: zod.string(),
- project_id: zod
- .string()
- .describe(
- "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
- ),
-})
-
-export const loopsRunsRetrieveQueryLimitDefault = 50
-export const loopsRunsRetrieveQueryLimitMax = 100
-
-export const LoopsRunsRetrieveQueryParams = () => zod.object({
- cursor: zod
- .string()
- .min(1)
- .optional()
- .describe("Opaque pagination cursor from a previous response's `next_cursor`."),
- limit: zod
- .number()
- .min(1)
- .max(loopsRunsRetrieveQueryLimitMax)
- .default(loopsRunsRetrieveQueryLimitDefault)
- .describe('Max results per page (default 50, max 100).'),
- status: zod
- .enum(['not_started', 'queued', 'in_progress', 'completed', 'failed', 'cancelled'])
- .optional()
- .describe(
- 'Only return runs with this status. Use failed to read errors even when canvas state is unavailable.\n\n\* `not_started` - Not Started\n\* `queued` - Queued\n\* `in_progress` - In Progress\n\* `completed` - Completed\n\* `failed` - Failed\n\* `cancelled` - Cancelled'
- ),
-})
-
/**
* List channels the requester can access, sorted by name and ID. Includes public channels, their personal #me channel, and private channels they belong to. Call provision_defaults to create missing default channels. Send limit and offset to get a page with count, next, previous, and results. Without limit, the response is an array of all accessible channels.
* @summary List channels
diff --git a/services/mcp/src/hono/tool-executor.ts b/services/mcp/src/hono/tool-executor.ts
index 28696103ab59..8985becf1b3d 100644
--- a/services/mcp/src/hono/tool-executor.ts
+++ b/services/mcp/src/hono/tool-executor.ts
@@ -36,6 +36,7 @@ import {
describeInputShape,
describeValidationError,
formatInputValidationError,
+ getDeprecatedToolRedirect,
markNoncanonicalMetricRun,
parseExecCallInnerArgs,
parseExecCallInnerToolName,
@@ -268,7 +269,8 @@ export class ToolExecutor {
if (!state.allTools.some((t) => t.name === toolName)) {
toolCallsTotal.inc({ tool: toolName, status: 'error' })
- return { content: [{ type: 'text', text: `Tool ${toolName} not found` }], isError: true }
+ const text = getDeprecatedToolRedirect(toolName, state.allTools) ?? `Tool ${toolName} not found`
+ return { content: [{ type: 'text', text }], isError: true }
}
const preBuilt = this.catalog.getToolByName(toolName)
diff --git a/services/mcp/src/resources/ui-apps.generated.ts b/services/mcp/src/resources/ui-apps.generated.ts
index 74bfd9d1873c..b14fa359deb2 100644
--- a/services/mcp/src/resources/ui-apps.generated.ts
+++ b/services/mcp/src/resources/ui-apps.generated.ts
@@ -18,7 +18,6 @@ export const FEATURE_FLAG_TESTING_RESOURCE_URI = 'ui://posthog/feature-flag-test
export const INLINE_SCAN_RESOURCE_URI = 'ui://posthog/inline-scan.html'
export const INSIGHT_ACTORS_RESOURCE_URI = 'ui://posthog/insight-actors.html'
export const LLM_COSTS_RESOURCE_URI = 'ui://posthog/llm-costs.html'
-export const LOOPS_REVIEW_RESOURCE_URI = 'ui://posthog/loops-review.html'
export const QUERY_RESULTS_RESOURCE_URI = 'ui://posthog/query-results.html'
export const RENDER_UI_RESOURCE_URI = 'ui://posthog/render-ui.html'
export const SESSION_RECORDING_RESOURCE_URI = 'ui://posthog/session-recording.html'
@@ -52,7 +51,6 @@ export type UiAppKey =
| 'inline-scan'
| 'insight-actors'
| 'llm-costs'
- | 'loops-review'
| 'query-results'
| 'render-ui'
| 'session-recording'
@@ -86,7 +84,6 @@ export const URI_MAP: Record<UiAppKey, string> = {
'inline-scan': INLINE_SCAN_RESOURCE_URI,
'insight-actors': INSIGHT_ACTORS_RESOURCE_URI,
'llm-costs': LLM_COSTS_RESOURCE_URI,
- 'loops-review': LOOPS_REVIEW_RESOURCE_URI,
'query-results': QUERY_RESULTS_RESOURCE_URI,
'render-ui': RENDER_UI_RESOURCE_URI,
'session-recording': SESSION_RECORDING_RESOURCE_URI,
@@ -252,12 +249,6 @@ export const UI_APPS: Array<{
description: 'Llm Costs detail view',
appDir: 'generated/llm-costs',
},
- {
- name: 'PostHog Loop Review',
- uri: LOOPS_REVIEW_RESOURCE_URI,
- description: 'Review card for a loop before creation, with a Create loop action.',
- appDir: 'loops-review',
- },
{
name: 'Query Results',
uri: QUERY_RESULTS_RESOURCE_URI,
diff --git a/services/mcp/src/tools/exec.ts b/services/mcp/src/tools/exec.ts
index 07bcabba9403..0c66ae2b6c51 100644
--- a/services/mcp/src/tools/exec.ts
+++ b/services/mcp/src/tools/exec.ts
@@ -614,6 +614,32 @@ const DEPRECATED_TOOL_REDIRECTS: Record<string, (allTools: Tool<ZodObjectAny>[])
`Tool "${removed}" was removed. It was a deprecation alias for "${replacement}", which takes the same arguments. Call "${replacement}" instead.`,
])
),
+ // The legacy loops API was removed. Loops are workflows tagged origin_product "loops".
+ ...Object.fromEntries(
+ [
+ ['loops-create', '"workflows-create"'],
+ ['loops-create-execute', '"workflows-create"'],
+ ['loops-create-prepare', '"workflows-create"'],
+ ['loops-destroy', '"workflows-archive"'],
+ ['loops-list', '"workflows-list"'],
+ ['loops-partial-update', '"workflows-patch-graph" or "workflows-update"'],
+ ['loops-preview-create', '"workflows-test-run"'],
+ ['loops-retrieve', '"workflows-get"'],
+ ['loops-review', '"workflows-create"'],
+ ].map(([removed, replacement]) => [
+ removed,
+ () =>
+ `Tool "${removed}" was removed. Loops run on workflows: read the building-loops skill, then use ${replacement} with origin_product "loops".`,
+ ])
+ ),
+ 'loops-run-create': () =>
+ 'Tool "loops-run-create" was removed. Loops run on workflows. "workflows-test-run" tests the graph one node at a time and mocks outbound calls by default; it does not start a real task run. To fire a loop for real, use Run now on an enabled schedule loop in PostHog Desktop, or wait for its trigger.',
+ 'loops-runs-retrieve': () =>
+ 'Tool "loops-runs-retrieve" was removed. Loops run on workflows. For run history, call "tasks-list" with the hog_flow_id of the loop and archived set to all, then "tasks-runs-retrieve" on a run for its branch and output.',
+}
+
+export function getDeprecatedToolRedirect(toolName: string, allTools: Tool<ZodObjectAny>[]): string | undefined {
+ return DEPRECATED_TOOL_REDIRECTS[toolName]?.(allTools)
}
/** The form caller keys and field names are matched on, so `date_from` reaches a field
@@ -1644,9 +1670,9 @@ function findTool(
): Tool<ZodObjectAny> {
const tool = tools.find((t) => t.name === name)
if (!tool) {
- const redirect = DEPRECATED_TOOL_REDIRECTS[name]
+ const redirect = getDeprecatedToolRedirect(name, tools)
if (redirect) {
- throw new ExecCommandError(redirect(tools), 'deprecated_tool')
+ throw new ExecCommandError(redirect, 'deprecated_tool')
}
const flagGatedTool = flagGatedTools.find((candidate) => candidate.name === name)
if (flagGatedTool) {
diff --git a/services/mcp/src/tools/generated/context_layer.ts b/services/mcp/src/tools/generated/context_layer.ts
index c4cefc20b252..aecb0af6eaa0 100644
--- a/services/mcp/src/tools/generated/context_layer.ts
+++ b/services/mcp/src/tools/generated/context_layer.ts
@@ -83,86 +83,6 @@ const contextWikiPageUpdate = (): ToolBase<
},
})
-const LoopContextWikiChannelResolveSchema = () => {
- const ContextLayerAgentChannelPagesRetrieveParams = orvalSchemas.ContextLayerAgentChannelPagesRetrieveParams()
- return ContextLayerAgentChannelPagesRetrieveParams.omit({ project_id: true })
-}
-
-const loopContextWikiChannelResolve = (): ToolBase<
- ReturnType<typeof LoopContextWikiChannelResolveSchema>,
- Schemas.ChannelWikiPage
-> => ({
- name: 'loop-context-wiki-channel-resolve',
- schema: LoopContextWikiChannelResolveSchema(),
- handler: async (context: Context, params: z.infer<ReturnType<typeof LoopContextWikiChannelResolveSchema>>) => {
- const projectId = await context.stateManager.getProjectId()
- const result = await context.api.request<Schemas.ChannelWikiPage>({
- method: 'GET',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/context_layer/agent/channel-pages/${encodeURIComponent(String(params.channel_id))}/`,
- })
- return result
- },
-})
-
-const LoopContextWikiPageRetrieveSchema = () => {
- const ContextLayerAgentPagesRetrieveQueryParams = orvalSchemas.ContextLayerAgentPagesRetrieveQueryParams()
- return ContextLayerAgentPagesRetrieveQueryParams.extend({ limit: WikiPageReadLimitSchema })
-}
-
-const loopContextWikiPageRetrieve = (): ToolBase<
- ReturnType<typeof LoopContextWikiPageRetrieveSchema>,
- Schemas.WikiPage
-> => ({
- name: 'loop-context-wiki-page-retrieve',
- schema: LoopContextWikiPageRetrieveSchema(),
- handler: async (context: Context, params: z.infer<ReturnType<typeof LoopContextWikiPageRetrieveSchema>>) => {
- const projectId = await context.stateManager.getProjectId()
- const result = await context.api.request<Schemas.WikiPage>({
- method: 'GET',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/context_layer/agent/pages/`,
- query: {
- head_sha: params.head_sha,
- limit: params.limit,
- offset: params.offset,
- path: params.path,
- },
- })
- return result
- },
-})
-
-const LoopContextWikiPageUpdateSchema = () => {
- const ContextLayerAgentPagesUpdateBody = orvalSchemas.ContextLayerAgentPagesUpdateBody()
- return ContextLayerAgentPagesUpdateBody
-}
-
-const loopContextWikiPageUpdate = (): ToolBase<
- ReturnType<typeof LoopContextWikiPageUpdateSchema>,
- Schemas.ContextLayerStatus
-> => ({
- name: 'loop-context-wiki-page-update',
- schema: LoopContextWikiPageUpdateSchema(),
- handler: async (context: Context, params: z.infer<ReturnType<typeof LoopContextWikiPageUpdateSchema>>) => {
- const projectId = await context.stateManager.getProjectId()
- const body: Record<string, unknown> = {}
- if (params.path !== undefined) {
- body['path'] = params.path
- }
- if (params.content !== undefined) {
- body['content'] = params.content
- }
- if (params.base_head !== undefined) {
- body['base_head'] = params.base_head
- }
- const result = await context.api.request<Schemas.ContextLayerStatus>({
- method: 'PUT',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/context_layer/agent/pages/`,
- body,
- })
- return result
- },
-})
-
const TaskContextWikiChannelResolveSchema = () => {
const ContextLayerAgentChannelPagesRetrieveParams = orvalSchemas.ContextLayerAgentChannelPagesRetrieveParams()
return ContextLayerAgentChannelPagesRetrieveParams.omit({ project_id: true })
@@ -279,9 +199,6 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'context-wiki-channel-resolve': contextWikiChannelResolve,
'context-wiki-page-retrieve': contextWikiPageRetrieve,
'context-wiki-page-update': contextWikiPageUpdate,
- 'loop-context-wiki-channel-resolve': loopContextWikiChannelResolve,
- 'loop-context-wiki-page-retrieve': loopContextWikiPageRetrieve,
- 'loop-context-wiki-page-update': loopContextWikiPageUpdate,
'task-context-wiki-channel-resolve': taskContextWikiChannelResolve,
'task-context-wiki-page-propose': taskContextWikiPagePropose,
'task-context-wiki-page-retrieve': taskContextWikiPageRetrieve,
diff --git a/services/mcp/src/tools/generated/tasks.ts b/services/mcp/src/tools/generated/tasks.ts
index ef79930dba49..fd6ba7f4819d 100644
--- a/services/mcp/src/tools/generated/tasks.ts
+++ b/services/mcp/src/tools/generated/tasks.ts
@@ -8,12 +8,6 @@ import {
TaskAgentCreateSchema,
TaskAgentRunCreateSchema,
} from '@/schema/tool-inputs'
-import { getConfirmedActionRuntime } from '@/tools/confirmed-action-registry'
-import {
- executeConfirmedAction,
- prepareConfirmedAction,
- type PrepareConfirmedActionResult,
-} from '@/tools/confirmed-action-runtime'
import { withPostHogUrl, pickResponseFields, omitResponseFields, type WithPostHogUrl } from '@/tools/tool-utils'
import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'
@@ -153,386 +147,6 @@ const channelRetrieve = (): ToolBase<ReturnType<typeof ChannelRetrieveSchema>, S
},
})
-const LoopChannelInstructionsRetrieveSchema = () => {
- const TaskChannelsInstructionsRetrieveParams = orvalSchemas.TaskChannelsInstructionsRetrieveParams()
- return TaskChannelsInstructionsRetrieveParams.omit({ project_id: true }).extend({
- id: TaskChannelsInstructionsRetrieveParams.shape['id'].describe("ID of the loop's context channel."),
- })
-}
-
-const loopChannelInstructionsRetrieve = (): ToolBase<
- ReturnType<typeof LoopChannelInstructionsRetrieveSchema>,
- Schemas.ChannelInstructionsDTO
-> => ({
- name: 'loop-channel-instructions-retrieve',
- schema: LoopChannelInstructionsRetrieveSchema(),
- handler: async (context: Context, params: z.infer<ReturnType<typeof LoopChannelInstructionsRetrieveSchema>>) => {
- const projectId = await context.stateManager.getProjectId()
- const result = await context.api.request<Schemas.ChannelInstructionsDTO>({
- method: 'GET',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/task_channels/${encodeURIComponent(String(params.id))}/instructions/`,
- })
- return result
- },
-})
-
-const LoopChannelInstructionsUpdateSchema = () => {
- const TaskChannelsInstructionsUpdateBody = orvalSchemas.TaskChannelsInstructionsUpdateBody()
- const TaskChannelsInstructionsUpdateParams = orvalSchemas.TaskChannelsInstructionsUpdateParams()
- return TaskChannelsInstructionsUpdateParams.omit({ project_id: true })
- .extend(TaskChannelsInstructionsUpdateBody.shape)
- .extend({
- id: TaskChannelsInstructionsUpdateParams.shape['id'].describe("ID of the loop's context channel."),
- base_version: ChannelInstructionsBaseVersionSchema,
- })
-}
-
-const loopChannelInstructionsUpdate = (): ToolBase<
- ReturnType<typeof LoopChannelInstructionsUpdateSchema>,
- Schemas.ChannelInstructionsDTO
-> => ({
- name: 'loop-channel-instructions-update',
- schema: LoopChannelInstructionsUpdateSchema(),
- handler: async (context: Context, params: z.infer<ReturnType<typeof LoopChannelInstructionsUpdateSchema>>) => {
- const projectId = await context.stateManager.getProjectId()
- const body: Record<string, unknown> = {}
- if (params.content !== undefined) {
- body['content'] = params.content
- }
- if (params.base_version !== undefined) {
- body['base_version'] = params.base_version
- }
- const result = await context.api.request<Schemas.ChannelInstructionsDTO>({
- method: 'PUT',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/task_channels/${encodeURIComponent(String(params.id))}/instructions/`,
- body,
- })
- return result
- },
-})
-
-const LoopsCreateSchema = () => {
- const LoopsCreateBody = orvalSchemas.LoopsCreateBody()
- return LoopsCreateBody
-}
-
-const LoopsCreateSchemaExecute = z.strictObject({
- confirmation_hash: z
- .string()
- .describe('The confirmation_hash returned by the matching -prepare tool. Pass it back verbatim.'),
- confirmation: z.string().describe('The literal string "confirm", typed by the user in chat. Required to proceed.'),
-})
-
-const loopsCreatePrepare = (): ToolBase<ReturnType<typeof LoopsCreateSchema>, PrepareConfirmedActionResult> => ({
- name: 'loops-create-prepare',
- schema: LoopsCreateSchema(),
- handler: async (context: Context, params: z.infer<ReturnType<typeof LoopsCreateSchema>>) => {
- const __runtime = getConfirmedActionRuntime()
- const __scopeProjectId = await context.stateManager.getProjectId()
- return await prepareConfirmedAction(context, {
- args: params,
- purpose: 'loops-create',
- actionLabel: 'create loop',
- messageTemplate:
- "About to create the loop '{name}', a persistent automation that will run unattended with your GitHub and connector access whenever its triggers fire. Reply 'confirm' to create it.\n",
- codec: __runtime.codec,
- stash: __runtime.stash,
- boundScope: { projectId: String(__scopeProjectId) },
- })
- },
-})
-
-const loopsCreateExecute = (): ToolBase<typeof LoopsCreateSchemaExecute, Schemas.LoopDTO> => ({
- name: 'loops-create-execute',
- schema: LoopsCreateSchemaExecute,
- handler: async (context: Context, confirmationParams: z.infer<typeof LoopsCreateSchemaExecute>) => {
- const __runtime = getConfirmedActionRuntime()
- const __scopeProjectId = await context.stateManager.getProjectId()
- const __guard = await executeConfirmedAction<z.infer<ReturnType<typeof LoopsCreateSchema>>>(context, {
- incomingArgs: confirmationParams,
- purpose: 'loops-create',
- codec: __runtime.codec,
- ledger: __runtime.ledger,
- stash: __runtime.stash,
- expectedScope: { projectId: String(__scopeProjectId) },
- })
- if (!__guard.ok) {
- return __guard.result as never
- }
- const params = __guard.verifiedArgs
- const projectId = __scopeProjectId
- const body: Record<string, unknown> = {}
- if (params.name !== undefined) {
- body['name'] = params.name
- }
- if (params.description !== undefined) {
- body['description'] = params.description
- }
- if (params.take_ownership !== undefined) {
- body['take_ownership'] = params.take_ownership
- }
- if (params.visibility !== undefined) {
- body['visibility'] = params.visibility
- }
- if (params.instructions !== undefined) {
- body['instructions'] = params.instructions
- }
- if (params.runtime_adapter !== undefined) {
- body['runtime_adapter'] = params.runtime_adapter
- }
- if (params.model !== undefined) {
- body['model'] = params.model
- }
- if (params.reasoning_effort !== undefined) {
- body['reasoning_effort'] = params.reasoning_effort
- }
- if (params.repositories !== undefined) {
- body['repositories'] = params.repositories
- }
- if (params.sandbox_environment !== undefined) {
- body['sandbox_environment'] = params.sandbox_environment
- }
- if (params.enabled !== undefined) {
- body['enabled'] = params.enabled
- }
- if (params.overlap_policy !== undefined) {
- body['overlap_policy'] = params.overlap_policy
- }
- if (params.behaviors !== undefined) {
- body['behaviors'] = params.behaviors
- }
- if (params.connectors !== undefined) {
- body['connectors'] = params.connectors
- }
- if (params.notifications !== undefined) {
- body['notifications'] = params.notifications
- }
- if (params.context_target !== undefined) {
- body['context_target'] = params.context_target
- }
- if (params.triggers !== undefined) {
- body['triggers'] = params.triggers
- }
- const result = await context.api.request<Schemas.LoopDTO>({
- method: 'POST',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/loops/`,
- body,
- })
- return result
- },
-})
-
-const LoopsDestroySchema = () => {
- const LoopsDestroyParams = orvalSchemas.LoopsDestroyParams()
- return LoopsDestroyParams.omit({ project_id: true })
-}
-
-const loopsDestroy = (): ToolBase<ReturnType<typeof LoopsDestroySchema>, unknown> => ({
- name: 'loops-destroy',
- schema: LoopsDestroySchema(),
- handler: async (context: Context, params: z.infer<ReturnType<typeof LoopsDestroySchema>>) => {
- const projectId = await context.stateManager.getProjectId()
- const result = await context.api.request<unknown>({
- method: 'DELETE',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/loops/${encodeURIComponent(String(params.id))}/`,
- })
- return result
- },
-})
-
-const LoopsListSchema = () => {
- const LoopsListQueryParams = orvalSchemas.LoopsListQueryParams()
- return LoopsListQueryParams
-}
-
-const loopsList = (): ToolBase<ReturnType<typeof LoopsListSchema>, WithPostHogUrl<Schemas.PaginatedLoopDTOList>> => ({
- name: 'loops-list',
- schema: LoopsListSchema(),
- handler: async (context: Context, params: z.infer<ReturnType<typeof LoopsListSchema>>) => {
- const projectId = await context.stateManager.getProjectId()
- const result = await context.api.request<Schemas.PaginatedLoopDTOList>({
- method: 'GET',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/loops/`,
- query: {
- limit: params.limit,
- offset: params.offset,
- },
- })
- return await withPostHogUrl(context, result, '/tasks')
- },
-})
-
-const LoopsPartialUpdateSchema = () => {
- const LoopsPartialUpdateBody = orvalSchemas.LoopsPartialUpdateBody()
- const LoopsPartialUpdateParams = orvalSchemas.LoopsPartialUpdateParams()
- return LoopsPartialUpdateParams.omit({ project_id: true }).extend(LoopsPartialUpdateBody.shape)
-}
-
-const loopsPartialUpdate = (): ToolBase<ReturnType<typeof LoopsPartialUpdateSchema>, Schemas.LoopDTO> => ({
- name: 'loops-partial-update',
- schema: LoopsPartialUpdateSchema(),
- handler: async (context: Context, params: z.infer<ReturnType<typeof LoopsPartialUpdateSchema>>) => {
- const projectId = await context.stateManager.getProjectId()
- const body: Record<string, unknown> = {}
- if (params.name !== undefined) {
- body['name'] = params.name
- }
- if (params.description !== undefined) {
- body['description'] = params.description
- }
- if (params.take_ownership !== undefined) {
- body['take_ownership'] = params.take_ownership
- }
- if (params.visibility !== undefined) {
- body['visibility'] = params.visibility
- }
- if (params.instructions !== undefined) {
- body['instructions'] = params.instructions
- }
- if (params.runtime_adapter !== undefined) {
- body['runtime_adapter'] = params.runtime_adapter
- }
- if (params.model !== undefined) {
- body['model'] = params.model
- }
- if (params.reasoning_effort !== undefined) {
- body['reasoning_effort'] = params.reasoning_effort
- }
- if (params.repositories !== undefined) {
- body['repositories'] = params.repositories
- }
- if (params.sandbox_environment !== undefined) {
- body['sandbox_environment'] = params.sandbox_environment
- }
- if (params.enabled !== undefined) {
- body['enabled'] = params.enabled
- }
- if (params.overlap_policy !== undefined) {
- body['overlap_policy'] = params.overlap_policy
- }
- if (params.behaviors !== undefined) {
- body['behaviors'] = params.behaviors
- }
- if (params.connectors !== undefined) {
- body['connectors'] = params.connectors
- }
- if (params.notifications !== undefined) {
- body['notifications'] = params.notifications
- }
- if (params.context_target !== undefined) {
- body['context_target'] = params.context_target
- }
- if (params.triggers !== undefined) {
- body['triggers'] = params.triggers
- }
- const result = await context.api.request<Schemas.LoopDTO>({
- method: 'PATCH',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/loops/${encodeURIComponent(String(params.id))}/`,
- body,
- })
- return result
- },
-})
-
-const LoopsPreviewCreateSchema = () => {
- const LoopsPreviewCreateBody = orvalSchemas.LoopsPreviewCreateBody()
- const LoopsPreviewCreateParams = orvalSchemas.LoopsPreviewCreateParams()
- return LoopsPreviewCreateParams.omit({ project_id: true }).extend(LoopsPreviewCreateBody.shape)
-}
-
-const loopsPreviewCreate = (): ToolBase<ReturnType<typeof LoopsPreviewCreateSchema>, Schemas.LoopPreviewDTO> => ({
- name: 'loops-preview-create',
- schema: LoopsPreviewCreateSchema(),
- handler: async (context: Context, params: z.infer<ReturnType<typeof LoopsPreviewCreateSchema>>) => {
- const projectId = await context.stateManager.getProjectId()
- const body: Record<string, unknown> = {}
- if (params.trigger_type !== undefined) {
- body['trigger_type'] = params.trigger_type
- }
- if (params.payload !== undefined) {
- body['payload'] = params.payload
- }
- const result = await context.api.request<Schemas.LoopPreviewDTO>({
- method: 'POST',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/loops/${encodeURIComponent(String(params.id))}/preview/`,
- body,
- })
- return result
- },
-})
-
-const LoopsRetrieveSchema = () => {
- const LoopsRetrieveParams = orvalSchemas.LoopsRetrieveParams()
- return LoopsRetrieveParams.omit({ project_id: true })
-}
-
-const loopsRetrieve = (): ToolBase<ReturnType<typeof LoopsRetrieveSchema>, WithPostHogUrl<Schemas.LoopDTO>> => ({
- name: 'loops-retrieve',
- schema: LoopsRetrieveSchema(),
- handler: async (context: Context, params: z.infer<ReturnType<typeof LoopsRetrieveSchema>>) => {
- const projectId = await context.stateManager.getProjectId()
- const result = await context.api.request<Schemas.LoopDTO>({
- method: 'GET',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/loops/${encodeURIComponent(String(params.id))}/`,
- })
- return await withPostHogUrl(context, result, `/tasks/${result.id}`)
- },
-})
-
-const LoopsRunCreateSchema = () => {
- const LoopsRunCreateParams = orvalSchemas.LoopsRunCreateParams()
- return LoopsRunCreateParams.omit({ project_id: true })
-}
-
-const loopsRunCreate = (): ToolBase<ReturnType<typeof LoopsRunCreateSchema>, Schemas.LoopFireResult> => ({
- name: 'loops-run-create',
- schema: LoopsRunCreateSchema(),
- handler: async (context: Context, params: z.infer<ReturnType<typeof LoopsRunCreateSchema>>) => {
- const projectId = await context.stateManager.getProjectId()
- const result = await context.api.request<Schemas.LoopFireResult>({
- method: 'POST',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/loops/${encodeURIComponent(String(params.id))}/run/`,
- })
- return result
- },
-})
-
-const LoopsRunsRetrieveSchema = () => {
- const LoopsRunsRetrieveParams = orvalSchemas.LoopsRunsRetrieveParams()
- const LoopsRunsRetrieveQueryParams = orvalSchemas.LoopsRunsRetrieveQueryParams()
- return LoopsRunsRetrieveParams.omit({ project_id: true }).extend(LoopsRunsRetrieveQueryParams.shape)
-}
-
-const loopsRunsRetrieve = (): ToolBase<
- ReturnType<typeof LoopsRunsRetrieveSchema>,
- WithPostHogUrl<Schemas.LoopRunPage>
-> => ({
- name: 'loops-runs-retrieve',
- schema: LoopsRunsRetrieveSchema(),
- handler: async (context: Context, params: z.infer<ReturnType<typeof LoopsRunsRetrieveSchema>>) => {
- const projectId = await context.stateManager.getProjectId()
- const result = await context.api.request<Schemas.LoopRunPage>({
- method: 'GET',
- path: `/api/projects/${encodeURIComponent(String(projectId))}/loops/${encodeURIComponent(String(params.id))}/runs/`,
- query: {
- cursor: params.cursor,
- limit: params.limit,
- status: params.status,
- },
- })
- return await withPostHogUrl(
- context,
- {
- ...result,
- results: await Promise.all(
- (result.results ?? []).map((item) => withPostHogUrl(context, item, `/tasks/${item.id}/runs`))
- ),
- },
- '/tasks'
- )
- },
-})
-
const TasksConfigAgentInstructionsCreateSchema = () => {
const TasksConfigAgentInstructionsCreateBody = orvalSchemas.TasksConfigAgentInstructionsCreateBody()
return TasksConfigAgentInstructionsCreateBody
@@ -1076,17 +690,6 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'channel-instructions-update': channelInstructionsUpdate,
'channel-list': channelList,
'channel-retrieve': channelRetrieve,
- 'loop-channel-instructions-retrieve': loopChannelInstructionsRetrieve,
- 'loop-channel-instructions-update': loopChannelInstructionsUpdate,
- 'loops-create-prepare': loopsCreatePrepare,
- 'loops-create-execute': loopsCreateExecute,
- 'loops-destroy': loopsDestroy,
- 'loops-list': loopsList,
- 'loops-partial-update': loopsPartialUpdate,
- 'loops-preview-create': loopsPreviewCreate,
- 'loops-retrieve': loopsRetrieve,
- 'loops-run-create': loopsRunCreate,
- 'loops-runs-retrieve': loopsRunsRetrieve,
'tasks-config-agent-instructions-create': tasksConfigAgentInstructionsCreate,
'tasks-config-create': tasksConfigCreate,
'tasks-config-list': tasksConfigList,
diff --git a/services/mcp/src/tools/index.ts b/services/mcp/src/tools/index.ts
index 8b6a2baf062c..e5187058ea31 100644
--- a/services/mcp/src/tools/index.ts
+++ b/services/mcp/src/tools/index.ts
@@ -20,7 +20,6 @@ import { GENERATED_TOOL_MAP } from './generated'
import queryInsight from './insights/query'
// Links (utility — builds canonical app URLs from the frontend's route table)
import generateAppUrl from './links/generate-app-url'
-import loopsReview from './loops/loopsReview'
import { mergeToolFactories } from './mergeToolFactories'
// Notebooks (edit + cell tools are hand-written — generated CRUD lives in generated/notebooks.ts)
import notebookAddCell from './notebooks/addCell'
@@ -119,7 +118,6 @@ export const TOOL_MAP: Record<string, () => ToolBase<ZodObjectAny>> = {
// Debug
'debug-mcp-ui-apps': debugMcpUiApps,
- 'loops-review': loopsReview,
// Feedback
'agent-feedback': submitFeedback,
diff --git a/services/mcp/src/tools/loops/loopsReview.ts b/services/mcp/src/tools/loops/loopsReview.ts
deleted file mode 100644
index 8ef40c57ccda..000000000000
--- a/services/mcp/src/tools/loops/loopsReview.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import type { z } from 'zod'
-
-import { LoopsCreateBody } from '@/generated/tasks/api'
-import { withUiApp } from '@/resources/ui-apps'
-import type { Context, ToolBase } from '@/tools/types'
-
-// The review card's input is exactly the `loops-create` body, so the card's "Create loop"
-// button can forward the reviewed config unchanged. This tool doesn't write anything — it
-// echoes the config back so the UI app can render it for confirmation.
-const schema = LoopsCreateBody()
-
-type Params = z.infer<typeof schema>
-
-export const loopsReviewHandler: ToolBase<typeof schema, Params>['handler'] = async (
- _context: Context,
- params: Params
-) => params
-
-export default (): ToolBase<typeof schema, Params> =>
- withUiApp('loops-review', {
- name: 'loops-review',
- schema,
- handler: loopsReviewHandler,
- })
diff --git a/services/mcp/src/ui-apps/apps/loops-review-confirm.ts b/services/mcp/src/ui-apps/apps/loops-review-confirm.ts
deleted file mode 100644
index efc2d82eb810..000000000000
--- a/services/mcp/src/ui-apps/apps/loops-review-confirm.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import type { LoopReviewData } from 'products/tasks/mcp/apps'
-
-import { APP_DATA_META_KEY } from '../types'
-
-// `loops-create` is a confirmed action (prepare/execute) and the card's click is the human
-// confirmation step, so only fields the card renders may travel: anything else in `data`
-// would be created without ever being reviewed. Keying off `LoopReviewData` makes the
-// compiler reject a card field that isn't listed here.
-const REVIEWED_FIELDS: Record<Exclude<keyof LoopReviewData, '_posthogUrl'>, true> = {
- name: true,
- description: true,
- instructions: true,
- runtime_adapter: true,
- model: true,
- reasoning_effort: true,
- visibility: true,
- repositories: true,
- triggers: true,
- enabled: true,
- overlap_policy: true,
- behaviors: true,
- connectors: true,
- sandbox_environment: true,
- notifications: true,
- context_target: true,
-}
-
-export function buildReviewedConfig(data: LoopReviewData): Record<string, unknown> {
- const reviewed: Record<string, unknown> = {}
- for (const key of Object.keys(REVIEWED_FIELDS)) {
- reviewed[key] = data[key as keyof LoopReviewData]
- }
- return reviewed
-}
-
-// `-prepare` tools have no UI resource, so the server mirrors the result onto the app-only
-// `_meta` channel; `structuredContent` stays as a fallback for hosts that forward it.
-export function extractConfirmationHash(prepared: {
- _meta?: Record<string, unknown>
- structuredContent?: unknown
-}): string | undefined {
- const preparedData = (prepared._meta?.[APP_DATA_META_KEY] ?? prepared.structuredContent) as
- | { confirmation_hash?: unknown }
- | undefined
- const hash = preparedData?.confirmation_hash
- return typeof hash === 'string' && hash.length > 0 ? hash : undefined
-}
diff --git a/services/mcp/src/ui-apps/apps/loops-review.tsx b/services/mcp/src/ui-apps/apps/loops-review.tsx
deleted file mode 100644
index f2fd4fb8a16e..000000000000
--- a/services/mcp/src/ui-apps/apps/loops-review.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-import '../styles/tailwind.css'
-
-import type { App } from '@modelcontextprotocol/ext-apps'
-import { useCallback, useState } from 'react'
-import { createRoot } from 'react-dom/client'
-
-import { LoopReviewView, type LoopReviewData, type LoopReviewState } from 'products/tasks/mcp/apps'
-
-import { AppWrapper } from '../components/AppWrapper'
-import { buildReviewedConfig, extractConfirmationHash } from './loops-review-confirm'
-
-function LoopReviewApp(): JSX.Element {
- return (
- <AppWrapper<LoopReviewData> appName="PostHog Loop Review">
- {({ data, app }) => <LoopReviewContent data={data!} app={app} />}
- </AppWrapper>
- )
-}
-
-function LoopReviewContent({ data, app }: { data: LoopReviewData; app: App | null }): JSX.Element {
- const [state, setState] = useState<LoopReviewState>({ loading: false, error: null, createdName: null })
-
- const handleCreate = useCallback(async (): Promise<void> => {
- if (!app) {
- setState({
- loading: false,
- error: 'Creating loops is not available in this host. Ask the agent to create it in chat.',
- createdName: null,
- })
- return
- }
- setState({ loading: true, error: null, createdName: null })
- try {
- const prepared = await app.callServerTool({
- name: 'loops-create-prepare',
- arguments: buildReviewedConfig(data),
- })
- if (prepared.isError) {
- const message =
- prepared.content?.find((c): c is { type: 'text'; text: string } => c.type === 'text')?.text ??
- 'Failed to create the loop.'
- setState({ loading: false, error: message, createdName: null })
- return
- }
- const confirmationHash = extractConfirmationHash(prepared)
- if (!confirmationHash) {
- setState({
- loading: false,
- error: 'Failed to create the loop: the server did not return a confirmation hash.',
- createdName: null,
- })
- return
- }
- const result = await app.callServerTool({
- name: 'loops-create-execute',
- arguments: { confirmation_hash: confirmationHash, confirmation: 'confirm' },
- })
- if (result.isError) {
- const message =
- result.content?.find((c): c is { type: 'text'; text: string } => c.type === 'text')?.text ??
- 'Failed to create the loop.'
- setState({ loading: false, error: message, createdName: null })
- return
- }
- setState({ loading: false, error: null, createdName: data.name?.trim() || 'Your loop' })
- } catch (err) {
- const message = err instanceof Error ? err.message : String(err)
- setState({ loading: false, error: message, createdName: null })
- }
- }, [app, data])
-
- return <LoopReviewView data={data} onCreate={handleCreate} state={state} />
-}
-
-const container = document.getElementById('root')
-if (container) {
- createRoot(container).render(<LoopReviewApp />)
-}
diff --git a/services/mcp/tests/hono/tool-executor.test.ts b/services/mcp/tests/hono/tool-executor.test.ts
index ee0617941d8e..a735c55c0267 100644
--- a/services/mcp/tests/hono/tool-executor.test.ts
+++ b/services/mcp/tests/hono/tool-executor.test.ts
@@ -62,6 +62,17 @@ describe('ToolExecutor', () => {
expect(result.content[0].text).toContain('not found')
})
+ it('returns replacement guidance for a direct call to a removed tool', async () => {
+ const result = (await executor.handleToolCall(
+ { name: 'loops-list', arguments: {} },
+ makeToolExecutorState([])
+ )) as any
+ expect(result.isError).toBe(true)
+ expect(result.content[0].text).toContain('loops-list')
+ expect(result.content[0].text).toContain('workflows-list')
+ expect(result.content[0].text).toContain('building-loops')
+ })
+
it('rejects tools not in the per-request filtered set', async () => {
const entries = catalog.getPreBuiltEntries()
const tool = entries[0]!
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-create-execute.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-create-execute.json
deleted file mode 100644
index f9e863b2ae53..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-create-execute.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "additionalProperties": false,
- "properties": {
- "confirmation": {
- "description": "The literal string \"confirm\", typed by the user in chat. Required to proceed.",
- "type": "string"
- },
- "confirmation_hash": {
- "description": "The confirmation_hash returned by the matching -prepare tool. Pass it back verbatim.",
- "type": "string"
- }
- },
- "required": ["confirmation_hash", "confirmation"],
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-create-prepare.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-create-prepare.json
deleted file mode 100644
index e7253c5bbdce..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-create-prepare.json
+++ /dev/null
@@ -1,333 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "description": "Request body for creating or updating a loop. Field required/default semantics match\nthe `Loop` model; partial updates only touch keys present in the payload.",
- "properties": {
- "behaviors": {
- "description": "PR / CI-follow-up behavior configuration.",
- "properties": {
- "create_prs": {
- "default": false,
- "description": "Whether the agent may push branches and open PRs. False makes this a report-only loop.",
- "type": "boolean"
- },
- "fix_review_comments": {
- "default": false,
- "description": "Whether to automatically address review comments on loop-created PRs.",
- "type": "boolean"
- },
- "max_fix_iterations": {
- "default": 3,
- "description": "Ceiling on automatic CI/review-comment fix iterations, capped at 10.",
- "maximum": 10,
- "minimum": 0,
- "type": "number"
- },
- "watch_ci": {
- "default": false,
- "description": "Whether to watch CI on loop-created PRs and report status.",
- "type": "boolean"
- }
- },
- "type": "object"
- },
- "connectors": {
- "description": "MCP connector configuration for this loop's runs.",
- "properties": {
- "mcp_installation_ids": {
- "description": "MCP Store installation ids (Slack, Linear, etc.) available to this loop's runs.",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "posthog_mcp_scopes": {
- "default": "read_only",
- "description": "Scope of the PostHog MCP access injected into this loop's runs.\n\n* `read_only` - read_only\n* `full` - full",
- "enum": ["read_only", "full"],
- "type": "string"
- }
- },
- "type": "object"
- },
- "context_target": {
- "anyOf": [
- {
- "properties": {
- "channel_id": {
- "description": "Id of the channel (context) this loop is attached to.",
- "type": "string"
- },
- "name": {
- "description": "Display name of the context, shown in the loop's publish prompt.",
- "maxLength": 128,
- "type": "string"
- },
- "outputs": {
- "description": "What the loop maintains in this context each run.",
- "properties": {
- "canvas_id": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "Id of a canvas in this context the loop keeps up to date each run, or null to maintain none."
- },
- "post_to_feed": {
- "default": false,
- "description": "Whether each run is filed into the context's feed as a card (sets the run's channel).",
- "type": "boolean"
- },
- "update_context": {
- "default": false,
- "description": "Whether each run reads and republishes the context's context.md to reflect the latest state.",
- "type": "boolean"
- }
- },
- "type": "object"
- }
- },
- "required": ["channel_id", "name"],
- "type": "object"
- },
- {
- "type": "null"
- }
- ],
- "description": "Context (channel) this loop is attached to, or null to detach. Drives feed placement and the context.md / canvas it keeps up to date."
- },
- "description": {
- "default": "",
- "description": "Free-form description of what this loop does.",
- "type": "string"
- },
- "enabled": {
- "default": true,
- "description": "Whether the loop's triggers are active. Pausing disables all triggers.",
- "type": "boolean"
- },
- "instructions": {
- "description": "The prompt delivered to the agent on every run.",
- "type": "string"
- },
- "model": {
- "default": "",
- "description": "LLM model identifier, validated against `runtime_adapter`'s catalog. Leave blank to let PostHog pick a sensible default at run time.",
- "type": "string"
- },
- "name": {
- "description": "Display name for the loop.",
- "maxLength": 400,
- "type": "string"
- },
- "notifications": {
- "description": "Per-channel notification configuration.",
- "properties": {
- "email": {
- "description": "Email notification settings.",
- "properties": {
- "enabled": {
- "default": false,
- "description": "Whether this channel is active.",
- "type": "boolean"
- },
- "events": {
- "description": "Event kinds this channel notifies on. One or more of: run_completed, run_failed, pr_created, pr_merged, pr_closed, needs_attention.",
- "items": {
- "description": "* `run_completed` - run_completed\n* `run_failed` - run_failed\n* `pr_created` - pr_created\n* `pr_merged` - pr_merged\n* `pr_closed` - pr_closed\n* `needs_attention` - needs_attention",
- "enum": [
- "run_completed",
- "run_failed",
- "pr_created",
- "pr_merged",
- "pr_closed",
- "needs_attention"
- ],
- "type": "string"
- },
- "type": "array"
- },
- "params": {
- "additionalProperties": {},
- "description": "Channel-specific parameters, e.g. Slack's `integration_id` and `channel`.",
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- }
- },
- "type": "object"
- },
- "push": {
- "description": "Push notification settings.",
- "properties": {
- "enabled": {
- "default": false,
- "description": "Whether this channel is active.",
- "type": "boolean"
- },
- "events": {
- "description": "Event kinds this channel notifies on. One or more of: run_completed, run_failed, pr_created, pr_merged, pr_closed, needs_attention.",
- "items": {
- "description": "* `run_completed` - run_completed\n* `run_failed` - run_failed\n* `pr_created` - pr_created\n* `pr_merged` - pr_merged\n* `pr_closed` - pr_closed\n* `needs_attention` - needs_attention",
- "enum": [
- "run_completed",
- "run_failed",
- "pr_created",
- "pr_merged",
- "pr_closed",
- "needs_attention"
- ],
- "type": "string"
- },
- "type": "array"
- },
- "params": {
- "additionalProperties": {},
- "description": "Channel-specific parameters, e.g. Slack's `integration_id` and `channel`.",
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- }
- },
- "type": "object"
- },
- "slack": {
- "description": "Slack notification settings.",
- "properties": {
- "enabled": {
- "default": false,
- "description": "Whether this channel is active.",
- "type": "boolean"
- },
- "events": {
- "description": "Event kinds this channel notifies on. One or more of: run_completed, run_failed, pr_created, pr_merged, pr_closed, needs_attention.",
- "items": {
- "description": "* `run_completed` - run_completed\n* `run_failed` - run_failed\n* `pr_created` - pr_created\n* `pr_merged` - pr_merged\n* `pr_closed` - pr_closed\n* `needs_attention` - needs_attention",
- "enum": [
- "run_completed",
- "run_failed",
- "pr_created",
- "pr_merged",
- "pr_closed",
- "needs_attention"
- ],
- "type": "string"
- },
- "type": "array"
- },
- "params": {
- "additionalProperties": {},
- "description": "Channel-specific parameters, e.g. Slack's `integration_id` and `channel`.",
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- }
- },
- "type": "object"
- }
- },
- "type": "object"
- },
- "overlap_policy": {
- "default": "skip",
- "description": "What happens when a trigger fires while a run is already active: 'skip', 'allow', or 'cancel_previous'.\n\n* `skip` - skip\n* `allow` - allow\n* `cancel_previous` - cancel_previous",
- "enum": ["skip", "allow", "cancel_previous"],
- "type": "string"
- },
- "reasoning_effort": {
- "anyOf": [
- {
- "description": "* `low` - low\n* `medium` - medium\n* `high` - high\n* `xhigh` - xhigh\n* `max` - max\n* `ultracode` - ultracode",
- "enum": ["low", "medium", "high", "xhigh", "max", "ultracode"],
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "Reasoning effort, validated against `runtime_adapter`/`model`'s supported set.\n\n* `low` - low\n* `medium` - medium\n* `high` - high\n* `xhigh` - xhigh\n* `max` - max\n* `ultracode` - ultracode"
- },
- "repositories": {
- "description": "Repositories this loop operates on, ordered. Capped at 1 until multi-repo execution ships. May be empty for report-only loops.",
- "items": {
- "properties": {
- "full_name": {
- "description": "Repository in `organization/repo` format, e.g. `posthog/posthog`.",
- "maxLength": 255,
- "type": "string"
- },
- "github_integration_id": {
- "description": "GitHub integration id this repository is accessed through.",
- "type": "number"
- }
- },
- "required": ["github_integration_id", "full_name"],
- "type": "object"
- },
- "maxItems": 1,
- "type": "array"
- },
- "runtime_adapter": {
- "description": "Runtime adapter: 'claude' or 'codex'.\n\n* `claude` - claude\n* `codex` - codex",
- "enum": ["claude", "codex"],
- "type": "string"
- },
- "sandbox_environment": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "Sandbox environment carrying encrypted env vars and the network allowlist into every run."
- },
- "take_ownership": {
- "default": false,
- "description": "On a team loop, claim ownership as part of this update so you can edit identity-bearing config (instructions, model, triggers, ...) that only the owner may change. Ignored on personal loops and on create.",
- "type": "boolean"
- },
- "triggers": {
- "description": "Full desired trigger list, id-stable: entries with a matching `id` are updated in place, entries without one are created, and existing triggers absent from this list are deleted. Omit the field entirely to leave triggers untouched. At most 25 triggers per loop.",
- "items": {
- "properties": {
- "config": {
- "description": "Trigger configuration, shape validated per `type`: schedule takes `{cron_expression, timezone}` or `{run_at}` for a one-time run; github takes `{github_integration_id, repository, events, filters}` where `events` is one or more of `issues`, `issue_comment`, `pull_request`, `push` (`event.action` shorthand like `issues.opened` is folded into an `actions` filter, one event per trigger) and `filters` takes `{actions, branches, labels, payload}`. Use `actions` for the event action; `payload` is for anything else in the webhook body, as a list of `{path, equals}` conditions where `path` is a dot-path of object keys and `equals` is a string or list of strings, e.g. `[{\"path\": \"requested_team.slug\", \"equals\": \"team-security\"}]` to run only when that team is asked to review. All filters must match. API triggers take no config."
- },
- "enabled": {
- "default": true,
- "description": "Whether this trigger is active. Disabling pauses only this trigger.",
- "type": "boolean"
- },
- "id": {
- "description": "Existing trigger id to update in place. Omit to create a new trigger.",
- "type": "string"
- },
- "type": {
- "description": "Trigger type: `schedule` (cron or one-time), `github` (repo webhook events), or `api` (POST to `trigger/`).\n\n* `schedule` - schedule\n* `github` - github\n* `api` - api",
- "enum": ["schedule", "github", "api"],
- "type": "string"
- }
- },
- "required": ["type"],
- "type": "object"
- },
- "type": "array"
- },
- "visibility": {
- "default": "personal",
- "description": "`personal` (owner-only) or `team` (visible and fireable by any team member).\n\n* `personal` - personal\n* `team` - team",
- "enum": ["personal", "team"],
- "type": "string"
- }
- },
- "required": ["name", "instructions", "runtime_adapter"],
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-destroy.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-destroy.json
deleted file mode 100644
index f9bfd8020ef3..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-destroy.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "id": {
- "type": "string"
- }
- },
- "required": ["id"],
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-list.json
deleted file mode 100644
index 8331b796ac73..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-list.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "limit": {
- "description": "Number of results to return per page.",
- "type": "number"
- },
- "offset": {
- "description": "The initial index from which to return the results.",
- "type": "number"
- }
- },
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-partial-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-partial-update.json
deleted file mode 100644
index 50a06f6824c5..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-partial-update.json
+++ /dev/null
@@ -1,329 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "behaviors": {
- "description": "PR / CI-follow-up behavior configuration.",
- "properties": {
- "create_prs": {
- "default": false,
- "description": "Whether the agent may push branches and open PRs. False makes this a report-only loop.",
- "type": "boolean"
- },
- "fix_review_comments": {
- "default": false,
- "description": "Whether to automatically address review comments on loop-created PRs.",
- "type": "boolean"
- },
- "max_fix_iterations": {
- "default": 3,
- "description": "Ceiling on automatic CI/review-comment fix iterations, capped at 10.",
- "maximum": 10,
- "minimum": 0,
- "type": "number"
- },
- "watch_ci": {
- "default": false,
- "description": "Whether to watch CI on loop-created PRs and report status.",
- "type": "boolean"
- }
- },
- "type": "object"
- },
- "connectors": {
- "description": "MCP connector configuration for this loop's runs.",
- "properties": {
- "mcp_installation_ids": {
- "description": "MCP Store installation ids (Slack, Linear, etc.) available to this loop's runs.",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "posthog_mcp_scopes": {
- "default": "read_only",
- "description": "Scope of the PostHog MCP access injected into this loop's runs.\n\n* `read_only` - read_only\n* `full` - full",
- "enum": ["read_only", "full"],
- "type": "string"
- }
- },
- "type": "object"
- },
- "context_target": {
- "anyOf": [
- {
- "properties": {
- "channel_id": {
- "description": "Id of the channel (context) this loop is attached to.",
- "type": "string"
- },
- "name": {
- "description": "Display name of the context, shown in the loop's publish prompt.",
- "maxLength": 128,
- "type": "string"
- },
- "outputs": {
- "description": "What the loop maintains in this context each run.",
- "properties": {
- "canvas_id": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "Id of a canvas in this context the loop keeps up to date each run, or null to maintain none."
- },
- "post_to_feed": {
- "default": false,
- "description": "Whether each run is filed into the context's feed as a card (sets the run's channel).",
- "type": "boolean"
- },
- "update_context": {
- "default": false,
- "description": "Whether each run reads and republishes the context's context.md to reflect the latest state.",
- "type": "boolean"
- }
- },
- "type": "object"
- }
- },
- "required": ["channel_id", "name"],
- "type": "object"
- },
- {
- "type": "null"
- }
- ],
- "description": "Context (channel) this loop is attached to, or null to detach. Drives feed placement and the context.md / canvas it keeps up to date."
- },
- "description": {
- "description": "Free-form description of what this loop does.",
- "type": "string"
- },
- "enabled": {
- "description": "Whether the loop's triggers are active. Pausing disables all triggers.",
- "type": "boolean"
- },
- "id": {
- "type": "string"
- },
- "instructions": {
- "description": "The prompt delivered to the agent on every run.",
- "type": "string"
- },
- "model": {
- "description": "LLM model identifier, validated against `runtime_adapter`'s catalog. Leave blank to let PostHog pick a sensible default at run time.",
- "type": "string"
- },
- "name": {
- "description": "Display name for the loop.",
- "maxLength": 400,
- "type": "string"
- },
- "notifications": {
- "description": "Per-channel notification configuration.",
- "properties": {
- "email": {
- "description": "Email notification settings.",
- "properties": {
- "enabled": {
- "default": false,
- "description": "Whether this channel is active.",
- "type": "boolean"
- },
- "events": {
- "description": "Event kinds this channel notifies on. One or more of: run_completed, run_failed, pr_created, pr_merged, pr_closed, needs_attention.",
- "items": {
- "description": "* `run_completed` - run_completed\n* `run_failed` - run_failed\n* `pr_created` - pr_created\n* `pr_merged` - pr_merged\n* `pr_closed` - pr_closed\n* `needs_attention` - needs_attention",
- "enum": [
- "run_completed",
- "run_failed",
- "pr_created",
- "pr_merged",
- "pr_closed",
- "needs_attention"
- ],
- "type": "string"
- },
- "type": "array"
- },
- "params": {
- "additionalProperties": {},
- "description": "Channel-specific parameters, e.g. Slack's `integration_id` and `channel`.",
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- }
- },
- "type": "object"
- },
- "push": {
- "description": "Push notification settings.",
- "properties": {
- "enabled": {
- "default": false,
- "description": "Whether this channel is active.",
- "type": "boolean"
- },
- "events": {
- "description": "Event kinds this channel notifies on. One or more of: run_completed, run_failed, pr_created, pr_merged, pr_closed, needs_attention.",
- "items": {
- "description": "* `run_completed` - run_completed\n* `run_failed` - run_failed\n* `pr_created` - pr_created\n* `pr_merged` - pr_merged\n* `pr_closed` - pr_closed\n* `needs_attention` - needs_attention",
- "enum": [
- "run_completed",
- "run_failed",
- "pr_created",
- "pr_merged",
- "pr_closed",
- "needs_attention"
- ],
- "type": "string"
- },
- "type": "array"
- },
- "params": {
- "additionalProperties": {},
- "description": "Channel-specific parameters, e.g. Slack's `integration_id` and `channel`.",
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- }
- },
- "type": "object"
- },
- "slack": {
- "description": "Slack notification settings.",
- "properties": {
- "enabled": {
- "default": false,
- "description": "Whether this channel is active.",
- "type": "boolean"
- },
- "events": {
- "description": "Event kinds this channel notifies on. One or more of: run_completed, run_failed, pr_created, pr_merged, pr_closed, needs_attention.",
- "items": {
- "description": "* `run_completed` - run_completed\n* `run_failed` - run_failed\n* `pr_created` - pr_created\n* `pr_merged` - pr_merged\n* `pr_closed` - pr_closed\n* `needs_attention` - needs_attention",
- "enum": [
- "run_completed",
- "run_failed",
- "pr_created",
- "pr_merged",
- "pr_closed",
- "needs_attention"
- ],
- "type": "string"
- },
- "type": "array"
- },
- "params": {
- "additionalProperties": {},
- "description": "Channel-specific parameters, e.g. Slack's `integration_id` and `channel`.",
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- }
- },
- "type": "object"
- }
- },
- "type": "object"
- },
- "overlap_policy": {
- "description": "What happens when a trigger fires while a run is already active: 'skip', 'allow', or 'cancel_previous'.\n\n* `skip` - skip\n* `allow` - allow\n* `cancel_previous` - cancel_previous",
- "enum": ["skip", "allow", "cancel_previous"],
- "type": "string"
- },
- "reasoning_effort": {
- "anyOf": [
- {
- "description": "* `low` - low\n* `medium` - medium\n* `high` - high\n* `xhigh` - xhigh\n* `max` - max\n* `ultracode` - ultracode",
- "enum": ["low", "medium", "high", "xhigh", "max", "ultracode"],
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "Reasoning effort, validated against `runtime_adapter`/`model`'s supported set.\n\n* `low` - low\n* `medium` - medium\n* `high` - high\n* `xhigh` - xhigh\n* `max` - max\n* `ultracode` - ultracode"
- },
- "repositories": {
- "description": "Repositories this loop operates on, ordered. Capped at 1 until multi-repo execution ships. May be empty for report-only loops.",
- "items": {
- "properties": {
- "full_name": {
- "description": "Repository in `organization/repo` format, e.g. `posthog/posthog`.",
- "maxLength": 255,
- "type": "string"
- },
- "github_integration_id": {
- "description": "GitHub integration id this repository is accessed through.",
- "type": "number"
- }
- },
- "required": ["github_integration_id", "full_name"],
- "type": "object"
- },
- "maxItems": 1,
- "type": "array"
- },
- "runtime_adapter": {
- "description": "Runtime adapter: 'claude' or 'codex'.\n\n* `claude` - claude\n* `codex` - codex",
- "enum": ["claude", "codex"],
- "type": "string"
- },
- "sandbox_environment": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "Sandbox environment carrying encrypted env vars and the network allowlist into every run."
- },
- "take_ownership": {
- "description": "On a team loop, claim ownership as part of this update so you can edit identity-bearing config (instructions, model, triggers, ...) that only the owner may change. Ignored on personal loops and on create.",
- "type": "boolean"
- },
- "triggers": {
- "description": "Full desired trigger list, id-stable: entries with a matching `id` are updated in place, entries without one are created, and existing triggers absent from this list are deleted. Omit the field entirely to leave triggers untouched. At most 25 triggers per loop.",
- "items": {
- "properties": {
- "config": {
- "description": "Trigger configuration, shape validated per `type`: schedule takes `{cron_expression, timezone}` or `{run_at}` for a one-time run; github takes `{github_integration_id, repository, events, filters}` where `events` is one or more of `issues`, `issue_comment`, `pull_request`, `push` (`event.action` shorthand like `issues.opened` is folded into an `actions` filter, one event per trigger) and `filters` takes `{actions, branches, labels, payload}`. Use `actions` for the event action; `payload` is for anything else in the webhook body, as a list of `{path, equals}` conditions where `path` is a dot-path of object keys and `equals` is a string or list of strings, e.g. `[{\"path\": \"requested_team.slug\", \"equals\": \"team-security\"}]` to run only when that team is asked to review. All filters must match. API triggers take no config."
- },
- "enabled": {
- "default": true,
- "description": "Whether this trigger is active. Disabling pauses only this trigger.",
- "type": "boolean"
- },
- "id": {
- "description": "Existing trigger id to update in place. Omit to create a new trigger.",
- "type": "string"
- },
- "type": {
- "description": "Trigger type: `schedule` (cron or one-time), `github` (repo webhook events), or `api` (POST to `trigger/`).\n\n* `schedule` - schedule\n* `github` - github\n* `api` - api",
- "enum": ["schedule", "github", "api"],
- "type": "string"
- }
- },
- "required": ["type"],
- "type": "object"
- },
- "type": "array"
- },
- "visibility": {
- "description": "`personal` (owner-only) or `team` (visible and fireable by any team member).\n\n* `personal` - personal\n* `team` - team",
- "enum": ["personal", "team"],
- "type": "string"
- }
- },
- "required": ["id"],
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-preview-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-preview-create.json
deleted file mode 100644
index 52c27d74cf7e..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-preview-create.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "id": {
- "type": "string"
- },
- "payload": {
- "description": "Sample trigger payload, e.g. a GitHub webhook body or an API trigger body, to render into context."
- },
- "trigger_type": {
- "default": "schedule",
- "description": "Trigger type to simulate. Defaults to a synthetic schedule fire.\n\n* `schedule` - schedule\n* `github` - github\n* `api` - api",
- "enum": ["schedule", "github", "api"],
- "type": "string"
- }
- },
- "required": ["id"],
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-retrieve.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-retrieve.json
deleted file mode 100644
index f9bfd8020ef3..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-retrieve.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "id": {
- "type": "string"
- }
- },
- "required": ["id"],
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-review.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-review.json
deleted file mode 100644
index e7253c5bbdce..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-review.json
+++ /dev/null
@@ -1,333 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "description": "Request body for creating or updating a loop. Field required/default semantics match\nthe `Loop` model; partial updates only touch keys present in the payload.",
- "properties": {
- "behaviors": {
- "description": "PR / CI-follow-up behavior configuration.",
- "properties": {
- "create_prs": {
- "default": false,
- "description": "Whether the agent may push branches and open PRs. False makes this a report-only loop.",
- "type": "boolean"
- },
- "fix_review_comments": {
- "default": false,
- "description": "Whether to automatically address review comments on loop-created PRs.",
- "type": "boolean"
- },
- "max_fix_iterations": {
- "default": 3,
- "description": "Ceiling on automatic CI/review-comment fix iterations, capped at 10.",
- "maximum": 10,
- "minimum": 0,
- "type": "number"
- },
- "watch_ci": {
- "default": false,
- "description": "Whether to watch CI on loop-created PRs and report status.",
- "type": "boolean"
- }
- },
- "type": "object"
- },
- "connectors": {
- "description": "MCP connector configuration for this loop's runs.",
- "properties": {
- "mcp_installation_ids": {
- "description": "MCP Store installation ids (Slack, Linear, etc.) available to this loop's runs.",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "posthog_mcp_scopes": {
- "default": "read_only",
- "description": "Scope of the PostHog MCP access injected into this loop's runs.\n\n* `read_only` - read_only\n* `full` - full",
- "enum": ["read_only", "full"],
- "type": "string"
- }
- },
- "type": "object"
- },
- "context_target": {
- "anyOf": [
- {
- "properties": {
- "channel_id": {
- "description": "Id of the channel (context) this loop is attached to.",
- "type": "string"
- },
- "name": {
- "description": "Display name of the context, shown in the loop's publish prompt.",
- "maxLength": 128,
- "type": "string"
- },
- "outputs": {
- "description": "What the loop maintains in this context each run.",
- "properties": {
- "canvas_id": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "Id of a canvas in this context the loop keeps up to date each run, or null to maintain none."
- },
- "post_to_feed": {
- "default": false,
- "description": "Whether each run is filed into the context's feed as a card (sets the run's channel).",
- "type": "boolean"
- },
- "update_context": {
- "default": false,
- "description": "Whether each run reads and republishes the context's context.md to reflect the latest state.",
- "type": "boolean"
- }
- },
- "type": "object"
- }
- },
- "required": ["channel_id", "name"],
- "type": "object"
- },
- {
- "type": "null"
- }
- ],
- "description": "Context (channel) this loop is attached to, or null to detach. Drives feed placement and the context.md / canvas it keeps up to date."
- },
- "description": {
- "default": "",
- "description": "Free-form description of what this loop does.",
- "type": "string"
- },
- "enabled": {
- "default": true,
- "description": "Whether the loop's triggers are active. Pausing disables all triggers.",
- "type": "boolean"
- },
- "instructions": {
- "description": "The prompt delivered to the agent on every run.",
- "type": "string"
- },
- "model": {
- "default": "",
- "description": "LLM model identifier, validated against `runtime_adapter`'s catalog. Leave blank to let PostHog pick a sensible default at run time.",
- "type": "string"
- },
- "name": {
- "description": "Display name for the loop.",
- "maxLength": 400,
- "type": "string"
- },
- "notifications": {
- "description": "Per-channel notification configuration.",
- "properties": {
- "email": {
- "description": "Email notification settings.",
- "properties": {
- "enabled": {
- "default": false,
- "description": "Whether this channel is active.",
- "type": "boolean"
- },
- "events": {
- "description": "Event kinds this channel notifies on. One or more of: run_completed, run_failed, pr_created, pr_merged, pr_closed, needs_attention.",
- "items": {
- "description": "* `run_completed` - run_completed\n* `run_failed` - run_failed\n* `pr_created` - pr_created\n* `pr_merged` - pr_merged\n* `pr_closed` - pr_closed\n* `needs_attention` - needs_attention",
- "enum": [
- "run_completed",
- "run_failed",
- "pr_created",
- "pr_merged",
- "pr_closed",
- "needs_attention"
- ],
- "type": "string"
- },
- "type": "array"
- },
- "params": {
- "additionalProperties": {},
- "description": "Channel-specific parameters, e.g. Slack's `integration_id` and `channel`.",
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- }
- },
- "type": "object"
- },
- "push": {
- "description": "Push notification settings.",
- "properties": {
- "enabled": {
- "default": false,
- "description": "Whether this channel is active.",
- "type": "boolean"
- },
- "events": {
- "description": "Event kinds this channel notifies on. One or more of: run_completed, run_failed, pr_created, pr_merged, pr_closed, needs_attention.",
- "items": {
- "description": "* `run_completed` - run_completed\n* `run_failed` - run_failed\n* `pr_created` - pr_created\n* `pr_merged` - pr_merged\n* `pr_closed` - pr_closed\n* `needs_attention` - needs_attention",
- "enum": [
- "run_completed",
- "run_failed",
- "pr_created",
- "pr_merged",
- "pr_closed",
- "needs_attention"
- ],
- "type": "string"
- },
- "type": "array"
- },
- "params": {
- "additionalProperties": {},
- "description": "Channel-specific parameters, e.g. Slack's `integration_id` and `channel`.",
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- }
- },
- "type": "object"
- },
- "slack": {
- "description": "Slack notification settings.",
- "properties": {
- "enabled": {
- "default": false,
- "description": "Whether this channel is active.",
- "type": "boolean"
- },
- "events": {
- "description": "Event kinds this channel notifies on. One or more of: run_completed, run_failed, pr_created, pr_merged, pr_closed, needs_attention.",
- "items": {
- "description": "* `run_completed` - run_completed\n* `run_failed` - run_failed\n* `pr_created` - pr_created\n* `pr_merged` - pr_merged\n* `pr_closed` - pr_closed\n* `needs_attention` - needs_attention",
- "enum": [
- "run_completed",
- "run_failed",
- "pr_created",
- "pr_merged",
- "pr_closed",
- "needs_attention"
- ],
- "type": "string"
- },
- "type": "array"
- },
- "params": {
- "additionalProperties": {},
- "description": "Channel-specific parameters, e.g. Slack's `integration_id` and `channel`.",
- "propertyNames": {
- "type": "string"
- },
- "type": "object"
- }
- },
- "type": "object"
- }
- },
- "type": "object"
- },
- "overlap_policy": {
- "default": "skip",
- "description": "What happens when a trigger fires while a run is already active: 'skip', 'allow', or 'cancel_previous'.\n\n* `skip` - skip\n* `allow` - allow\n* `cancel_previous` - cancel_previous",
- "enum": ["skip", "allow", "cancel_previous"],
- "type": "string"
- },
- "reasoning_effort": {
- "anyOf": [
- {
- "description": "* `low` - low\n* `medium` - medium\n* `high` - high\n* `xhigh` - xhigh\n* `max` - max\n* `ultracode` - ultracode",
- "enum": ["low", "medium", "high", "xhigh", "max", "ultracode"],
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "Reasoning effort, validated against `runtime_adapter`/`model`'s supported set.\n\n* `low` - low\n* `medium` - medium\n* `high` - high\n* `xhigh` - xhigh\n* `max` - max\n* `ultracode` - ultracode"
- },
- "repositories": {
- "description": "Repositories this loop operates on, ordered. Capped at 1 until multi-repo execution ships. May be empty for report-only loops.",
- "items": {
- "properties": {
- "full_name": {
- "description": "Repository in `organization/repo` format, e.g. `posthog/posthog`.",
- "maxLength": 255,
- "type": "string"
- },
- "github_integration_id": {
- "description": "GitHub integration id this repository is accessed through.",
- "type": "number"
- }
- },
- "required": ["github_integration_id", "full_name"],
- "type": "object"
- },
- "maxItems": 1,
- "type": "array"
- },
- "runtime_adapter": {
- "description": "Runtime adapter: 'claude' or 'codex'.\n\n* `claude` - claude\n* `codex` - codex",
- "enum": ["claude", "codex"],
- "type": "string"
- },
- "sandbox_environment": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "description": "Sandbox environment carrying encrypted env vars and the network allowlist into every run."
- },
- "take_ownership": {
- "default": false,
- "description": "On a team loop, claim ownership as part of this update so you can edit identity-bearing config (instructions, model, triggers, ...) that only the owner may change. Ignored on personal loops and on create.",
- "type": "boolean"
- },
- "triggers": {
- "description": "Full desired trigger list, id-stable: entries with a matching `id` are updated in place, entries without one are created, and existing triggers absent from this list are deleted. Omit the field entirely to leave triggers untouched. At most 25 triggers per loop.",
- "items": {
- "properties": {
- "config": {
- "description": "Trigger configuration, shape validated per `type`: schedule takes `{cron_expression, timezone}` or `{run_at}` for a one-time run; github takes `{github_integration_id, repository, events, filters}` where `events` is one or more of `issues`, `issue_comment`, `pull_request`, `push` (`event.action` shorthand like `issues.opened` is folded into an `actions` filter, one event per trigger) and `filters` takes `{actions, branches, labels, payload}`. Use `actions` for the event action; `payload` is for anything else in the webhook body, as a list of `{path, equals}` conditions where `path` is a dot-path of object keys and `equals` is a string or list of strings, e.g. `[{\"path\": \"requested_team.slug\", \"equals\": \"team-security\"}]` to run only when that team is asked to review. All filters must match. API triggers take no config."
- },
- "enabled": {
- "default": true,
- "description": "Whether this trigger is active. Disabling pauses only this trigger.",
- "type": "boolean"
- },
- "id": {
- "description": "Existing trigger id to update in place. Omit to create a new trigger.",
- "type": "string"
- },
- "type": {
- "description": "Trigger type: `schedule` (cron or one-time), `github` (repo webhook events), or `api` (POST to `trigger/`).\n\n* `schedule` - schedule\n* `github` - github\n* `api` - api",
- "enum": ["schedule", "github", "api"],
- "type": "string"
- }
- },
- "required": ["type"],
- "type": "object"
- },
- "type": "array"
- },
- "visibility": {
- "default": "personal",
- "description": "`personal` (owner-only) or `team` (visible and fireable by any team member).\n\n* `personal` - personal\n* `team` - team",
- "enum": ["personal", "team"],
- "type": "string"
- }
- },
- "required": ["name", "instructions", "runtime_adapter"],
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-run-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-run-create.json
deleted file mode 100644
index f9bfd8020ef3..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-run-create.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "id": {
- "type": "string"
- }
- },
- "required": ["id"],
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-runs-retrieve.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-runs-retrieve.json
deleted file mode 100644
index 3defa07014a6..000000000000
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/loops-runs-retrieve.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "$schema": "https://json-schema.org/draft/2020-12/schema",
- "properties": {
- "cursor": {
- "description": "Opaque pagination cursor from a previous response's `next_cursor`.",
- "minLength": 1,
- "type": "string"
- },
- "id": {
- "type": "string"
- },
- "limit": {
- "default": 50,
- "description": "Max results per page (default 50, max 100).",
- "maximum": 100,
- "minimum": 1,
- "type": "number"
- },
- "status": {
- "description": "Only return runs with this status. Use failed to read errors even when canvas state is unavailable.\n\n* `not_started` - Not Started\n* `queued` - Queued\n* `in_progress` - In Progress\n* `completed` - Completed\n* `failed` - Failed\n* `cancelled` - Cancelled",
- "enum": ["not_started", "queued", "in_progress", "completed", "failed", "cancelled"],
- "type": "string"
- }
- },
- "required": ["id"],
- "type": "object"
-}
diff --git a/services/mcp/tests/unit/context-wiki-generated.test.ts b/services/mcp/tests/unit/context-wiki-generated.test.ts
index f5dce896c6b3..2114dd7c358e 100644
--- a/services/mcp/tests/unit/context-wiki-generated.test.ts
+++ b/services/mcp/tests/unit/context-wiki-generated.test.ts
@@ -35,7 +35,7 @@ function createMockContext(): Context {
}
describe('generated context read tools', () => {
- it.each(['context-wiki-page-retrieve', 'loop-context-wiki-page-retrieve', 'task-context-wiki-page-retrieve'])(
+ it.each(['context-wiki-page-retrieve', 'task-context-wiki-page-retrieve'])(
'%s forwards bounded reads and the revision',
async (name) => {
const context = createMockContext()
diff --git a/services/mcp/tests/unit/exec.test.ts b/services/mcp/tests/unit/exec.test.ts
index 27b276560fdd..72699d04f889 100644
--- a/services/mcp/tests/unit/exec.test.ts
+++ b/services/mcp/tests/unit/exec.test.ts
@@ -1976,6 +1976,13 @@ describe('exec tool', () => {
)
})
+ it('explains that a workflow test run does not replace a real loop run', async () => {
+ const exec = createExec()
+ await expect(exec.handler(mockContext, { command: 'call loops-run-create {}' })).rejects.toThrow(
+ /workflows-test-run[\s\S]*does not start a real task run[\s\S]*Run now/
+ )
+ })
+
it('lists available query-* tools when query-run is called', async () => {
const queryTrends = makeMockTool({ name: 'query-trends', description: 'Run a trends query' })
const exec = createExec([queryTrends])
diff --git a/services/mcp/tests/unit/loops-review-confirm.test.ts b/services/mcp/tests/unit/loops-review-confirm.test.ts
deleted file mode 100644
index ed60e520c76e..000000000000
--- a/services/mcp/tests/unit/loops-review-confirm.test.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import { describe, expect, it } from 'vitest'
-
-import { buildReviewedConfig, extractConfirmationHash } from '@/ui-apps/apps/loops-review-confirm'
-import { APP_DATA_META_KEY } from '@/ui-apps/types'
-
-import type { LoopReviewData } from 'products/tasks/mcp/apps'
-
-describe('loops-review confirm helpers', () => {
- describe('buildReviewedConfig', () => {
- it('forwards reviewed fields and drops anything else', () => {
- const data = {
- name: 'Open PR summary',
- instructions: 'Summarize open PRs',
- visibility: 'team',
- overlap_policy: 'allow',
- _posthogUrl: 'https://us.posthog.com',
- injected_field: 'must never travel',
- } as unknown as LoopReviewData
-
- const config = buildReviewedConfig(data)
-
- expect(config).toMatchObject({
- name: 'Open PR summary',
- instructions: 'Summarize open PRs',
- visibility: 'team',
- overlap_policy: 'allow',
- })
- expect(config).not.toHaveProperty('_posthogUrl')
- expect(config).not.toHaveProperty('injected_field')
- })
- })
-
- describe('extractConfirmationHash', () => {
- it.each<[string, { _meta?: Record<string, unknown>; structuredContent?: unknown }, string | undefined]>([
- [
- 'reads the hash from the _meta app channel',
- { _meta: { [APP_DATA_META_KEY]: { confirmation_hash: 'hash-from-meta' } } },
- 'hash-from-meta',
- ],
- [
- 'prefers _meta over structuredContent',
- {
- _meta: { [APP_DATA_META_KEY]: { confirmation_hash: 'hash-from-meta' } },
- structuredContent: { confirmation_hash: 'hash-from-structured' },
- },
- 'hash-from-meta',
- ],
- [
- 'falls back to structuredContent',
- { structuredContent: { confirmation_hash: 'hash-from-structured' } },
- 'hash-from-structured',
- ],
- ['returns undefined when neither channel has a hash', { _meta: {} }, undefined],
- ['returns undefined for a non-string hash', { structuredContent: { confirmation_hash: 42 } }, undefined],
- ])('%s', (_label, prepared, expected) => {
- expect(extractConfirmationHash(prepared)).toBe(expected)
- })
- })
-})
diff --git a/services/mcp/tests/unit/tool-filtering.test.ts b/services/mcp/tests/unit/tool-filtering.test.ts
index 0d7cfabcc642..75a3b0c7d497 100644
--- a/services/mcp/tests/unit/tool-filtering.test.ts
+++ b/services/mcp/tests/unit/tool-filtering.test.ts
@@ -1121,8 +1121,6 @@ describe('Tool Filtering - Feature Flags', () => {
'engineering-analytics',
'web-analytics-path-cleaning-suggestions',
'stamphog',
- 'loops',
- 'loops-hog-flows',
'review-hog',
'warehouse-person-properties',
'organization-billing-api',
@@ -1141,20 +1139,10 @@ describe('Tool Filtering - Feature Flags', () => {
])
)
expect(flags).toContain('ai-observability-offline-evaluations')
- expect(flags).toHaveLength(40)
+ expect(flags).toHaveLength(38)
})
- it('every loops tool is gated on the loops flag', () => {
- // Guards against a loops tool (hand-written like loops-review, or generated)
- // shipping without the gate and leaking the unreleased surface pre-rollout.
- const loopsTools = Object.entries(getToolDefinitions()).filter(([name]) => name.startsWith('loops-'))
- expect(loopsTools.length).toBeGreaterThan(0)
- for (const [name, definition] of loopsTools) {
- expect({ name, feature_flag: definition.feature_flag }).toEqual({ name, feature_flag: 'loops' })
- }
- })
-
- it('keeps human, task, and loop context wiki tools on separate scopes', () => {
+ it('keeps human and task context wiki tools on separate scopes', () => {
const definitions = getToolDefinitions()
expect(definitions['context-wiki-page-update']!.required_scopes).toEqual(['organization:write'])
expect(definitions['task-context-wiki-page-update']!.required_scopes).toEqual([
@@ -1162,15 +1150,6 @@ describe('Tool Filtering - Feature Flags', () => {
'internal_run:read',
'context_layer_internal:write',
])
- expect(definitions['loop-context-wiki-page-update']!.required_scopes).toEqual([
- 'task:write',
- 'loop_context_internal:write',
- ])
- expect(definitions['loop-channel-instructions-update']!.required_scopes).toEqual([
- 'task:write',
- 'loop_context_internal:write',
- ])
- expect(definitions['loop-channel-instructions-update']!.feature_flag).toBeUndefined()
})
it('shows task context writes only to write-enabled task credentials', async () => {