Skip to content

feat: role-aware MCP tutorial with dialogue follow-ups and goodbye#508

Merged
edwinyjlim merged 14 commits into
mainfrom
personalization-role
Jun 5, 2026
Merged

feat: role-aware MCP tutorial with dialogue follow-ups and goodbye#508
edwinyjlim merged 14 commits into
mainfrom
personalization-role

Conversation

@joethreepwood
Copy link
Copy Markdown
Contributor

@joethreepwood joethreepwood commented Jun 4, 2026

Loom: https://www.loom.com/share/fa250e9521ae4d88a45505532bb51a61

Summary

  • Lights up the role + framework matrix in src/lib/mcp-role-prompts.ts (added in feat: Rebuild the MCP install + create role-tailored prompts screen #500 but never wired) and turns the MCP tutorial into a paced, role-tailored, branching conversation.
  • New phases — Greeting (role-tuned headline + bullets + outro), FollowUp (inline below run result, no auto-advance), Goodbye (final reminder on every dismissal).
  • Follow-up tree blends per-tool, per-role, generic, and late-tree deep-dive candidate pools, rotated by branch depth so repeat visits don't feel canned.

Why

The post-#500 tutorial captured role_at_organization from OAuth but never used it — every user saw the same STOCK_MCP_SUGGESTED_PROMPTS. This wires the role through end-to-end: kit, greeting copy, follow-up flavor. The Goodbye phase closes a recurring "wait, how do I use MCP now?" gap — users who exit the tutorial always leave with the names of their installed clients and 3 role-tailored starter prompts.

What changed

  • src/lib/mcp-role-prompts.ts:
    • getRoleGreeting(role) — returns headline / bullets / outro per TAILORED_ROLE with neutral fallback.
    • getFollowUps({ lastToolName, role, branchHistory, ... }) — expanded pools (5-6 per tool, new per-role set, 6 generic, deep-dive set at depth ≥ 3), MCP tool-name normalization (mcp__server__tooltool), depth-based rotation, history-based dedup.
    • FOLLOW_UP_COUNT, FOLLOW_UP_EXIT_SENTINEL exported.
  • src/ui/tui/screens/McpSuggestedPromptsScreen.tsx:
    • New phases: Greeting, FollowUp, Goodbye.
    • Picker now calls getRolePrompts(role, integration) — engineers get error/perf prompts, founders growth, PMs funnels, etc.
    • Running renders tool calls / results / errors as styled boxes; text chunks are plain (the stream itself is the reveal).
    • FollowUp renders the run result above the picker, so the user reads at their own pace. No POST_RUN_DELAY.
    • Goodbye reads session.mcpInstalledClients and shows 3 starter prompts from the role kit; falls back to a generic client list when standalone.
    • [enter] skips the auto-paced Greeting; PickerMenu owns Enter in picker phases (no double-fire).
    • MAX_PROMPT_RUNS bumped 3 → 5 so the conversation tree has room.
  • src/lib/__tests__/mcp-role-prompts.test.ts: +12 tests covering getRoleGreeting, follow-up pool composition, depth-based rotation, role-mixing variance, tool-name normalization, history-based dedup.
  • src/ui/tui/playground/demos/McpSuggestedPromptsDemo.tsx: docstring updated to call out the new phases (no behavior change).

Test plan

  • pnpm typecheck — clean
  • pnpm test — 740 / 740 passing
  • pnpm try --playgroundmcp-tutorial demo:
    • Cycle roles with R and confirm greeting copy + kit + follow-ups all change
    • Set S=with-tools, run a prompt, confirm FollowUp picker appears under the result with query-trends-flavored suggestions
    • Pick a follow-up; confirm next FollowUp shows different suggestions (depth rotation kicked in)
    • Exit at every entry point (Choose → Exit, [esc] mid-Greeting, mid-Running, FollowUp's "I'm done", [esc] from FollowUp) and confirm Goodbye phase fires each time
    • Confirm Goodbye lists Claude Code (the mocked installed client) and 3 role-tailored sample prompts
  • End-to-end (in wizard-workbench): wizard mcp tutorial --local against the local MCP, walk a real role through Greeting → Picker → Running → FollowUp → Goodbye

🤖 Generated with Claude Code

Lights up the role + framework matrix in mcp-role-prompts.ts (added in
#500 but never wired up) and turns the MCP tutorial into a paced,
role-tailored, branching conversation.

- Greeting phase between Auth and PromptPicker — role-tuned headline /
  bullets / outro for every TAILORED_ROLE plus a neutral fallback.
- PromptPicker now calls getRolePrompts(role, integration) so engineers
  see error/perf prompts, founders see growth prompts, etc.
- Running phase styles tool calls / results / errors as bordered boxes;
  text is plain (the chunk-by-chunk arrival is the reveal animation).
- FollowUp phase renders inline below the result, so the user reads at
  their own pace — no auto-advance timer. Follow-ups blend per-tool,
  per-role, generic, and late-tree deep-dive pools, rotated by branch
  depth so repeat visits surface different suggestions.
- Goodbye phase fires on every dismissal — names installed clients (or
  lists common ones if standalone), shows 3 starter prompts from the
  role kit, and points to "npx @posthog/wizard mcp tutorial" for
  re-running.
- [enter] skips the typewriter Greeting for returning users.

+12 tests in mcp-role-prompts.test.ts covering getRoleGreeting,
getFollowUps pool composition, depth-based rotation, MCP tool-name
normalization, and history-based deduplication.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

🧙 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.

@joethreepwood joethreepwood self-assigned this Jun 4, 2026
joethreepwood and others added 2 commits June 4, 2026 14:40
Two product-discovery beats added on top of the role-aware tutorial.

- After every tool-result chunk, render a one-line cross-product hint
  pointing the user at the underlying PostHog product. `query-trends`
  highlights pinning to a dashboard, `create-feature-flag` calls out the
  1M/month free tier, `execute-sql` plugs the data warehouse, etc.
  Each agent action becomes a quiet "did you know" without breaking
  flow. Implemented as getToolHint(toolName) → ToolHint with MCP-prefix
  normalization, rendered under tool-result in ChunkLine.
- Above the role kit in PromptPicker, prepend 2 role-tailored
  cross-sell prompts — engineers see error tracking + session replay
  demos, founders see replay + surveys, marketing sees replay + web
  analytics, etc. Labels are prefixed with "Try {Product} —" so they
  visually stand out in the shared picker. Picking one runs the same
  Streaming → FollowUp flow as a regular kit prompt, so the agent
  actually demos the product against the user's real data.

+7 tests in mcp-role-prompts.test.ts cover hint lookup + normalization,
neutral / role-specific cross-sell sets, and cross-role variance.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`runMcpPromptViaSdk` was calling the Claude Agent SDK without the env
vars that point it at the PostHog LLM gateway, so the SDK tried to
authenticate directly against Anthropic and 401'd with "Invalid
authentication credentials" the moment a user picked a prompt.

Mirror what `initializeAgent` does in agent-interface.ts: set
ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN / CLAUDE_CODE_OAUTH_TOKEN /
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS from the user's OAuth credentials
before calling query(). The host on the OAuth response feeds
getLlmGatewayUrlFromHost so the right regional gateway is used.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@edwinyjlim
Copy link
Copy Markdown
Member

i'm gonna get this out the door today, so we can have a v1 of personalized MCP tutorials

@edwinyjlim edwinyjlim merged commit 0c84e2f into main Jun 5, 2026
17 checks passed
@edwinyjlim edwinyjlim deleted the personalization-role branch June 5, 2026 20:14
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