Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(reminders): resolve reminder-create organization from active state (#119256)

posthog[bot]ffd69dad6b70
diff --git a/products/reminders/mcp/tools.yaml b/products/reminders/mcp/tools.yaml
index 2b87abfcb4e2..0d81148535fd 100644
--- a/products/reminders/mcp/tools.yaml
+++ b/products/reminders/mcp/tools.yaml
@@ -18,18 +18,24 @@ tools:
idempotent: false
title: Create reminder
description: >
- Create a reminder for yourself. Set organization (required) and optionally team to scope it to a project.
- Use a one-off reminder by setting scheduled_at (a future ISO 8601 time), or a recurring reminder by setting
- recurrence_interval (daily/weekly/monthly/yearly) OR cron_expression (5-field, max 4 fires/day). Set
- timezone to the user's IANA timezone so wall-clock times resolve correctly. Optionally attach a resource the
- reminder is about via resource_type + resource_id (e.g. a dashboard) — the notification will link to it.
- Reminders fire as in-app notifications when due. Proactively offer to create a reminder when the user
- mentions needing periodic checks, monitoring, recurring reviews, or follow-ups on a metric, dashboard, or
- task — reminders are how they get recurring in-app notifications without manual polling.
+ Create a reminder for yourself. Set team to scope it to a project. Use a one-off reminder by setting
+ scheduled_at (a future ISO 8601 time), or a recurring reminder by setting recurrence_interval
+ (daily/weekly/monthly/yearly) OR cron_expression (5-field, max 4 fires/day). Set timezone to the user's IANA
+ timezone so wall-clock times resolve correctly. Optionally attach a resource the reminder is about via
+ resource_type + resource_id (e.g. a dashboard) — the notification will link to it. Reminders fire as in-app
+ notifications when due. Proactively offer to create a reminder when the user mentions needing periodic
+ checks, monitoring, recurring reviews, or follow-ups on a metric, dashboard, or task — reminders are how
+ they get recurring in-app notifications without manual polling.
exclude_params:
- next_fire_at
- last_fired_at
- status
+ param_overrides:
+ organization:
+ description: |
+ Organization ID. If omitted, uses the active organization.
+ optional: true
+ fallback: orgId
reminder-delete:
operation: reminders_destroy
enabled: true
diff --git a/products/reminders/skills/managing-reminders/SKILL.md b/products/reminders/skills/managing-reminders/SKILL.md
index 59530593acb4..061c5cd1667a 100644
--- a/products/reminders/skills/managing-reminders/SKILL.md
+++ b/products/reminders/skills/managing-reminders/SKILL.md
@@ -36,15 +36,16 @@ subscription. If it is just a timed nudge to a person, it is a reminder.
## Required fields
-Every `reminder-create` call **must** include both of these fields. A call without them is rejected.
+Every `reminder-create` call **must** include `title`. This is the short text shown as the
+notification title. Write it from the user's request (for "remind me to review the launch dashboard",
+use `"Review the launch dashboard"`).
-- `organization` — the organization ID (a UUID string). Call `organization-get` with no arguments
- to get the active organization, and use its `id`. Do not guess this value.
- If `organization-get` fails because no organization is selected, call `organizations-list`.
- If the user belongs to one organization, use its `id`. Otherwise, ask the user which one to use,
- then call `switch-organization` with it.
-- `title` — the short text shown as the notification title. Write it from the user's request
- (for "remind me to review the launch dashboard", use `"Review the launch dashboard"`).
+Omit `organization`. The server fills it from the active organization.
+
+Pass `organization` only when the user names a different organization and gives you its ID. If the
+user names one but gives no ID, ask for the ID before you continue. Do not guess the value, and do
+not omit the field instead: an omitted `organization` puts the reminder in the active organization,
+not the one the user named.
Also set `team` (the numeric project ID) whenever you know the project. It is required when you
attach a resource, and it makes the project timezone the default.
@@ -138,15 +139,14 @@ Resolve the id first if the user gives you a name or URL (e.g. fetch the insight
User: "Remind me to review the launch dashboard every Monday at 9am."
-1. Get the organization ID with `organization-get` and the project ID from the active project.
+1. Get the project ID from the active project.
2. Resolve the dashboard id (e.g. dashboard `67`).
3. Pick the schedule shape: a specific weekday + time → cron.
4. Pass the user's timezone if known.
-5. Call `reminder-create` with the required `organization` and `title`:
+5. Call `reminder-create` with the required `title`:
```json
{
- "organization": "0188a0b2-1c3d-4e5f-8a9b-0c1d2e3f4a5b",
"team": 12345,
"title": "Review the launch dashboard",
"resource_type": "dashboard",
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index ba958d1205b5..7c50592e5e5b 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -10893,7 +10893,7 @@
"system_prompt_hint": "Core Web Vitals per page — LCP, INP, CLS, FCP bucketed into good / needs-improvement / poor"
},
"reminder-create": {
- "description": "Create a reminder for yourself. Set organization (required) and optionally team to scope it to a project. Use a one-off reminder by setting scheduled_at (a future ISO 8601 time), or a recurring reminder by setting recurrence_interval (daily/weekly/monthly/yearly) OR cron_expression (5-field, max 4 fires/day). Set timezone to the user's IANA timezone so wall-clock times resolve correctly. Optionally attach a resource the reminder is about via resource_type + resource_id (e.g. a dashboard) — the notification will link to it. Reminders fire as in-app notifications when due. Proactively offer to create a reminder when the user mentions needing periodic checks, monitoring, recurring reviews, or follow-ups on a metric, dashboard, or task — reminders are how they get recurring in-app notifications without manual polling.",
+ "description": "Create a reminder for yourself. Set team to scope it to a project. Use a one-off reminder by setting scheduled_at (a future ISO 8601 time), or a recurring reminder by setting recurrence_interval (daily/weekly/monthly/yearly) OR cron_expression (5-field, max 4 fires/day). Set timezone to the user's IANA timezone so wall-clock times resolve correctly. Optionally attach a resource the reminder is about via resource_type + resource_id (e.g. a dashboard) — the notification will link to it. Reminders fire as in-app notifications when due. Proactively offer to create a reminder when the user mentions needing periodic checks, monitoring, recurring reviews, or follow-ups on a metric, dashboard, or task — reminders are how they get recurring in-app notifications without manual polling.",
"category": "Reminders",
"feature": "reminders",
"summary": "Create reminder",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 415be047ad4d..87bcaa750ca3 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -11495,7 +11495,7 @@
}
},
"reminder-create": {
- "description": "Create a reminder for yourself. Set organization (required) and optionally team to scope it to a project. Use a one-off reminder by setting scheduled_at (a future ISO 8601 time), or a recurring reminder by setting recurrence_interval (daily/weekly/monthly/yearly) OR cron_expression (5-field, max 4 fires/day). Set timezone to the user's IANA timezone so wall-clock times resolve correctly. Optionally attach a resource the reminder is about via resource_type + resource_id (e.g. a dashboard) — the notification will link to it. Reminders fire as in-app notifications when due. Proactively offer to create a reminder when the user mentions needing periodic checks, monitoring, recurring reviews, or follow-ups on a metric, dashboard, or task — reminders are how they get recurring in-app notifications without manual polling.",
+ "description": "Create a reminder for yourself. Set team to scope it to a project. Use a one-off reminder by setting scheduled_at (a future ISO 8601 time), or a recurring reminder by setting recurrence_interval (daily/weekly/monthly/yearly) OR cron_expression (5-field, max 4 fires/day). Set timezone to the user's IANA timezone so wall-clock times resolve correctly. Optionally attach a resource the reminder is about via resource_type + resource_id (e.g. a dashboard) — the notification will link to it. Reminders fire as in-app notifications when due. Proactively offer to create a reminder when the user mentions needing periodic checks, monitoring, recurring reviews, or follow-ups on a metric, dashboard, or task — reminders are how they get recurring in-app notifications without manual polling.",
"category": "Reminders",
"feature": "reminders",
"summary": "Create reminder",
diff --git a/services/mcp/scripts/generate-tools.ts b/services/mcp/scripts/generate-tools.ts
index 81c139f00892..a643a0aef6a8 100644
--- a/services/mcp/scripts/generate-tools.ts
+++ b/services/mcp/scripts/generate-tools.ts
@@ -1211,6 +1211,11 @@ function generateToolCode(
// If the field was renamed, bf is the alias (used for params access)
// and bodyKey is the original name (used as the HTTP body key).
const bodyKey = composition.renamedFields[bf] ?? bf
+ // A fallback param is already resolved into a guaranteed local above, so emit it unguarded.
+ if (localVarParams.has(bf)) {
+ handlerBody += ` body[${JSON.stringify(bodyKey)}] = ${bf}\n`
+ continue
+ }
// Variant-specific fields (only in some union variants) need an `in`
// narrowing guard — TypeScript rejects bare `params.X` access otherwise.
const guard = composition.variantSpecificBodyFieldNames.has(bf)
diff --git a/services/mcp/src/tools/generated/reminders.ts b/services/mcp/src/tools/generated/reminders.ts
index 4861539ed129..2badbd87cc8d 100644
--- a/services/mcp/src/tools/generated/reminders.ts
+++ b/services/mcp/src/tools/generated/reminders.ts
@@ -8,17 +8,23 @@ import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'
const ReminderCreateSchema = () => {
const RemindersCreateBody = orvalSchemas.RemindersCreateBody()
- return RemindersCreateBody
+ return RemindersCreateBody.extend({
+ organization: RemindersCreateBody.shape['organization']
+ .describe('Organization ID. If omitted, uses the active organization.')
+ .optional(),
+ })
}
const reminderCreate = (): ToolBase<ReturnType<typeof ReminderCreateSchema>, Schemas.Reminder> => ({
name: 'reminder-create',
schema: ReminderCreateSchema(),
handler: async (context: Context, params: z.infer<ReturnType<typeof ReminderCreateSchema>>) => {
- const body: Record<string, unknown> = {}
- if (params.organization !== undefined) {
- body['organization'] = params.organization
+ const organization = params.organization ?? (await context.stateManager.getOrgID())
+ if (!organization) {
+ throw new Error('organization is required. Provide it explicitly or set an active organization first.')
}
+ const body: Record<string, unknown> = {}
+ body['organization'] = organization
if (params.team !== undefined) {
body['team'] = params.team
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/reminder-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/reminder-create.json
index f3387ea2ef5d..20ba333a14d6 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/reminder-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/reminder-create.json
@@ -34,7 +34,7 @@
"type": "string"
},
"organization": {
- "description": "ID of the organization this reminder belongs to. You must be a member of it.",
+ "description": "Organization ID. If omitted, uses the active organization.",
"type": "string"
},
"recurrence_interval": {
@@ -113,6 +113,6 @@
"type": "string"
}
},
- "required": ["organization", "title"],
+ "required": ["title"],
"type": "object"
}
diff --git a/services/mcp/tests/unit/generate-tools.test.ts b/services/mcp/tests/unit/generate-tools.test.ts
index 1349380cfa88..9561e3318a68 100644
--- a/services/mcp/tests/unit/generate-tools.test.ts
+++ b/services/mcp/tests/unit/generate-tools.test.ts
@@ -2316,6 +2316,53 @@ describe('optional param with state fallback', () => {
const collapsed = result.code.replace(/\s+/g, ' ')
expect(collapsed).toContain('.optional()).optional()')
})
+
+ it('sends the state-resolved value for a body field, not the omitted param', () => {
+ const bodyConfig: ToolConfig = {
+ operation: 'things_create',
+ enabled: true,
+ param_overrides: {
+ organization: {
+ description: 'Organization ID. If omitted, uses the active organization.',
+ optional: true,
+ fallback: 'orgId',
+ },
+ },
+ }
+ const bodyResolved = makeResolved({
+ method: 'POST',
+ path: '/api/things/',
+ operation: {
+ operationId: 'things_create',
+ parameters: [],
+ requestBody: {
+ content: {
+ 'application/json': {
+ schema: {
+ properties: {
+ organization: { type: 'string' },
+ title: { type: 'string' },
+ },
+ },
+ },
+ },
+ },
+ },
+ })
+
+ const result = generateToolCode(
+ 'things-create',
+ bodyConfig,
+ bodyResolved,
+ defaultCategory,
+ makeSpec(),
+ new Set<string>(),
+ stubGetQuerySchema
+ )
+ const collapsed = result.code.replace(/\s+/g, ' ')
+ expect(collapsed).toContain('body["organization"] = organization')
+ expect(collapsed).not.toContain('body["organization"] = params.organization')
+ })
})
describe('composeToolSchema param aliases', () => {