:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(annotations): expose emoji param on annotation MCP tools (#62308)
Paul D'Ambra3f6d93242547
diff --git a/products/annotations/mcp/tools.yaml b/products/annotations/mcp/tools.yamlindex ddb5d5799038..06806c18d657 100644--- a/products/annotations/mcp/tools.yaml+++ b/products/annotations/mcp/tools.yaml@@ -22,11 +22,13 @@ tools:description: >Create an annotation to mark an important change (for example, a deployment) on charts and trends. Provide anote in `content`, when it happened in `date_marker` (ISO 8601), and whether it is scoped to the current- `project` or the whole `organization`.+ `project` or the whole `organization`. Optionally set an `emoji` to show in place of the default badge on+ the chart.include_params:- content- date_marker- scope+ - emojiannotation-delete:operation: annotations_destroyenabled: true@@ -83,11 +85,13 @@ tools:title: Update annotationdescription: >Update an existing annotation by ID. You can change its text (`content`), when it happened (`date_marker`,- ISO 8601), or its visibility scope (`project` or `organization`). Only the fields you provide are updated.+ ISO 8601), its visibility scope (`project` or `organization`), or its `emoji`. Only the fields you provide+ are updated.include_params:- content- date_marker- scope+ - emojiannotations-update:operation: annotations_updateenabled: falsediff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex dc965a1a69c2..672ec4ca69bd 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -331,7 +331,7 @@}},"annotation-create": {- "description": "Create an annotation to mark an important change (for example, a deployment) on charts and trends. Provide a note in `content`, when it happened in `date_marker` (ISO 8601), and whether it is scoped to the current `project` or the whole `organization`.",+ "description": "Create an annotation to mark an important change (for example, a deployment) on charts and trends. Provide a note in `content`, when it happened in `date_marker` (ISO 8601), and whether it is scoped to the current `project` or the whole `organization`. Optionally set an `emoji` to show in place of the default badge on the chart.","category": "Annotations","feature": "annotations","summary": "Create annotation",@@ -387,7 +387,7 @@}},"annotations-partial-update": {- "description": "Update an existing annotation by ID. You can change its text (`content`), when it happened (`date_marker`, ISO 8601), or its visibility scope (`project` or `organization`). Only the fields you provide are updated.",+ "description": "Update an existing annotation by ID. You can change its text (`content`), when it happened (`date_marker`, ISO 8601), its visibility scope (`project` or `organization`), or its `emoji`. Only the fields you provide are updated.","category": "Annotations","feature": "annotations","summary": "Update annotation",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex a35791c48897..71faba0a1e96 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -347,7 +347,7 @@}},"annotation-create": {- "description": "Create an annotation to mark an important change (for example, a deployment) on charts and trends. Provide a note in `content`, when it happened in `date_marker` (ISO 8601), and whether it is scoped to the current `project` or the whole `organization`.",+ "description": "Create an annotation to mark an important change (for example, a deployment) on charts and trends. Provide a note in `content`, when it happened in `date_marker` (ISO 8601), and whether it is scoped to the current `project` or the whole `organization`. Optionally set an `emoji` to show in place of the default badge on the chart.","category": "Annotations","feature": "annotations","summary": "Create annotation",@@ -403,7 +403,7 @@}},"annotations-partial-update": {- "description": "Update an existing annotation by ID. You can change its text (`content`), when it happened (`date_marker`, ISO 8601), or its visibility scope (`project` or `organization`). Only the fields you provide are updated.",+ "description": "Update an existing annotation by ID. You can change its text (`content`), when it happened (`date_marker`, ISO 8601), its visibility scope (`project` or `organization`), or its `emoji`. Only the fields you provide are updated.","category": "Annotations","feature": "annotations","summary": "Update annotation",diff --git a/services/mcp/src/tools/generated/annotations.ts b/services/mcp/src/tools/generated/annotations.tsindex c2b48b6a5832..c803902767d6 100644--- a/services/mcp/src/tools/generated/annotations.ts+++ b/services/mcp/src/tools/generated/annotations.ts@@ -19,7 +19,6 @@ const AnnotationCreateSchema = AnnotationsCreateBody.omit({dashboard_item: true,dashboard_id: true,deleted: true,- emoji: true,})const annotationCreate = (): ToolBase<typeof AnnotationCreateSchema, Schemas.Annotation> => ({@@ -37,6 +36,9 @@ const annotationCreate = (): ToolBase<typeof AnnotationCreateSchema, Schemas.Annif (params.scope !== undefined) {body['scope'] = params.scope}+ if (params.emoji !== undefined) {+ body['emoji'] = params.emoji+ }const result = await context.api.request<Schemas.Annotation>({method: 'POST',path: `/api/projects/${encodeURIComponent(String(projectId))}/annotations/`,@@ -103,13 +105,8 @@ const annotationsList = (): ToolBase<})const AnnotationsPartialUpdateSchema = AnnotationsPartialUpdateParams.omit({ project_id: true }).extend(- AnnotationsPartialUpdateBody.omit({- creation_type: true,- dashboard_item: true,- dashboard_id: true,- deleted: true,- emoji: true,- }).shape+ AnnotationsPartialUpdateBody.omit({ creation_type: true, dashboard_item: true, dashboard_id: true, deleted: true })+ .shape)const annotationsPartialUpdate = (): ToolBase<typeof AnnotationsPartialUpdateSchema, Schemas.Annotation> => ({@@ -127,6 +124,9 @@ const annotationsPartialUpdate = (): ToolBase<typeof AnnotationsPartialUpdateSchif (params.scope !== undefined) {body['scope'] = params.scope}+ if (params.emoji !== undefined) {+ body['emoji'] = params.emoji+ }const result = await context.api.request<Schemas.Annotation>({method: 'PATCH',path: `/api/projects/${encodeURIComponent(String(projectId))}/annotations/${encodeURIComponent(String(params.id))}/`,diff --git a/services/mcp/tests/tools/annotations.integration.test.ts b/services/mcp/tests/tools/annotations.integration.test.tsindex 7a72418bf8b7..d8ead550e7e7 100644--- a/services/mcp/tests/tools/annotations.integration.test.ts+++ b/services/mcp/tests/tools/annotations.integration.test.ts@@ -47,6 +47,7 @@ describe('Annotations', { concurrent: false }, () => {content: `Test annotation ${generateUniqueKey('ann')}`,date_marker: '2024-01-15T12:00:00Z',scope: 'project' as const,+ emoji: '🤖',}const result = await createTool.handler(context, params)@@ -56,6 +57,7 @@ describe('Annotations', { concurrent: false }, () => {expect(annotation.content).toBe(params.content)expect(annotation.date_marker).toContain('2024-01-15')expect(annotation.scope).toBe('project')+ expect(annotation.emoji).toBe('🤖')createdAnnotationIds.push(annotation.id)})@@ -162,6 +164,25 @@ describe('Annotations', { concurrent: false }, () => {expect(updated.date_marker).toContain('2024-06-15')})+ it('should update annotation emoji', async () => {+ const createResult = await createTool.handler(context, {+ content: `Emoji update ${generateUniqueKey('emoji')}`,+ date_marker: '2024-07-15T00:00:00Z',+ scope: 'project' as const,+ })+ const created = parseToolResponse(createResult)+ createdAnnotationIds.push(created.id)++ const result = await updateTool.handler(context, {+ id: created.id,+ emoji: '🚀',+ })+ const updated = parseToolResponse(result)++ expect(updated.id).toBe(created.id)+ expect(updated.emoji).toBe('🚀')+ })+it('should update annotation scope', async () => {const createResult = await createTool.handler(context, {content: `Scope update ${generateUniqueKey('scope')}`,diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/annotation-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/annotation-create.jsonindex e23394fda0d1..7777e9acb20c 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/annotation-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/annotation-create.json@@ -26,6 +26,18 @@],"description": "When this annotation happened (ISO 8601 timestamp). Used to position it on charts."},+ "emoji": {+ "anyOf": [+ {+ "maxLength": 16,+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "Optional emoji shown in place of the default badge when this annotation is surfaced on a chart."+ },"scope": {"description": "Annotation visibility scope: `project`, `organization`, `dashboard`, or `dashboard_item`. `recording` is deprecated and rejected.\n\n* `dashboard_item` - insight\n* `dashboard` - dashboard\n* `project` - project\n* `organization` - organization\n* `recording` - recording","enum": ["dashboard_item", "dashboard", "project", "organization", "recording"],diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/annotations-partial-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/annotations-partial-update.jsonindex e7f3df06a3b3..58c8feb6a948 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/annotations-partial-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/annotations-partial-update.json@@ -26,6 +26,18 @@],"description": "When this annotation happened (ISO 8601 timestamp). Used to position it on charts."},+ "emoji": {+ "anyOf": [+ {+ "maxLength": 16,+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "description": "Optional emoji shown in place of the default badge when this annotation is surfaced on a chart."+ },"id": {"description": "A unique integer value identifying this annotation.","type": "number"