Skip to content

feat: data-aware MCP tutorial (scout, real-schema quests, demo seeding)#600

Draft
joethreepwood wants to merge 1 commit into
mainfrom
feat/mcp-tutorial-data-aware
Draft

feat: data-aware MCP tutorial (scout, real-schema quests, demo seeding)#600
joethreepwood wants to merge 1 commit into
mainfrom
feat/mcp-tutorial-data-aware

Conversation

@joethreepwood

Copy link
Copy Markdown
Contributor

Problem

The MCP tutorial offers the same canned prompts to everyone, and nothing in it is data-aware. A freshly-installed project usually has near-zero events, so prompts like "show me my top events", "build a funnel", or "top errors this week" come back empty — and the agent, told it's a live demo, improvises and narrates emptiness. Users can wander into a data-less dead end where no path pays off.

Builds on the role-aware tutorial (#508) and the read-only/write scope split in src/lib/oauth/program-scopes.ts — reads are exploration, the writable surfaces (dashboards/insights/notebooks/annotations) are the guaranteed wins.

Changes

A best-effort scout runs once after auth and produces a ProjectDataProfile that routes every downstream branch, so the tutorial only ever offers playable moves.

  • Scoutsrc/lib/mcp-project-profile.ts: one HogQL query (POST /api/projects/:id/query/) for event volume + the project's real event names, plus parallel limit=1 REST existence checks for replay/surveys/flags/experiments/warehouse. Time-boxed (5s) and best-effort: a slow/failed probe returns a degraded profile and the tutorial falls back to the legacy static kit. Never throws, never blocks.
  • Real-schema quests — quests are generated from the project's own topCustomEvents (a funnel + trend + breakdown) instead of a hardcoded list. The agent orders funnel steps, so volume-sorted input is fine.
  • Activation cross-sells — a product the scout found no data for becomes a "here's how to turn on Session Replay / Error Tracking" prompt (routed through docs-search, which never dead-ends), ordered by role affinity. A dead end becomes a product-discovery beat.
  • Seedingsrc/lib/mcp-seed-events.ts: empty projects are offered a small backdated SaaS funnel ($pageview → signed_up → activated → feature_used → upgraded_to_paid) sent via posthog-node, tagged wizard_seed:true for one-click cleanup. Backdated across 7 days so time-windowed charts light up immediately. $exception is left out on purpose so error tracking stays an activation cross-sell.

getTutorialPicker() is the single composition point (empty → write-only + activation, rich → generated quests, sparse → safe read + quest, degraded → legacy). New screen phases: Scouting / SeedOffer / Seeding. Product knowledge stays in the mcp-* modules + copy JSON; the screen and services stay dumb orchestration; the agent SDK runner is untouched.

Files

  • new src/lib/mcp-project-profile.ts — probe + pure assembleProfile
  • new src/lib/mcp-seed-events.ts — seeder + deterministic dataset builder
  • src/lib/mcp-role-prompts.ts / .copy.json — generated quests, activation cross-sells, write-only quests, seed-offer copy
  • src/ui/tui/screens/McpSuggestedPromptsScreen.tsx — Scouting/SeedOffer/Seeding phases, profile-driven picker
  • src/ui/tui/services/mcp-suggested-prompts-services.tsprobeProjectData / seedDemoEvents
  • src/utils/urls.tsgetIngestionHostFromHost
  • playground demo — T tier toggle (rich/sparse/empty)

Test plan

  • pnpm build clean, tsc --noEmit clean
  • pnpm test848/848 (+36: profile classification, seed dataset, generated quests, activation selection, picker composition)
  • pnpm lint — 0 errors, 0 new warnings in touched files
  • Playground (pnpm try --playground → "MCP tutorial"): T cycles rich → sparse → empty; confirm rich leads with generated quests, empty walks SeedOffer → Seeding, R reorders activation cross-sells.
  • Real run (pnpm try mcp tutorial --debug): walk an empty project (seed fork) and a project with events (generated quests); tail -f /tmp/posthog-wizard.log | grep -E "probeProjectData|seedDemoEvents".

Note

The HogQL query/REST response shapes weren't validated against a live instance — the code degrades safely (legacy kit, never crashes) if a shape differs, but the probe wants one real run in wizard-workbench to confirm tier classification. Seeding writes ~89 demo events into whatever project you log into (tagged wizard_seed:true) — use a throwaway.

LLM context

Co-authored with Claude Code (Opus 4.8). Scope was deliberately the data-aware spine (ideas: scout, activation cross-sell, real-schema quests, seeding); a quest-log HUD and a role capstone were left as follow-ups.

🤖 Generated with Claude Code

Make the MCP tutorial look at the project before it talks. A fresh
install with no events used to hit "show me my top events", get nothing
back, and the agent would improvise — a data-less dead end. This adds a
best-effort scout after auth and routes every branch on what it finds.

- Scout (src/lib/mcp-project-profile.ts): one HogQL query for event
  volume + the project's real event names, plus parallel limit=1 REST
  existence checks for replay/surveys/flags/experiments/warehouse.
  Time-boxed and best-effort — a slow/failed probe returns a `degraded`
  profile and the tutorial falls back to the legacy static kit. Never
  throws, never blocks.
- Real-schema quests: the picker is generated from the project's own
  top custom events (funnel/trend/breakdown) instead of a hardcoded
  list. The agent orders funnel steps, so volume-sorted input is fine.
- Activation cross-sells: a product the scout found NO data for becomes
  a "here's how to turn on Session Replay / Error Tracking" prompt
  (routed through docs-search, which never dead-ends) ordered by role
  affinity — turning a dead end into a product-discovery beat.
- Seeding (src/lib/mcp-seed-events.ts): empty projects are offered a
  backdated SaaS funnel via posthog-node, tagged `wizard_seed:true` for
  one-click cleanup. $exception is left out so error tracking stays an
  activation cross-sell.

getTutorialPicker() is the single composition point (empty →
write-only + activation, rich → generated quests, sparse → safe read +
quest, degraded → legacy). Product knowledge stays in the mcp-* modules
and copy JSON; the screen + services stay orchestration. New phases:
Scouting, SeedOffer, Seeding. Playground gains a `T` tier toggle
(rich/sparse/empty) to preview every branch without the network.

+36 tests (profile classification, seed dataset, generated quests,
activation selection, picker composition). Builds clean, 848/848 pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci error-tracking-upload-source-maps
  • /wizard-ci misc
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci error-tracking-upload-source-maps/android
  • /wizard-ci error-tracking-upload-source-maps/flutter
  • /wizard-ci error-tracking-upload-source-maps/ios
  • /wizard-ci error-tracking-upload-source-maps/next
  • /wizard-ci error-tracking-upload-source-maps/next-no-posthog
  • /wizard-ci error-tracking-upload-source-maps/node-raw
  • /wizard-ci error-tracking-upload-source-maps/node-rollup
  • /wizard-ci error-tracking-upload-source-maps/node-rollup-typescript-plugin
  • /wizard-ci error-tracking-upload-source-maps/node-webpack
  • /wizard-ci error-tracking-upload-source-maps/nuxt-3-6
  • /wizard-ci error-tracking-upload-source-maps/nuxt-4-3
  • /wizard-ci error-tracking-upload-source-maps/react-native
  • /wizard-ci error-tracking-upload-source-maps/react-vite
  • /wizard-ci error-tracking-upload-source-maps/rust
  • /wizard-ci misc/quack-quack
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

Comment thread src/utils/urls.ts
return 'http://localhost:8010';
}

if (host.includes('eu.posthog.com') || host.includes('eu.i.posthog.com')) {
Comment thread src/utils/urls.ts
return 'http://localhost:8010';
}

if (host.includes('eu.posthog.com') || host.includes('eu.i.posthog.com')) {
@joethreepwood joethreepwood requested a review from edwinyjlim June 8, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants