feat(subscriptions): expose AI subscriptions + ad-hoc reports as MCP tools#59633
feat(subscriptions): expose AI subscriptions + ad-hoc reports as MCP tools#59633vdekrijger wants to merge 2 commits into
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
MCP UI Apps size report
|
🔍 Migration Risk AnalysisWe've analyzed your migrations for potential risks. Summary: 0 Safe | 0 Needs Review | 1 Blocked ❌ BlockedCauses locks or breaks compatibility 📚 How to Deploy These Changes SafelyAddField: This operation acquires a brief lock but doesn't rewrite the table. Deployment uses lock timeouts with automatic retries, so lock contention will cause retries rather than connection pile-up. RunPython: Use batching for large data migrations:
See the migration safety guide Last updated: 2026-05-27 07:51 UTC (15f237f) |
| url_prefix: /subscriptions | ||
| ui_apps: {} | ||
| tools: | ||
| subscriptions-create: |
There was a problem hiding this comment.
Can you help me sanity check, but I presume we currently have no subscription based tools available for our MCP right?
There was a problem hiding this comment.
Good call to sanity-check this. Turns out we did already have subscription tools — they lived enabled in services/mcp/definitions/core.yaml, not here. Rather than duplicate, I migrated them all into this product file as the single source of truth and reduced the core.yaml entries to disabled stubs (matching the dashboards/feature_flags pattern). Done in 15f237f.
|
|
||
| (3) `content_type: "ai_prompt"` — schedule a recurring LLM-generated report from a free-text prompt. | ||
| Requires `prompt` (≤4000 chars). Subject to cloud + org-level AI data-processing consent + | ||
| `SUBSCRIPTION_AI_PROMPT` feature flag. `target_type` must be `email` or `slack` (no webhook for |
There was a problem hiding this comment.
Webhook isn't allowed for the other subs either, they share the same delivery options, so. Iwonder if we should isntead just generalise them instead of solely mentioning it here.
There was a problem hiding this comment.
Generalized — the create description now frames delivery as set by target_type (email/slack/webhook) across all flavours, and calls out that AI-prompt subs support email + slack only, instead of implying webhook is special-cased just here. 15f237f.
| (3) `content_type: "ai_prompt"` — schedule a recurring LLM-generated report from a free-text prompt. | ||
| Requires `prompt` (≤4000 chars). Subject to cloud + org-level AI data-processing consent + | ||
| `SUBSCRIPTION_AI_PROMPT` feature flag. `target_type` must be `email` or `slack` (no webhook for | ||
| AI subs). `ai_config` (optional) accepts `model` and `planner_model` from a whitelisted set. |
There was a problem hiding this comment.
AI config has been removed, so please clean up this PR with all references!
There was a problem hiding this comment.
Cleaned up — removed all ai_config references (excluded from the create params and dropped from the skill). 15f237f.
| AI subs). `ai_config` (optional) accepts `model` and `planner_model` from a whitelisted set. | ||
|
|
||
| `content_type` is pinned at create time — switching kind via PATCH is rejected. For an | ||
| immediately-delivered ad-hoc AI report (no schedule, no recipient), use subscriptions-ai-report-create |
There was a problem hiding this comment.
I think this endpoint will end up being removed! so we can remove it here and disable / remove the tool as well.
There was a problem hiding this comment.
Done — subscriptions-ai-report-create is now a disabled stub and the ad-hoc op is no longer exposed as a tool. 15f237f.
| (2) `content_type: "dashboard"` — schedule periodic snapshots of one dashboard. Requires `dashboard` | ||
| and `dashboard_export_insights` (the subset of the dashboard's insights to include, max 6). | ||
|
|
||
| (3) `content_type: "ai_prompt"` — schedule a recurring LLM-generated report from a free-text prompt. |
There was a problem hiding this comment.
This option is currently only enabled if the user is part of the feature flag, do we need to mention that here? or is there a better way to go about it?
There was a problem hiding this comment.
Reworded to avoid coupling the doc to a flag name — the description now says AI-prompt subs are available "once the organization has approved AI data processing and AI subscriptions are enabled for it," which captures the gate behaviorally. 15f237f.
| @@ -0,0 +1,101 @@ | |||
| --- | |||
| name: generating-ad-hoc-ai-report | |||
There was a problem hiding this comment.
I think we should remove this skill as I would suggest to remove that ad hoc endpoint!
There was a problem hiding this comment.
Removed — generating-ad-hoc-ai-report/SKILL.md is deleted (git rm). 15f237f.
|
|
||
| Use this skill when the user wants a **recurring** AI-generated report delivered on | ||
| a schedule. For a one-off "generate now and return markdown" (no schedule, no | ||
| delivery), use `generating-ad-hoc-ai-report` instead. |
There was a problem hiding this comment.
I think we'll remove that sklil, so please don't reference it anymore
There was a problem hiding this comment.
Done — all references to the ad-hoc report skill are removed from creating-ai-subscription. 15f237f.
| - **One transient send failure auto-fails the whole delivery** (the cached markdown | ||
| means a retry is cheap). Slack rate limits or SMTP blips will trigger Temporal | ||
| retries on the next tick; persistent failures auto-disable the subscription. | ||
| - **Test the prompt first with `generating-ad-hoc-ai-report`** before scheduling |
There was a problem hiding this comment.
This functionality will go away FYI
There was a problem hiding this comment.
Removed the ad-hoc functionality references here too. 15f237f.
- migrate subscription MCP tools fully into products/subscriptions/mcp/tools.yaml;
reduce core.yaml entries to disabled stubs (single source of truth)
- subscriptions-delete: soft_delete: true so it PATCHes {deleted: true} instead of
issuing a DELETE that 405s under ForbidDestroyModel; cast id string-int
- subscriptions-list: fix response.exclude to bare field name (invite_message);
results.*.invite_message was a silent no-op that leaked the field
- subscriptions-partial-update: exclude deleted so deletion only via dedicated tool
- bring deliveries-list/retrieve + test-delivery over enabled with accurate
409/404 docs
- creating-ai-subscription skill: drop ad-hoc report refs, fix Slack channel
discovery flow and auto-disable wording; remove generating-ad-hoc-ai-report skill
|
Size Change: 0 B Total Size: 119 MB ℹ️ View Unchanged
|

Problem
Changes
How did you test this code?
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Publish to changelog?
Docs update
🤖 Agent context