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.

feat(signals): enable the inbox-reports-merge MCP tool (#107088)

posthog[bot]ac764eb5e734
diff --git a/products/signals/mcp/tools.yaml b/products/signals/mcp/tools.yaml
index 71112a0b05fb..b3ff7b626424 100644
--- a/products/signals/mcp/tools.yaml
+++ b/products/signals/mcp/tools.yaml
@@ -287,14 +287,14 @@ tools:
- updated_at
inbox-reports-merge:
operation: signals_reports_merge_create
- enabled: false
+ enabled: true
scopes:
- task:write
annotations:
readOnly: false
destructive: true
idempotent: false
- enrich_url: '{id}'
+ enrich_url: '{params.id}'
title: Merge duplicate reports into one
description: >
Fold duplicate inbox reports into the one report that survives them, when the same issue landed in more than
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 37202c8f5c60..6b93a98a11ef 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -6381,6 +6381,20 @@
"readOnlyHint": true
}
},
+ "inbox-reports-merge": {
+ "description": "Fold duplicate inbox reports into the one report that survives them, when the same issue landed in more than one report. The URL names the survivor and `source_report_ids` (1–10) names the duplicates. Pick the survivor deliberately: prefer the older report, and prefer the one holding an open implementation PR or an active claim. The sources' signals, work-log artefacts, pull requests, task runs and checks move onto the survivor, the survivor's signal counters take theirs on, and each source is archived with a 'duplicate of' link back. A source's open pull request stays open, because the survivor holds it after the move; any active claim on a source is released first, so re-claim the survivor if you were working on one. Titles and summaries are NOT combined, so follow with `inbox-reports-update` if the survivor needs a rewrite. Both ends must be a live report, and the whole call applies or none of it does: 409 and no writes when the survivor is resolved, or when a source is the survivor itself, is resolved or archived, is still being researched (`in_progress`), or carries more signals than one merge can move. A merged report keeps its URL but can never be restored, so merge only reports you are confident are the same issue, and use an `inbox-report-artefacts-create` `related_to` link when they are merely related.",
+ "category": "Signals",
+ "feature": "signals",
+ "summary": "Merge duplicate reports into one",
+ "title": "Merge duplicate reports into one",
+ "required_scopes": ["task:write"],
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
+ },
"inbox-reports-retrieve": {
"description": "Get a single signal report by ID. Returns the full report, including work_state, current assignee, and the attached pull request and its latest known state, plus typed impact metrics. Every metric includes a bounded live InsightVizNode/TrendsQuery built only from EventsNode or ActionsNode sources and may include an optional cached snapshot fallback. This call returns that stored content without executing the query. Consumers derive a BoldNumber whole-window headline and an ActionsBar longitudinal response, capped at 1,000 estimated points, through the normal analytics query path and cache. Queryless legacy or malformed metrics are always redacted. The report's full work log is readable via inbox-report-artefacts-list; read it before acting. The raw underlying signals require a HogQL query (see the 'signals' skill). Claim the report before doing work. A report may be claimed in potential, candidate, in_progress, pending_input, ready, or failed state.",
"category": "Signals",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index cc7f810cc0ac..af095b321ed2 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -6578,6 +6578,20 @@
"readOnlyHint": true
}
},
+ "inbox-reports-merge": {
+ "description": "Fold duplicate inbox reports into the one report that survives them, when the same issue landed in more than one report. The URL names the survivor and `source_report_ids` (1–10) names the duplicates. Pick the survivor deliberately: prefer the older report, and prefer the one holding an open implementation PR or an active claim. The sources' signals, work-log artefacts, pull requests, task runs and checks move onto the survivor, the survivor's signal counters take theirs on, and each source is archived with a 'duplicate of' link back. A source's open pull request stays open, because the survivor holds it after the move; any active claim on a source is released first, so re-claim the survivor if you were working on one. Titles and summaries are NOT combined, so follow with `inbox-reports-update` if the survivor needs a rewrite. Both ends must be a live report, and the whole call applies or none of it does: 409 and no writes when the survivor is resolved, or when a source is the survivor itself, is resolved or archived, is still being researched (`in_progress`), or carries more signals than one merge can move. A merged report keeps its URL but can never be restored, so merge only reports you are confident are the same issue, and use an `inbox-report-artefacts-create` `related_to` link when they are merely related.",
+ "category": "Signals",
+ "feature": "signals",
+ "summary": "Merge duplicate reports into one",
+ "title": "Merge duplicate reports into one",
+ "required_scopes": ["task:write"],
+ "annotations": {
+ "destructiveHint": true,
+ "idempotentHint": false,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ }
+ },
"inbox-reports-retrieve": {
"description": "Get a single signal report by ID. Returns the full report, including work_state, current assignee, and the attached pull request and its latest known state, plus typed impact metrics. Every metric includes a bounded live InsightVizNode/TrendsQuery built only from EventsNode or ActionsNode sources and may include an optional cached snapshot fallback. This call returns that stored content without executing the query. Consumers derive a BoldNumber whole-window headline and an ActionsBar longitudinal response, capped at 1,000 estimated points, through the normal analytics query path and cache. Queryless legacy or malformed metrics are always redacted. The report's full work log is readable via inbox-report-artefacts-list; read it before acting. The raw underlying signals require a HogQL query (see the 'signals' skill). Claim the report before doing work. A report may be claimed in potential, candidate, in_progress, pending_input, ready, or failed state.",
"category": "Signals",
diff --git a/services/mcp/src/generated/signals/api.ts b/services/mcp/src/generated/signals/api.ts
index 625e2bb246f9..8d605c9669b3 100644
--- a/services/mcp/src/generated/signals/api.ts
+++ b/services/mcp/src/generated/signals/api.ts
@@ -3,7 +3,7 @@
* MCP service uses these Zod schemas for generated tool handlers.
* To regenerate: hogli build:openapi
*
- * PostHog API - MCP 48 enabled ops
+ * PostHog API - MCP 49 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
@@ -232,6 +232,40 @@ export const SignalsReportsClaimBody = () => zod.object({
.describe('Release ownership while preserving any attached pull request.'),
})
+/**
+ * Fold one or more duplicate reports into this report, which survives. The sources' signals, work-log artefacts, pull requests, task runs and checks move onto the survivor, the survivor's signal counters take on theirs, and each source is archived with a 'duplicate of' link back to the survivor. A source's open pull request stays open, because the survivor holds it after the move. Pick the survivor deliberately: prefer the older report, and prefer the one with an open implementation PR or an active claim. Any active claim on a source is released, so re-claim the survivor if you were working on one. Titles and summaries are not combined, so edit it afterwards if it needs a rewrite. A merged report keeps its URL but cannot be restored, because its signals now belong to the survivor.
+ * @summary Merge duplicate reports into this one
+ */
+export const SignalsReportsMergeCreateParams = () => zod.object({
+ id: zod.string().describe('A UUID string identifying this signal report.'),
+ 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 signalsReportsMergeCreateBodySourceReportIdsMax = 10
+
+export const signalsReportsMergeCreateBodyReasonMax = 500
+
+export const SignalsReportsMergeCreateBody = () => zod.object({
+ source_report_ids: zod
+ .array(zod.string())
+ .min(1)
+ .max(signalsReportsMergeCreateBodySourceReportIdsMax)
+ .describe(
+ "Ids of the duplicate reports to fold into this one (1–10). Each must be a live report in this project: a resolved, archived or deleted report is rejected with 409, as is the survivor's own id. Duplicates in the list are de-duplicated. The whole merge applies or none of it does."
+ ),
+ reason: zod
+ .string()
+ .max(signalsReportsMergeCreateBodyReasonMax)
+ .optional()
+ .describe(
+ "Optional one-line explanation of why these reports are the same issue. Recorded on each source's 'duplicate of' link and on the note left on the survivor. Capped at 500 characters."
+ ),
+})
+
/**
* Transition a report to a new state. The model validates allowed transitions, except that a
* verdict the report already holds (dismissing a suppressed report, resolving a resolved one)
diff --git a/services/mcp/src/tools/generated/signals.ts b/services/mcp/src/tools/generated/signals.ts
index 9ac53ad7cfdd..6c42baec50cb 100644
--- a/services/mcp/src/tools/generated/signals.ts
+++ b/services/mcp/src/tools/generated/signals.ts
@@ -423,6 +423,39 @@ const inboxReportsList = (): ToolBase<
},
})
+const InboxReportsMergeSchema = () => {
+ const SignalsReportsMergeCreateBody = orvalSchemas.SignalsReportsMergeCreateBody()
+ const SignalsReportsMergeCreateParams = orvalSchemas.SignalsReportsMergeCreateParams()
+ return z.preprocess(
+ normalizeParamAliases({ id: ['survivor_report_id'] }),
+ SignalsReportsMergeCreateParams.omit({ project_id: true }).extend(SignalsReportsMergeCreateBody.shape)
+ )
+}
+
+const inboxReportsMerge = (): ToolBase<
+ ReturnType<typeof InboxReportsMergeSchema>,
+ WithPostHogUrl<Schemas.SignalReportMergeResponse>
+> => ({
+ name: 'inbox-reports-merge',
+ schema: InboxReportsMergeSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof InboxReportsMergeSchema>>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const body: Record<string, unknown> = {}
+ if (params.source_report_ids !== undefined) {
+ body['source_report_ids'] = params.source_report_ids
+ }
+ if (params.reason !== undefined) {
+ body['reason'] = params.reason
+ }
+ const result = await context.api.request<Schemas.SignalReportMergeResponse>({
+ method: 'POST',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/signals/reports/${encodeURIComponent(String(params.id))}/merge/`,
+ body,
+ })
+ return await withPostHogUrl(context, result, `/inbox/${params.id}`)
+ },
+})
+
const InboxReportsRetrieveSchema = () => {
const SignalsReportsRetrieveParams = orvalSchemas.SignalsReportsRetrieveParams()
return z.preprocess(
@@ -2383,6 +2416,7 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'inbox-reports-bulk-set-state': inboxReportsBulkSetState,
'inbox-reports-claim': inboxReportsClaim,
'inbox-reports-list': inboxReportsList,
+ 'inbox-reports-merge': inboxReportsMerge,
'inbox-reports-retrieve': inboxReportsRetrieve,
'inbox-reports-set-state': inboxReportsSetState,
'inbox-reports-update': inboxReportsUpdate,
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-merge.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-merge.json
new file mode 100644
index 000000000000..70941c016a9b
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/inbox-reports-merge.json
@@ -0,0 +1,25 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "id": {
+ "description": "A UUID string identifying this signal report.",
+ "type": "string"
+ },
+ "reason": {
+ "description": "Optional one-line explanation of why these reports are the same issue. Recorded on each source's 'duplicate of' link and on the note left on the survivor. Capped at 500 characters.",
+ "maxLength": 500,
+ "type": "string"
+ },
+ "source_report_ids": {
+ "description": "Ids of the duplicate reports to fold into this one (1–10). Each must be a live report in this project: a resolved, archived or deleted report is rejected with 409, as is the survivor's own id. Duplicates in the list are de-duplicated. The whole merge applies or none of it does.",
+ "items": {
+ "type": "string"
+ },
+ "maxItems": 10,
+ "minItems": 1,
+ "type": "array"
+ }
+ },
+ "required": ["id", "source_report_ids"],
+ "type": "object"
+}