Skip to content

Commit ac5c5f3

Browse files
committed
Developing the wizard
1 parent 9e385e6 commit ac5c5f3

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: Developing the wizard
3+
sidebar: Handbook
4+
showTitle: true
5+
---
6+
7+
Developers love the wizard: it's the fastest way to get a deep, correct integration of PostHog into their project, with none of the hallucinations that come from naive agent-based attempts.
8+
9+
## The wizard's architecture
10+
11+
The wizard is a CLI tool that runs locally in developers' projects.
12+
13+
It wraps the [Claude Agent SDK](https://platform.claude.com/docs/en/agent-sdk/overview) to perform the integration, reviewing project code and making edits as needed.
14+
15+
To direct the agent, the wizard uses the PostHog [MCP server](https://github.com/PostHog/posthog/tree/master/products/mcp) as a context provider. The MCP includes workflow prompts, documentation and example code to improve the correctness and completeness of the integration.
16+
17+
MCP content is derived from the PostHog [examples repository](https://github.com/PostHog/examples), which includes code snippets, documentation and prompts. The examples repo generates a zip file and manifest that determine's the URIs and structure for `prompts` and `resources`. Updating the examples repo will instantly update the MCP content.
18+
19+
## Developing the wizard
20+
21+
Use these prompts to get your agent started.
22+
23+
Get the repos:
24+
25+
```md
26+
27+
Clone these repositories:
28+
29+
https://github.com/PostHog/wizard-workbench
30+
https://github.com/PostHog/examples
31+
https://github.com/PostHog/wizard
32+
33+
(If you don't have it already, the PostHog repo includes the MCP server) https://github.com/PostHog/posthog
34+
35+
```
36+
37+
Configure the workbench to run the wizard and its local dependencies:
38+
39+
```md
40+
41+
Read the README.md file in the wizard-workbench repository. Configure a .env file with the paths to the repos.
42+
43+
```
44+
45+
With the workbench now configured, open a terminal at its root and run:
46+
47+
```bash
48+
mprocs
49+
```
50+
51+
This will start the workbench and all its dependencies:
52+
53+
- Making a change to the examples repo will instantly update the MCP content.
54+
- Editing the wizard's code will automatically rebuild and link the changes globally. Run it against any project on your machine with `wizard --local-mcp`.
55+
- Review the contents of the MCP server by selecting the **mcp-inspector** tab and opening the link it provides in your browser.
56+
57+
## Using the MCP inspector
58+
59+
You'll want the link that looks like this from the mcp-inspector tab:
60+
61+
```
62+
http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=97e0ba...
63+
```
64+
65+
Look for the text `Open inspector with token pre-filled.
66+
67+
Access the link in your browser, set the transport type to **Streamable HTTP**, and set the URL to **http://localhost:8787/mcp**. (Alternatively, you can also inspect the production MCP by setting the URL to **https://mcp.posthog.com/mcp**).
68+
69+
![MCP inspector](https://res.cloudinary.com/dmukukwp6/image/upload/q_auto,f_auto/Screenshot_2025_12_17_at_4_04_47_PM_df53b1ea2b.png)
70+
71+
You'll need a PostHog API key to access the MCP server. Get one from the [user API keys settings page](https://app.posthog.com/settings/user-api-keys?preset=mcp_server). Open the **Authentication** tab and paste the key into the **Bearer token** field.
72+
73+
Hit connect and you'll see the MCP server's contents.

contents/handbook/content/docs-runbook/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ We've built out extensive tooling to help us write docs. This page records how t
1313
| [Onboarding docs](/handbook/content/docs-runbook/onboarding-docs) | How to create and maintain shared onboarding documentation between the in-app flow and website |
1414
| [SDK reference docs](/handbook/content/docs-runbook/sdk-reference-docs) | How SDK reference documentation is generated and maintained |
1515
| [API specification](/handbook/content/docs-runbook/api-specification) | How to create and maintain the API specification |
16+
| [Developing the wizard](/handbook/content/docs-runbook/developing-the-wizard) | How to develop and extend the onboarding wizard |
1617

0 commit comments

Comments
 (0)