[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-posthog-testing-mcp-tools-locally":3,"mdc--pmdgvl-key":40,"related-org-posthog-testing-mcp-tools-locally":1865,"related-repo-posthog-testing-mcp-tools-locally":2038},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":11,"stars":25,"repoUrl":26,"updatedAt":27,"license":28,"forks":29,"topics":30,"repo":35,"sourceUrl":38,"mdContent":39},"testing-mcp-tools-locally","test managed migration MCP tools locally","Set up the local dev environment, seed data, and API keys to test the staff-only managed migrations MCP tools (managed-migrations-support-list, managed-migrations-support-get) end to end. Use when testing batch import support tooling, debugging MCP tool responses or discovery (tools not appearing), or verifying the support API before deploying. Covers the discovery gate: hidden scope, is_staff, user:read, and why wildcard keys and OAuth never work.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},"posthog","PostHog","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Fposthog.png",[12,16,19,22],{"name":13,"slug":14,"type":15},"Local Development","local-development","tag",{"name":17,"slug":18,"type":15},"Migration","migration",{"name":20,"slug":21,"type":15},"MCP","mcp",{"name":23,"slug":24,"type":15},"Testing","testing",59,"https:\u002F\u002Fgithub.com\u002FPostHog\u002Fai-plugin","2026-07-21T06:07:37.686545",null,11,[31,32,33,34],"claude-code-plugin","codex-plugin","cursor-plugin","gemini-cli-extension",{"repoUrl":26,"stars":25,"forks":29,"topics":36,"description":37},[31,32,33,34],"Official PostHog plugin for Claude Code, Cursor, Gemini, Codex and other AI coding tools","https:\u002F\u002Fgithub.com\u002FPostHog\u002Fai-plugin\u002Ftree\u002FHEAD\u002Fskills\u002Ftesting-mcp-tools-locally","---\nname: testing-mcp-tools-locally\ndescription: >\n  Set up the local dev environment, seed data, and API keys to test the staff-only managed migrations\n  MCP tools (managed-migrations-support-list, managed-migrations-support-get) end to end.\n  Use when testing batch import support tooling, debugging MCP tool responses or discovery\n  (tools not appearing), or verifying the support API before deploying.\n  Covers the discovery gate: hidden scope, is_staff, user:read, and why wildcard keys and OAuth never work.\n---\n\n# Testing managed migrations MCP tools locally\n\n## Prerequisites\n\nThe dev environment must be running with Docker services healthy.\nThe batch import support API and MCP tools require:\n\n- A staff user (`is_staff = True`)\n- A Personal API Key carrying **both** `batch_import_support:read` and `user:read`, explicitly\n- Postgres migrations applied (ClickHouse not required)\n\nWhy both scopes: the backend accepts `batch_import_support:read` alone,\nbut MCP tool discovery verifies staffness via `\u002Fapi\u002Fusers\u002F@me\u002F` and hides the tools (fail-closed) when the key cannot make that call.\nA `*` wildcard does **not** substitute for either — the discovery gate requires the hidden scope explicitly, and the backend's `INTERNAL` scope handling rejects wildcard keys outright.\nFor the production setup flow, see [docs\u002Fsupport-mcp-tools.md](..\u002F..\u002Fdocs\u002Fsupport-mcp-tools.md).\n\n## 1. Start the dev environment\n\n```bash\nhogli start -d\nhogli wait\n```\n\nIf `hogli wait` fails on `migrate-persons-db` or `migrate-behavioral-cohorts`,\nthose are optional separate databases — ignore them.\nIf it fails on `migrate-postgres`, check Docker port forwarding (see troubleshooting below).\n\n## 2. Run Postgres migrations\n\n```bash\nhogli migrations:run\n```\n\nClickHouse migration failures are fine — batch imports only need Postgres.\n\n## 3. Verify DB connectivity from the Django shell\n\n```bash\nhogli dev:shell-plus -y -- -c \"\nfrom posthog.models import Team, User\nprint(Team.objects.first(), User.objects.first())\n\"\n```\n\nIf this fails with `connection refused` on port 5432, see troubleshooting below.\n\n## 4. Seed batch import test data\n\nUse `hogli dev:shell-plus` to create `BatchImport` records in various states.\nThe `secrets` field is an `EncryptedJSONStringField` — empty `{}` serializes to null\nand violates the NOT NULL constraint; always pass a non-empty dict.\n\n```python\nfrom products.managed_migrations.backend.models.batch_imports import BatchImport\n\nBatchImport.objects.create(\n    team=team,\n    created_by_id=user.id,\n    status=BatchImport.Status.PAUSED,\n    import_config={\n        'source': {'type': 's3', 'bucket': 'test', 'region': 'us-east-1', 'prefix': 'data\u002F'},\n        'data_format': {'type': 'json_lines', 'skip_blanks': True, 'content': {'type': 'mixpanel'}},\n        'sink': {'type': 'capture'},\n    },\n    secrets={'access_key': 'test', 'secret_key': 'test'},\n    state={'parts': [\n        {'key': 'part-1', 'current_offset': 50000, 'total_size': 50000},\n        {'key': 'part-2', 'current_offset': 10000, 'total_size': 50000},\n        {'key': 'part-3'},\n    ]},\n)\n```\n\nSee `references\u002Fseed-data.md` for a full seeding script covering all statuses.\n\n**Important:** the local `batch-import-worker` process will pick up `RUNNING` records\nand may modify their status (e.g. pausing them due to config validation errors).\nTo keep records stable for testing, either stop the worker or use `COMPLETED`\u002F`FAILED`\u002F`PAUSED` statuses.\n\n## 5. Make your user staff and mint test keys\n\nMint **fresh** keys rather than editing scopes on an existing one —\nthe MCP server caches a key's scopes per token, so edited scopes can serve stale results.\n\n```python\nfrom posthog.models import User\nfrom posthog.models.personal_api_key import PersonalAPIKey\nfrom posthog.models.utils import generate_random_token_personal, hash_key_value\n\nme = User.objects.first()\nme.is_staff = True; me.save()\n\ndef mint(user, scopes):\n    token = generate_random_token_personal()\n    PersonalAPIKey.objects.create(user=user, label=str(scopes)[:40], secure_value=hash_key_value(token), scopes=scopes)\n    return token\n\nprint(mint(me, [\"batch_import_support:read\", \"user:read\"]))\n```\n\nTo test the negative cases of the discovery gate, also mint:\na `[\"*\"]` key (tools must NOT appear),\na `[\"batch_import_support:read\"]` key without `user:read` (tools must NOT appear — staff lookup fails closed),\nand the full pair on a non-staff user (tools must NOT appear).\n\n## 6. Test the API directly\n\n```bash\n# List all batch imports\ncurl -H \"Authorization: Bearer \u003Ctoken>\" \\\n     http:\u002F\u002Flocalhost:8010\u002Fapi\u002Fmanaged_migrations_support\u002F | jq\n\n# Get detail for a specific import\ncurl -H \"Authorization: Bearer \u003Ctoken>\" \\\n     http:\u002F\u002Flocalhost:8010\u002Fapi\u002Fmanaged_migrations_support\u002F\u003Cuuid>\u002F | jq\n```\n\n## 7. Test via MCP\n\n**Run the Hono server, not `pnpm run dev`.**\nThe wrangler worker (`pnpm run dev`, port 8787) proxies `\u002Fmcp` to **production** `mcp.us.posthog.com` unless `MCP_HONO_URL` is set,\nso local keys get `401 Invalid API key`.\nThe Hono server serves MCP directly against the local API:\n\n```bash\ncd services\u002Fmcp\ncp .dev.vars.example .dev.vars   # POSTHOG_API_BASE_URL=http:\u002F\u002Flocalhost:8010\npnpm run dev:hono                # serves http:\u002F\u002Flocalhost:3001\u002Fmcp\n```\n\n**Authenticate with the PAT as a Bearer header, never the OAuth flow.**\nThe hidden scope is structurally absent from OAuth — signing in through the inspector's OAuth login can never surface these tools.\n\nThe Hono server runs exec mode: `tools\u002Flist` returns a single `exec` tool,\nand real tools are discovered and invoked through it.\nTest with the MCP Inspector CLI:\n\n```bash\n# Discovery — should list both support tools for the staff key, none for the others\nnpx @modelcontextprotocol\u002Finspector --cli http:\u002F\u002Flocalhost:3001\u002Fmcp \\\n  --header \"Authorization: Bearer \u003Ctoken>\" \\\n  --method tools\u002Fcall --tool-name exec --tool-arg \"command=search managed-migrations-support\"\n\n# Invocation — end-to-end through Django\nnpx @modelcontextprotocol\u002Finspector --cli http:\u002F\u002Flocalhost:3001\u002Fmcp \\\n  --header \"Authorization: Bearer \u003Ctoken>\" \\\n  --method tools\u002Fcall --tool-name exec --tool-arg \"command=call managed-migrations-support-list {}\"\n```\n\nExpected discovery matrix:\n\n| key                                                         | tools visible                    |\n| ----------------------------------------------------------- | -------------------------------- |\n| staff user, `batch_import_support:read` + `user:read`       | both                             |\n| staff user, `*` only                                        | none                             |\n| staff user, `batch_import_support:read` without `user:read` | none (staff lookup fails closed) |\n| non-staff user, both scopes                                 | none (and direct API calls 403)  |\n\nThe interactive Inspector UI (`http:\u002F\u002Flocalhost:6274`) also works —\npaste the PAT as the Bearer token in connection settings instead of using its OAuth login.\n\n## Troubleshooting\n\n### 401 \"Invalid API key\" from localhost:8787\n\nYou're talking to the wrangler worker, which proxies `\u002Fmcp` to production — your local key is invalid there.\nUse the Hono server on port 3001 (see step 7), or set `MCP_HONO_URL=http:\u002F\u002Flocalhost:3001` in `.dev.vars`.\n\n### Tools don't appear for a key that should see them\n\nCheck, in order:\n\n1. The key carries `batch_import_support:read` **explicitly** — `*` does not match hidden scopes.\n2. The key also carries `user:read` (or `*`) — the discovery staff check reads `\u002Fapi\u002Fusers\u002F@me\u002F` and fails closed.\n3. The key's user has `is_staff = True`.\n4. The key was minted with those scopes from the start — the MCP server caches scopes per token, so mint a fresh key instead of editing an existing one.\n\n### Port 5432 not reachable from host\n\nThe `posthog-db-1` Docker container may have stale port mappings\n(container created days ago without the current port binding config).\nFix by force-recreating:\n\n```bash\ndocker compose -f docker-compose.dev.yml -f docker-compose.profiles.yml \\\n  up -d --force-recreate db\n```\n\nVerify: `nc -z 127.0.0.1 5432` should succeed.\n\n### `secrets={}` causes NOT NULL violation\n\n`EncryptedJSONStringField` encrypts the value — an empty dict serializes to null.\nAlways pass a non-empty dict: `secrets={'placeholder': 'true'}`.\n\n### Batch import worker modifies seeded records\n\nThe local `batch-import-worker` process automatically claims `RUNNING` records.\nIf it encounters a config validation error (e.g. missing `skip_blanks`),\nit will pause the import with a detailed Rust backtrace in `status_message`.\nStop the worker or seed with non-`RUNNING` statuses to prevent this.\n\n### The gates, end to end\n\nA request passes through two independent layers:\n\n1. **MCP discovery** (presentation): a tool requiring an OAuth-hidden scope surfaces only when the key explicitly carries the scope AND `\u002Fapi\u002Fusers\u002F@me\u002F` confirms `is_staff` — otherwise it is hidden, fail-closed (`services\u002Fmcp\u002Fsrc\u002Flib\u002Fstaff-only-tools.ts`).\n2. **Django enforcement** (the security boundary): `IsAuthenticated` + `IsStaffUser` + `APIScopePermission` with `scope_object = \"INTERNAL\"` and `batch_import_support:read`. Sessions need staffness only; PATs need staffness plus the explicit scope; `*`-only keys always 403.\n",{"data":41,"body":42},{"name":4,"description":6},{"type":43,"children":44},"root",[45,54,61,67,120,172,178,225,262,268,287,292,298,364,377,383,428,595,608,657,663,675,783,811,817,966,972,1034,1101,1111,1132,1336,1341,1449,1462,1468,1475,1502,1508,1513,1584,1590,1603,1669,1682,1694,1711,1717,1759,1765,1770,1859],{"type":46,"tag":47,"props":48,"children":50},"element","h1",{"id":49},"testing-managed-migrations-mcp-tools-locally",[51],{"type":52,"value":53},"text","Testing managed migrations MCP tools locally",{"type":46,"tag":55,"props":56,"children":58},"h2",{"id":57},"prerequisites",[59],{"type":52,"value":60},"Prerequisites",{"type":46,"tag":62,"props":63,"children":64},"p",{},[65],{"type":52,"value":66},"The dev environment must be running with Docker services healthy.\nThe batch import support API and MCP tools require:",{"type":46,"tag":68,"props":69,"children":70},"ul",{},[71,86,115],{"type":46,"tag":72,"props":73,"children":74},"li",{},[75,77,84],{"type":52,"value":76},"A staff user (",{"type":46,"tag":78,"props":79,"children":81},"code",{"className":80},[],[82],{"type":52,"value":83},"is_staff = True",{"type":52,"value":85},")",{"type":46,"tag":72,"props":87,"children":88},{},[89,91,97,99,105,107,113],{"type":52,"value":90},"A Personal API Key carrying ",{"type":46,"tag":92,"props":93,"children":94},"strong",{},[95],{"type":52,"value":96},"both",{"type":52,"value":98}," ",{"type":46,"tag":78,"props":100,"children":102},{"className":101},[],[103],{"type":52,"value":104},"batch_import_support:read",{"type":52,"value":106}," and ",{"type":46,"tag":78,"props":108,"children":110},{"className":109},[],[111],{"type":52,"value":112},"user:read",{"type":52,"value":114},", explicitly",{"type":46,"tag":72,"props":116,"children":117},{},[118],{"type":52,"value":119},"Postgres migrations applied (ClickHouse not required)",{"type":46,"tag":62,"props":121,"children":122},{},[123,125,130,132,138,140,146,148,153,155,161,163,170],{"type":52,"value":124},"Why both scopes: the backend accepts ",{"type":46,"tag":78,"props":126,"children":128},{"className":127},[],[129],{"type":52,"value":104},{"type":52,"value":131}," alone,\nbut MCP tool discovery verifies staffness via ",{"type":46,"tag":78,"props":133,"children":135},{"className":134},[],[136],{"type":52,"value":137},"\u002Fapi\u002Fusers\u002F@me\u002F",{"type":52,"value":139}," and hides the tools (fail-closed) when the key cannot make that call.\nA ",{"type":46,"tag":78,"props":141,"children":143},{"className":142},[],[144],{"type":52,"value":145},"*",{"type":52,"value":147}," wildcard does ",{"type":46,"tag":92,"props":149,"children":150},{},[151],{"type":52,"value":152},"not",{"type":52,"value":154}," substitute for either — the discovery gate requires the hidden scope explicitly, and the backend's ",{"type":46,"tag":78,"props":156,"children":158},{"className":157},[],[159],{"type":52,"value":160},"INTERNAL",{"type":52,"value":162}," scope handling rejects wildcard keys outright.\nFor the production setup flow, see ",{"type":46,"tag":164,"props":165,"children":167},"a",{"href":166},"..\u002F..\u002Fdocs\u002Fsupport-mcp-tools.md",[168],{"type":52,"value":169},"docs\u002Fsupport-mcp-tools.md",{"type":52,"value":171},".",{"type":46,"tag":55,"props":173,"children":175},{"id":174},"_1-start-the-dev-environment",[176],{"type":52,"value":177},"1. Start the dev environment",{"type":46,"tag":179,"props":180,"children":185},"pre",{"className":181,"code":182,"language":183,"meta":184,"style":184},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","hogli start -d\nhogli wait\n","bash","",[186],{"type":46,"tag":78,"props":187,"children":188},{"__ignoreMap":184},[189,212],{"type":46,"tag":190,"props":191,"children":194},"span",{"class":192,"line":193},"line",1,[195,201,207],{"type":46,"tag":190,"props":196,"children":198},{"style":197},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[199],{"type":52,"value":200},"hogli",{"type":46,"tag":190,"props":202,"children":204},{"style":203},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[205],{"type":52,"value":206}," start",{"type":46,"tag":190,"props":208,"children":209},{"style":203},[210],{"type":52,"value":211}," -d\n",{"type":46,"tag":190,"props":213,"children":215},{"class":192,"line":214},2,[216,220],{"type":46,"tag":190,"props":217,"children":218},{"style":197},[219],{"type":52,"value":200},{"type":46,"tag":190,"props":221,"children":222},{"style":203},[223],{"type":52,"value":224}," wait\n",{"type":46,"tag":62,"props":226,"children":227},{},[228,230,236,238,244,246,252,254,260],{"type":52,"value":229},"If ",{"type":46,"tag":78,"props":231,"children":233},{"className":232},[],[234],{"type":52,"value":235},"hogli wait",{"type":52,"value":237}," fails on ",{"type":46,"tag":78,"props":239,"children":241},{"className":240},[],[242],{"type":52,"value":243},"migrate-persons-db",{"type":52,"value":245}," or ",{"type":46,"tag":78,"props":247,"children":249},{"className":248},[],[250],{"type":52,"value":251},"migrate-behavioral-cohorts",{"type":52,"value":253},",\nthose are optional separate databases — ignore them.\nIf it fails on ",{"type":46,"tag":78,"props":255,"children":257},{"className":256},[],[258],{"type":52,"value":259},"migrate-postgres",{"type":52,"value":261},", check Docker port forwarding (see troubleshooting below).",{"type":46,"tag":55,"props":263,"children":265},{"id":264},"_2-run-postgres-migrations",[266],{"type":52,"value":267},"2. Run Postgres migrations",{"type":46,"tag":179,"props":269,"children":271},{"className":181,"code":270,"language":183,"meta":184,"style":184},"hogli migrations:run\n",[272],{"type":46,"tag":78,"props":273,"children":274},{"__ignoreMap":184},[275],{"type":46,"tag":190,"props":276,"children":277},{"class":192,"line":193},[278,282],{"type":46,"tag":190,"props":279,"children":280},{"style":197},[281],{"type":52,"value":200},{"type":46,"tag":190,"props":283,"children":284},{"style":203},[285],{"type":52,"value":286}," migrations:run\n",{"type":46,"tag":62,"props":288,"children":289},{},[290],{"type":52,"value":291},"ClickHouse migration failures are fine — batch imports only need Postgres.",{"type":46,"tag":55,"props":293,"children":295},{"id":294},"_3-verify-db-connectivity-from-the-django-shell",[296],{"type":52,"value":297},"3. Verify DB connectivity from the Django shell",{"type":46,"tag":179,"props":299,"children":301},{"className":181,"code":300,"language":183,"meta":184,"style":184},"hogli dev:shell-plus -y -- -c \"\nfrom posthog.models import Team, User\nprint(Team.objects.first(), User.objects.first())\n\"\n",[302],{"type":46,"tag":78,"props":303,"children":304},{"__ignoreMap":184},[305,338,346,355],{"type":46,"tag":190,"props":306,"children":307},{"class":192,"line":193},[308,312,317,322,327,332],{"type":46,"tag":190,"props":309,"children":310},{"style":197},[311],{"type":52,"value":200},{"type":46,"tag":190,"props":313,"children":314},{"style":203},[315],{"type":52,"value":316}," dev:shell-plus",{"type":46,"tag":190,"props":318,"children":319},{"style":203},[320],{"type":52,"value":321}," -y",{"type":46,"tag":190,"props":323,"children":324},{"style":203},[325],{"type":52,"value":326}," --",{"type":46,"tag":190,"props":328,"children":329},{"style":203},[330],{"type":52,"value":331}," -c",{"type":46,"tag":190,"props":333,"children":335},{"style":334},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[336],{"type":52,"value":337}," \"\n",{"type":46,"tag":190,"props":339,"children":340},{"class":192,"line":214},[341],{"type":46,"tag":190,"props":342,"children":343},{"style":203},[344],{"type":52,"value":345},"from posthog.models import Team, User\n",{"type":46,"tag":190,"props":347,"children":349},{"class":192,"line":348},3,[350],{"type":46,"tag":190,"props":351,"children":352},{"style":203},[353],{"type":52,"value":354},"print(Team.objects.first(), User.objects.first())\n",{"type":46,"tag":190,"props":356,"children":358},{"class":192,"line":357},4,[359],{"type":46,"tag":190,"props":360,"children":361},{"style":334},[362],{"type":52,"value":363},"\"\n",{"type":46,"tag":62,"props":365,"children":366},{},[367,369,375],{"type":52,"value":368},"If this fails with ",{"type":46,"tag":78,"props":370,"children":372},{"className":371},[],[373],{"type":52,"value":374},"connection refused",{"type":52,"value":376}," on port 5432, see troubleshooting below.",{"type":46,"tag":55,"props":378,"children":380},{"id":379},"_4-seed-batch-import-test-data",[381],{"type":52,"value":382},"4. Seed batch import test data",{"type":46,"tag":62,"props":384,"children":385},{},[386,388,394,396,402,404,410,412,418,420,426],{"type":52,"value":387},"Use ",{"type":46,"tag":78,"props":389,"children":391},{"className":390},[],[392],{"type":52,"value":393},"hogli dev:shell-plus",{"type":52,"value":395}," to create ",{"type":46,"tag":78,"props":397,"children":399},{"className":398},[],[400],{"type":52,"value":401},"BatchImport",{"type":52,"value":403}," records in various states.\nThe ",{"type":46,"tag":78,"props":405,"children":407},{"className":406},[],[408],{"type":52,"value":409},"secrets",{"type":52,"value":411}," field is an ",{"type":46,"tag":78,"props":413,"children":415},{"className":414},[],[416],{"type":52,"value":417},"EncryptedJSONStringField",{"type":52,"value":419}," — empty ",{"type":46,"tag":78,"props":421,"children":423},{"className":422},[],[424],{"type":52,"value":425},"{}",{"type":52,"value":427}," serializes to null\nand violates the NOT NULL constraint; always pass a non-empty dict.",{"type":46,"tag":179,"props":429,"children":433},{"className":430,"code":431,"language":432,"meta":184,"style":184},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","from products.managed_migrations.backend.models.batch_imports import BatchImport\n\nBatchImport.objects.create(\n    team=team,\n    created_by_id=user.id,\n    status=BatchImport.Status.PAUSED,\n    import_config={\n        'source': {'type': 's3', 'bucket': 'test', 'region': 'us-east-1', 'prefix': 'data\u002F'},\n        'data_format': {'type': 'json_lines', 'skip_blanks': True, 'content': {'type': 'mixpanel'}},\n        'sink': {'type': 'capture'},\n    },\n    secrets={'access_key': 'test', 'secret_key': 'test'},\n    state={'parts': [\n        {'key': 'part-1', 'current_offset': 50000, 'total_size': 50000},\n        {'key': 'part-2', 'current_offset': 10000, 'total_size': 50000},\n        {'key': 'part-3'},\n    ]},\n)\n","python",[434],{"type":46,"tag":78,"props":435,"children":436},{"__ignoreMap":184},[437,445,454,462,470,479,488,497,506,515,524,532,541,550,559,568,577,586],{"type":46,"tag":190,"props":438,"children":439},{"class":192,"line":193},[440],{"type":46,"tag":190,"props":441,"children":442},{},[443],{"type":52,"value":444},"from products.managed_migrations.backend.models.batch_imports import BatchImport\n",{"type":46,"tag":190,"props":446,"children":447},{"class":192,"line":214},[448],{"type":46,"tag":190,"props":449,"children":451},{"emptyLinePlaceholder":450},true,[452],{"type":52,"value":453},"\n",{"type":46,"tag":190,"props":455,"children":456},{"class":192,"line":348},[457],{"type":46,"tag":190,"props":458,"children":459},{},[460],{"type":52,"value":461},"BatchImport.objects.create(\n",{"type":46,"tag":190,"props":463,"children":464},{"class":192,"line":357},[465],{"type":46,"tag":190,"props":466,"children":467},{},[468],{"type":52,"value":469},"    team=team,\n",{"type":46,"tag":190,"props":471,"children":473},{"class":192,"line":472},5,[474],{"type":46,"tag":190,"props":475,"children":476},{},[477],{"type":52,"value":478},"    created_by_id=user.id,\n",{"type":46,"tag":190,"props":480,"children":482},{"class":192,"line":481},6,[483],{"type":46,"tag":190,"props":484,"children":485},{},[486],{"type":52,"value":487},"    status=BatchImport.Status.PAUSED,\n",{"type":46,"tag":190,"props":489,"children":491},{"class":192,"line":490},7,[492],{"type":46,"tag":190,"props":493,"children":494},{},[495],{"type":52,"value":496},"    import_config={\n",{"type":46,"tag":190,"props":498,"children":500},{"class":192,"line":499},8,[501],{"type":46,"tag":190,"props":502,"children":503},{},[504],{"type":52,"value":505},"        'source': {'type': 's3', 'bucket': 'test', 'region': 'us-east-1', 'prefix': 'data\u002F'},\n",{"type":46,"tag":190,"props":507,"children":509},{"class":192,"line":508},9,[510],{"type":46,"tag":190,"props":511,"children":512},{},[513],{"type":52,"value":514},"        'data_format': {'type': 'json_lines', 'skip_blanks': True, 'content': {'type': 'mixpanel'}},\n",{"type":46,"tag":190,"props":516,"children":518},{"class":192,"line":517},10,[519],{"type":46,"tag":190,"props":520,"children":521},{},[522],{"type":52,"value":523},"        'sink': {'type': 'capture'},\n",{"type":46,"tag":190,"props":525,"children":526},{"class":192,"line":29},[527],{"type":46,"tag":190,"props":528,"children":529},{},[530],{"type":52,"value":531},"    },\n",{"type":46,"tag":190,"props":533,"children":535},{"class":192,"line":534},12,[536],{"type":46,"tag":190,"props":537,"children":538},{},[539],{"type":52,"value":540},"    secrets={'access_key': 'test', 'secret_key': 'test'},\n",{"type":46,"tag":190,"props":542,"children":544},{"class":192,"line":543},13,[545],{"type":46,"tag":190,"props":546,"children":547},{},[548],{"type":52,"value":549},"    state={'parts': [\n",{"type":46,"tag":190,"props":551,"children":553},{"class":192,"line":552},14,[554],{"type":46,"tag":190,"props":555,"children":556},{},[557],{"type":52,"value":558},"        {'key': 'part-1', 'current_offset': 50000, 'total_size': 50000},\n",{"type":46,"tag":190,"props":560,"children":562},{"class":192,"line":561},15,[563],{"type":46,"tag":190,"props":564,"children":565},{},[566],{"type":52,"value":567},"        {'key': 'part-2', 'current_offset': 10000, 'total_size': 50000},\n",{"type":46,"tag":190,"props":569,"children":571},{"class":192,"line":570},16,[572],{"type":46,"tag":190,"props":573,"children":574},{},[575],{"type":52,"value":576},"        {'key': 'part-3'},\n",{"type":46,"tag":190,"props":578,"children":580},{"class":192,"line":579},17,[581],{"type":46,"tag":190,"props":582,"children":583},{},[584],{"type":52,"value":585},"    ]},\n",{"type":46,"tag":190,"props":587,"children":589},{"class":192,"line":588},18,[590],{"type":46,"tag":190,"props":591,"children":592},{},[593],{"type":52,"value":594},")\n",{"type":46,"tag":62,"props":596,"children":597},{},[598,600,606],{"type":52,"value":599},"See ",{"type":46,"tag":78,"props":601,"children":603},{"className":602},[],[604],{"type":52,"value":605},"references\u002Fseed-data.md",{"type":52,"value":607}," for a full seeding script covering all statuses.",{"type":46,"tag":62,"props":609,"children":610},{},[611,616,618,624,626,632,634,640,642,648,649,655],{"type":46,"tag":92,"props":612,"children":613},{},[614],{"type":52,"value":615},"Important:",{"type":52,"value":617}," the local ",{"type":46,"tag":78,"props":619,"children":621},{"className":620},[],[622],{"type":52,"value":623},"batch-import-worker",{"type":52,"value":625}," process will pick up ",{"type":46,"tag":78,"props":627,"children":629},{"className":628},[],[630],{"type":52,"value":631},"RUNNING",{"type":52,"value":633}," records\nand may modify their status (e.g. pausing them due to config validation errors).\nTo keep records stable for testing, either stop the worker or use ",{"type":46,"tag":78,"props":635,"children":637},{"className":636},[],[638],{"type":52,"value":639},"COMPLETED",{"type":52,"value":641},"\u002F",{"type":46,"tag":78,"props":643,"children":645},{"className":644},[],[646],{"type":52,"value":647},"FAILED",{"type":52,"value":641},{"type":46,"tag":78,"props":650,"children":652},{"className":651},[],[653],{"type":52,"value":654},"PAUSED",{"type":52,"value":656}," statuses.",{"type":46,"tag":55,"props":658,"children":660},{"id":659},"_5-make-your-user-staff-and-mint-test-keys",[661],{"type":52,"value":662},"5. Make your user staff and mint test keys",{"type":46,"tag":62,"props":664,"children":665},{},[666,668,673],{"type":52,"value":667},"Mint ",{"type":46,"tag":92,"props":669,"children":670},{},[671],{"type":52,"value":672},"fresh",{"type":52,"value":674}," keys rather than editing scopes on an existing one —\nthe MCP server caches a key's scopes per token, so edited scopes can serve stale results.",{"type":46,"tag":179,"props":676,"children":678},{"className":430,"code":677,"language":432,"meta":184,"style":184},"from posthog.models import User\nfrom posthog.models.personal_api_key import PersonalAPIKey\nfrom posthog.models.utils import generate_random_token_personal, hash_key_value\n\nme = User.objects.first()\nme.is_staff = True; me.save()\n\ndef mint(user, scopes):\n    token = generate_random_token_personal()\n    PersonalAPIKey.objects.create(user=user, label=str(scopes)[:40], secure_value=hash_key_value(token), scopes=scopes)\n    return token\n\nprint(mint(me, [\"batch_import_support:read\", \"user:read\"]))\n",[679],{"type":46,"tag":78,"props":680,"children":681},{"__ignoreMap":184},[682,690,698,706,713,721,729,736,744,752,760,768,775],{"type":46,"tag":190,"props":683,"children":684},{"class":192,"line":193},[685],{"type":46,"tag":190,"props":686,"children":687},{},[688],{"type":52,"value":689},"from posthog.models import User\n",{"type":46,"tag":190,"props":691,"children":692},{"class":192,"line":214},[693],{"type":46,"tag":190,"props":694,"children":695},{},[696],{"type":52,"value":697},"from posthog.models.personal_api_key import PersonalAPIKey\n",{"type":46,"tag":190,"props":699,"children":700},{"class":192,"line":348},[701],{"type":46,"tag":190,"props":702,"children":703},{},[704],{"type":52,"value":705},"from posthog.models.utils import generate_random_token_personal, hash_key_value\n",{"type":46,"tag":190,"props":707,"children":708},{"class":192,"line":357},[709],{"type":46,"tag":190,"props":710,"children":711},{"emptyLinePlaceholder":450},[712],{"type":52,"value":453},{"type":46,"tag":190,"props":714,"children":715},{"class":192,"line":472},[716],{"type":46,"tag":190,"props":717,"children":718},{},[719],{"type":52,"value":720},"me = User.objects.first()\n",{"type":46,"tag":190,"props":722,"children":723},{"class":192,"line":481},[724],{"type":46,"tag":190,"props":725,"children":726},{},[727],{"type":52,"value":728},"me.is_staff = True; me.save()\n",{"type":46,"tag":190,"props":730,"children":731},{"class":192,"line":490},[732],{"type":46,"tag":190,"props":733,"children":734},{"emptyLinePlaceholder":450},[735],{"type":52,"value":453},{"type":46,"tag":190,"props":737,"children":738},{"class":192,"line":499},[739],{"type":46,"tag":190,"props":740,"children":741},{},[742],{"type":52,"value":743},"def mint(user, scopes):\n",{"type":46,"tag":190,"props":745,"children":746},{"class":192,"line":508},[747],{"type":46,"tag":190,"props":748,"children":749},{},[750],{"type":52,"value":751},"    token = generate_random_token_personal()\n",{"type":46,"tag":190,"props":753,"children":754},{"class":192,"line":517},[755],{"type":46,"tag":190,"props":756,"children":757},{},[758],{"type":52,"value":759},"    PersonalAPIKey.objects.create(user=user, label=str(scopes)[:40], secure_value=hash_key_value(token), scopes=scopes)\n",{"type":46,"tag":190,"props":761,"children":762},{"class":192,"line":29},[763],{"type":46,"tag":190,"props":764,"children":765},{},[766],{"type":52,"value":767},"    return token\n",{"type":46,"tag":190,"props":769,"children":770},{"class":192,"line":534},[771],{"type":46,"tag":190,"props":772,"children":773},{"emptyLinePlaceholder":450},[774],{"type":52,"value":453},{"type":46,"tag":190,"props":776,"children":777},{"class":192,"line":543},[778],{"type":46,"tag":190,"props":779,"children":780},{},[781],{"type":52,"value":782},"print(mint(me, [\"batch_import_support:read\", \"user:read\"]))\n",{"type":46,"tag":62,"props":784,"children":785},{},[786,788,794,796,802,804,809],{"type":52,"value":787},"To test the negative cases of the discovery gate, also mint:\na ",{"type":46,"tag":78,"props":789,"children":791},{"className":790},[],[792],{"type":52,"value":793},"[\"*\"]",{"type":52,"value":795}," key (tools must NOT appear),\na ",{"type":46,"tag":78,"props":797,"children":799},{"className":798},[],[800],{"type":52,"value":801},"[\"batch_import_support:read\"]",{"type":52,"value":803}," key without ",{"type":46,"tag":78,"props":805,"children":807},{"className":806},[],[808],{"type":52,"value":112},{"type":52,"value":810}," (tools must NOT appear — staff lookup fails closed),\nand the full pair on a non-staff user (tools must NOT appear).",{"type":46,"tag":55,"props":812,"children":814},{"id":813},"_6-test-the-api-directly",[815],{"type":52,"value":816},"6. Test the API directly",{"type":46,"tag":179,"props":818,"children":820},{"className":181,"code":819,"language":183,"meta":184,"style":184},"# List all batch imports\ncurl -H \"Authorization: Bearer \u003Ctoken>\" \\\n     http:\u002F\u002Flocalhost:8010\u002Fapi\u002Fmanaged_migrations_support\u002F | jq\n\n# Get detail for a specific import\ncurl -H \"Authorization: Bearer \u003Ctoken>\" \\\n     http:\u002F\u002Flocalhost:8010\u002Fapi\u002Fmanaged_migrations_support\u002F\u003Cuuid>\u002F | jq\n",[821],{"type":46,"tag":78,"props":822,"children":823},{"__ignoreMap":184},[824,833,867,885,892,900,927],{"type":46,"tag":190,"props":825,"children":826},{"class":192,"line":193},[827],{"type":46,"tag":190,"props":828,"children":830},{"style":829},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[831],{"type":52,"value":832},"# List all batch imports\n",{"type":46,"tag":190,"props":834,"children":835},{"class":192,"line":214},[836,841,846,851,856,861],{"type":46,"tag":190,"props":837,"children":838},{"style":197},[839],{"type":52,"value":840},"curl",{"type":46,"tag":190,"props":842,"children":843},{"style":203},[844],{"type":52,"value":845}," -H",{"type":46,"tag":190,"props":847,"children":848},{"style":334},[849],{"type":52,"value":850}," \"",{"type":46,"tag":190,"props":852,"children":853},{"style":203},[854],{"type":52,"value":855},"Authorization: Bearer \u003Ctoken>",{"type":46,"tag":190,"props":857,"children":858},{"style":334},[859],{"type":52,"value":860},"\"",{"type":46,"tag":190,"props":862,"children":864},{"style":863},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[865],{"type":52,"value":866}," \\\n",{"type":46,"tag":190,"props":868,"children":869},{"class":192,"line":348},[870,875,880],{"type":46,"tag":190,"props":871,"children":872},{"style":203},[873],{"type":52,"value":874},"     http:\u002F\u002Flocalhost:8010\u002Fapi\u002Fmanaged_migrations_support\u002F",{"type":46,"tag":190,"props":876,"children":877},{"style":334},[878],{"type":52,"value":879}," |",{"type":46,"tag":190,"props":881,"children":882},{"style":197},[883],{"type":52,"value":884}," jq\n",{"type":46,"tag":190,"props":886,"children":887},{"class":192,"line":357},[888],{"type":46,"tag":190,"props":889,"children":890},{"emptyLinePlaceholder":450},[891],{"type":52,"value":453},{"type":46,"tag":190,"props":893,"children":894},{"class":192,"line":472},[895],{"type":46,"tag":190,"props":896,"children":897},{"style":829},[898],{"type":52,"value":899},"# Get detail for a specific import\n",{"type":46,"tag":190,"props":901,"children":902},{"class":192,"line":481},[903,907,911,915,919,923],{"type":46,"tag":190,"props":904,"children":905},{"style":197},[906],{"type":52,"value":840},{"type":46,"tag":190,"props":908,"children":909},{"style":203},[910],{"type":52,"value":845},{"type":46,"tag":190,"props":912,"children":913},{"style":334},[914],{"type":52,"value":850},{"type":46,"tag":190,"props":916,"children":917},{"style":203},[918],{"type":52,"value":855},{"type":46,"tag":190,"props":920,"children":921},{"style":334},[922],{"type":52,"value":860},{"type":46,"tag":190,"props":924,"children":925},{"style":863},[926],{"type":52,"value":866},{"type":46,"tag":190,"props":928,"children":929},{"class":192,"line":490},[930,934,939,944,949,954,958,962],{"type":46,"tag":190,"props":931,"children":932},{"style":203},[933],{"type":52,"value":874},{"type":46,"tag":190,"props":935,"children":936},{"style":334},[937],{"type":52,"value":938},"\u003C",{"type":46,"tag":190,"props":940,"children":941},{"style":203},[942],{"type":52,"value":943},"uui",{"type":46,"tag":190,"props":945,"children":946},{"style":863},[947],{"type":52,"value":948},"d",{"type":46,"tag":190,"props":950,"children":951},{"style":334},[952],{"type":52,"value":953},">",{"type":46,"tag":190,"props":955,"children":956},{"style":203},[957],{"type":52,"value":641},{"type":46,"tag":190,"props":959,"children":960},{"style":334},[961],{"type":52,"value":879},{"type":46,"tag":190,"props":963,"children":964},{"style":197},[965],{"type":52,"value":884},{"type":46,"tag":55,"props":967,"children":969},{"id":968},"_7-test-via-mcp",[970],{"type":52,"value":971},"7. Test via MCP",{"type":46,"tag":62,"props":973,"children":974},{},[975,987,989,994,996,1002,1004,1009,1010,1016,1018,1024,1026,1032],{"type":46,"tag":92,"props":976,"children":977},{},[978,980,986],{"type":52,"value":979},"Run the Hono server, not ",{"type":46,"tag":78,"props":981,"children":983},{"className":982},[],[984],{"type":52,"value":985},"pnpm run dev",{"type":52,"value":171},{"type":52,"value":988},"\nThe wrangler worker (",{"type":46,"tag":78,"props":990,"children":992},{"className":991},[],[993],{"type":52,"value":985},{"type":52,"value":995},", port 8787) proxies ",{"type":46,"tag":78,"props":997,"children":999},{"className":998},[],[1000],{"type":52,"value":1001},"\u002Fmcp",{"type":52,"value":1003}," to ",{"type":46,"tag":92,"props":1005,"children":1006},{},[1007],{"type":52,"value":1008},"production",{"type":52,"value":98},{"type":46,"tag":78,"props":1011,"children":1013},{"className":1012},[],[1014],{"type":52,"value":1015},"mcp.us.posthog.com",{"type":52,"value":1017}," unless ",{"type":46,"tag":78,"props":1019,"children":1021},{"className":1020},[],[1022],{"type":52,"value":1023},"MCP_HONO_URL",{"type":52,"value":1025}," is set,\nso local keys get ",{"type":46,"tag":78,"props":1027,"children":1029},{"className":1028},[],[1030],{"type":52,"value":1031},"401 Invalid API key",{"type":52,"value":1033},".\nThe Hono server serves MCP directly against the local API:",{"type":46,"tag":179,"props":1035,"children":1037},{"className":181,"code":1036,"language":183,"meta":184,"style":184},"cd services\u002Fmcp\ncp .dev.vars.example .dev.vars   # POSTHOG_API_BASE_URL=http:\u002F\u002Flocalhost:8010\npnpm run dev:hono                # serves http:\u002F\u002Flocalhost:3001\u002Fmcp\n",[1038],{"type":46,"tag":78,"props":1039,"children":1040},{"__ignoreMap":184},[1041,1055,1078],{"type":46,"tag":190,"props":1042,"children":1043},{"class":192,"line":193},[1044,1050],{"type":46,"tag":190,"props":1045,"children":1047},{"style":1046},"--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF",[1048],{"type":52,"value":1049},"cd",{"type":46,"tag":190,"props":1051,"children":1052},{"style":203},[1053],{"type":52,"value":1054}," services\u002Fmcp\n",{"type":46,"tag":190,"props":1056,"children":1057},{"class":192,"line":214},[1058,1063,1068,1073],{"type":46,"tag":190,"props":1059,"children":1060},{"style":197},[1061],{"type":52,"value":1062},"cp",{"type":46,"tag":190,"props":1064,"children":1065},{"style":203},[1066],{"type":52,"value":1067}," .dev.vars.example",{"type":46,"tag":190,"props":1069,"children":1070},{"style":203},[1071],{"type":52,"value":1072}," .dev.vars",{"type":46,"tag":190,"props":1074,"children":1075},{"style":829},[1076],{"type":52,"value":1077},"   # POSTHOG_API_BASE_URL=http:\u002F\u002Flocalhost:8010\n",{"type":46,"tag":190,"props":1079,"children":1080},{"class":192,"line":348},[1081,1086,1091,1096],{"type":46,"tag":190,"props":1082,"children":1083},{"style":197},[1084],{"type":52,"value":1085},"pnpm",{"type":46,"tag":190,"props":1087,"children":1088},{"style":203},[1089],{"type":52,"value":1090}," run",{"type":46,"tag":190,"props":1092,"children":1093},{"style":203},[1094],{"type":52,"value":1095}," dev:hono",{"type":46,"tag":190,"props":1097,"children":1098},{"style":829},[1099],{"type":52,"value":1100},"                # serves http:\u002F\u002Flocalhost:3001\u002Fmcp\n",{"type":46,"tag":62,"props":1102,"children":1103},{},[1104,1109],{"type":46,"tag":92,"props":1105,"children":1106},{},[1107],{"type":52,"value":1108},"Authenticate with the PAT as a Bearer header, never the OAuth flow.",{"type":52,"value":1110},"\nThe hidden scope is structurally absent from OAuth — signing in through the inspector's OAuth login can never surface these tools.",{"type":46,"tag":62,"props":1112,"children":1113},{},[1114,1116,1122,1124,1130],{"type":52,"value":1115},"The Hono server runs exec mode: ",{"type":46,"tag":78,"props":1117,"children":1119},{"className":1118},[],[1120],{"type":52,"value":1121},"tools\u002Flist",{"type":52,"value":1123}," returns a single ",{"type":46,"tag":78,"props":1125,"children":1127},{"className":1126},[],[1128],{"type":52,"value":1129},"exec",{"type":52,"value":1131}," tool,\nand real tools are discovered and invoked through it.\nTest with the MCP Inspector CLI:",{"type":46,"tag":179,"props":1133,"children":1135},{"className":181,"code":1134,"language":183,"meta":184,"style":184},"# Discovery — should list both support tools for the staff key, none for the others\nnpx @modelcontextprotocol\u002Finspector --cli http:\u002F\u002Flocalhost:3001\u002Fmcp \\\n  --header \"Authorization: Bearer \u003Ctoken>\" \\\n  --method tools\u002Fcall --tool-name exec --tool-arg \"command=search managed-migrations-support\"\n\n# Invocation — end-to-end through Django\nnpx @modelcontextprotocol\u002Finspector --cli http:\u002F\u002Flocalhost:3001\u002Fmcp \\\n  --header \"Authorization: Bearer \u003Ctoken>\" \\\n  --method tools\u002Fcall --tool-name exec --tool-arg \"command=call managed-migrations-support-list {}\"\n",[1136],{"type":46,"tag":78,"props":1137,"children":1138},{"__ignoreMap":184},[1139,1147,1174,1198,1239,1246,1254,1277,1300],{"type":46,"tag":190,"props":1140,"children":1141},{"class":192,"line":193},[1142],{"type":46,"tag":190,"props":1143,"children":1144},{"style":829},[1145],{"type":52,"value":1146},"# Discovery — should list both support tools for the staff key, none for the others\n",{"type":46,"tag":190,"props":1148,"children":1149},{"class":192,"line":214},[1150,1155,1160,1165,1170],{"type":46,"tag":190,"props":1151,"children":1152},{"style":197},[1153],{"type":52,"value":1154},"npx",{"type":46,"tag":190,"props":1156,"children":1157},{"style":203},[1158],{"type":52,"value":1159}," @modelcontextprotocol\u002Finspector",{"type":46,"tag":190,"props":1161,"children":1162},{"style":203},[1163],{"type":52,"value":1164}," --cli",{"type":46,"tag":190,"props":1166,"children":1167},{"style":203},[1168],{"type":52,"value":1169}," http:\u002F\u002Flocalhost:3001\u002Fmcp",{"type":46,"tag":190,"props":1171,"children":1172},{"style":863},[1173],{"type":52,"value":866},{"type":46,"tag":190,"props":1175,"children":1176},{"class":192,"line":348},[1177,1182,1186,1190,1194],{"type":46,"tag":190,"props":1178,"children":1179},{"style":203},[1180],{"type":52,"value":1181},"  --header",{"type":46,"tag":190,"props":1183,"children":1184},{"style":334},[1185],{"type":52,"value":850},{"type":46,"tag":190,"props":1187,"children":1188},{"style":203},[1189],{"type":52,"value":855},{"type":46,"tag":190,"props":1191,"children":1192},{"style":334},[1193],{"type":52,"value":860},{"type":46,"tag":190,"props":1195,"children":1196},{"style":863},[1197],{"type":52,"value":866},{"type":46,"tag":190,"props":1199,"children":1200},{"class":192,"line":357},[1201,1206,1211,1216,1221,1226,1230,1235],{"type":46,"tag":190,"props":1202,"children":1203},{"style":203},[1204],{"type":52,"value":1205},"  --method",{"type":46,"tag":190,"props":1207,"children":1208},{"style":203},[1209],{"type":52,"value":1210}," tools\u002Fcall",{"type":46,"tag":190,"props":1212,"children":1213},{"style":203},[1214],{"type":52,"value":1215}," --tool-name",{"type":46,"tag":190,"props":1217,"children":1218},{"style":203},[1219],{"type":52,"value":1220}," exec",{"type":46,"tag":190,"props":1222,"children":1223},{"style":203},[1224],{"type":52,"value":1225}," --tool-arg",{"type":46,"tag":190,"props":1227,"children":1228},{"style":334},[1229],{"type":52,"value":850},{"type":46,"tag":190,"props":1231,"children":1232},{"style":203},[1233],{"type":52,"value":1234},"command=search managed-migrations-support",{"type":46,"tag":190,"props":1236,"children":1237},{"style":334},[1238],{"type":52,"value":363},{"type":46,"tag":190,"props":1240,"children":1241},{"class":192,"line":472},[1242],{"type":46,"tag":190,"props":1243,"children":1244},{"emptyLinePlaceholder":450},[1245],{"type":52,"value":453},{"type":46,"tag":190,"props":1247,"children":1248},{"class":192,"line":481},[1249],{"type":46,"tag":190,"props":1250,"children":1251},{"style":829},[1252],{"type":52,"value":1253},"# Invocation — end-to-end through Django\n",{"type":46,"tag":190,"props":1255,"children":1256},{"class":192,"line":490},[1257,1261,1265,1269,1273],{"type":46,"tag":190,"props":1258,"children":1259},{"style":197},[1260],{"type":52,"value":1154},{"type":46,"tag":190,"props":1262,"children":1263},{"style":203},[1264],{"type":52,"value":1159},{"type":46,"tag":190,"props":1266,"children":1267},{"style":203},[1268],{"type":52,"value":1164},{"type":46,"tag":190,"props":1270,"children":1271},{"style":203},[1272],{"type":52,"value":1169},{"type":46,"tag":190,"props":1274,"children":1275},{"style":863},[1276],{"type":52,"value":866},{"type":46,"tag":190,"props":1278,"children":1279},{"class":192,"line":499},[1280,1284,1288,1292,1296],{"type":46,"tag":190,"props":1281,"children":1282},{"style":203},[1283],{"type":52,"value":1181},{"type":46,"tag":190,"props":1285,"children":1286},{"style":334},[1287],{"type":52,"value":850},{"type":46,"tag":190,"props":1289,"children":1290},{"style":203},[1291],{"type":52,"value":855},{"type":46,"tag":190,"props":1293,"children":1294},{"style":334},[1295],{"type":52,"value":860},{"type":46,"tag":190,"props":1297,"children":1298},{"style":863},[1299],{"type":52,"value":866},{"type":46,"tag":190,"props":1301,"children":1302},{"class":192,"line":508},[1303,1307,1311,1315,1319,1323,1327,1332],{"type":46,"tag":190,"props":1304,"children":1305},{"style":203},[1306],{"type":52,"value":1205},{"type":46,"tag":190,"props":1308,"children":1309},{"style":203},[1310],{"type":52,"value":1210},{"type":46,"tag":190,"props":1312,"children":1313},{"style":203},[1314],{"type":52,"value":1215},{"type":46,"tag":190,"props":1316,"children":1317},{"style":203},[1318],{"type":52,"value":1220},{"type":46,"tag":190,"props":1320,"children":1321},{"style":203},[1322],{"type":52,"value":1225},{"type":46,"tag":190,"props":1324,"children":1325},{"style":334},[1326],{"type":52,"value":850},{"type":46,"tag":190,"props":1328,"children":1329},{"style":203},[1330],{"type":52,"value":1331},"command=call managed-migrations-support-list {}",{"type":46,"tag":190,"props":1333,"children":1334},{"style":334},[1335],{"type":52,"value":363},{"type":46,"tag":62,"props":1337,"children":1338},{},[1339],{"type":52,"value":1340},"Expected discovery matrix:",{"type":46,"tag":1342,"props":1343,"children":1344},"table",{},[1345,1364],{"type":46,"tag":1346,"props":1347,"children":1348},"thead",{},[1349],{"type":46,"tag":1350,"props":1351,"children":1352},"tr",{},[1353,1359],{"type":46,"tag":1354,"props":1355,"children":1356},"th",{},[1357],{"type":52,"value":1358},"key",{"type":46,"tag":1354,"props":1360,"children":1361},{},[1362],{"type":52,"value":1363},"tools visible",{"type":46,"tag":1365,"props":1366,"children":1367},"tbody",{},[1368,1393,1412,1436],{"type":46,"tag":1350,"props":1369,"children":1370},{},[1371,1389],{"type":46,"tag":1372,"props":1373,"children":1374},"td",{},[1375,1377,1382,1384],{"type":52,"value":1376},"staff user, ",{"type":46,"tag":78,"props":1378,"children":1380},{"className":1379},[],[1381],{"type":52,"value":104},{"type":52,"value":1383}," + ",{"type":46,"tag":78,"props":1385,"children":1387},{"className":1386},[],[1388],{"type":52,"value":112},{"type":46,"tag":1372,"props":1390,"children":1391},{},[1392],{"type":52,"value":96},{"type":46,"tag":1350,"props":1394,"children":1395},{},[1396,1407],{"type":46,"tag":1372,"props":1397,"children":1398},{},[1399,1400,1405],{"type":52,"value":1376},{"type":46,"tag":78,"props":1401,"children":1403},{"className":1402},[],[1404],{"type":52,"value":145},{"type":52,"value":1406}," only",{"type":46,"tag":1372,"props":1408,"children":1409},{},[1410],{"type":52,"value":1411},"none",{"type":46,"tag":1350,"props":1413,"children":1414},{},[1415,1431],{"type":46,"tag":1372,"props":1416,"children":1417},{},[1418,1419,1424,1426],{"type":52,"value":1376},{"type":46,"tag":78,"props":1420,"children":1422},{"className":1421},[],[1423],{"type":52,"value":104},{"type":52,"value":1425}," without ",{"type":46,"tag":78,"props":1427,"children":1429},{"className":1428},[],[1430],{"type":52,"value":112},{"type":46,"tag":1372,"props":1432,"children":1433},{},[1434],{"type":52,"value":1435},"none (staff lookup fails closed)",{"type":46,"tag":1350,"props":1437,"children":1438},{},[1439,1444],{"type":46,"tag":1372,"props":1440,"children":1441},{},[1442],{"type":52,"value":1443},"non-staff user, both scopes",{"type":46,"tag":1372,"props":1445,"children":1446},{},[1447],{"type":52,"value":1448},"none (and direct API calls 403)",{"type":46,"tag":62,"props":1450,"children":1451},{},[1452,1454,1460],{"type":52,"value":1453},"The interactive Inspector UI (",{"type":46,"tag":78,"props":1455,"children":1457},{"className":1456},[],[1458],{"type":52,"value":1459},"http:\u002F\u002Flocalhost:6274",{"type":52,"value":1461},") also works —\npaste the PAT as the Bearer token in connection settings instead of using its OAuth login.",{"type":46,"tag":55,"props":1463,"children":1465},{"id":1464},"troubleshooting",[1466],{"type":52,"value":1467},"Troubleshooting",{"type":46,"tag":1469,"props":1470,"children":1472},"h3",{"id":1471},"_401-invalid-api-key-from-localhost8787",[1473],{"type":52,"value":1474},"401 \"Invalid API key\" from localhost:8787",{"type":46,"tag":62,"props":1476,"children":1477},{},[1478,1480,1485,1487,1493,1495,1501],{"type":52,"value":1479},"You're talking to the wrangler worker, which proxies ",{"type":46,"tag":78,"props":1481,"children":1483},{"className":1482},[],[1484],{"type":52,"value":1001},{"type":52,"value":1486}," to production — your local key is invalid there.\nUse the Hono server on port 3001 (see step 7), or set ",{"type":46,"tag":78,"props":1488,"children":1490},{"className":1489},[],[1491],{"type":52,"value":1492},"MCP_HONO_URL=http:\u002F\u002Flocalhost:3001",{"type":52,"value":1494}," in ",{"type":46,"tag":78,"props":1496,"children":1498},{"className":1497},[],[1499],{"type":52,"value":1500},".dev.vars",{"type":52,"value":171},{"type":46,"tag":1469,"props":1503,"children":1505},{"id":1504},"tools-dont-appear-for-a-key-that-should-see-them",[1506],{"type":52,"value":1507},"Tools don't appear for a key that should see them",{"type":46,"tag":62,"props":1509,"children":1510},{},[1511],{"type":52,"value":1512},"Check, in order:",{"type":46,"tag":1514,"props":1515,"children":1516},"ol",{},[1517,1542,1568,1579],{"type":46,"tag":72,"props":1518,"children":1519},{},[1520,1522,1527,1528,1533,1535,1540],{"type":52,"value":1521},"The key carries ",{"type":46,"tag":78,"props":1523,"children":1525},{"className":1524},[],[1526],{"type":52,"value":104},{"type":52,"value":98},{"type":46,"tag":92,"props":1529,"children":1530},{},[1531],{"type":52,"value":1532},"explicitly",{"type":52,"value":1534}," — ",{"type":46,"tag":78,"props":1536,"children":1538},{"className":1537},[],[1539],{"type":52,"value":145},{"type":52,"value":1541}," does not match hidden scopes.",{"type":46,"tag":72,"props":1543,"children":1544},{},[1545,1547,1552,1554,1559,1561,1566],{"type":52,"value":1546},"The key also carries ",{"type":46,"tag":78,"props":1548,"children":1550},{"className":1549},[],[1551],{"type":52,"value":112},{"type":52,"value":1553}," (or ",{"type":46,"tag":78,"props":1555,"children":1557},{"className":1556},[],[1558],{"type":52,"value":145},{"type":52,"value":1560},") — the discovery staff check reads ",{"type":46,"tag":78,"props":1562,"children":1564},{"className":1563},[],[1565],{"type":52,"value":137},{"type":52,"value":1567}," and fails closed.",{"type":46,"tag":72,"props":1569,"children":1570},{},[1571,1573,1578],{"type":52,"value":1572},"The key's user has ",{"type":46,"tag":78,"props":1574,"children":1576},{"className":1575},[],[1577],{"type":52,"value":83},{"type":52,"value":171},{"type":46,"tag":72,"props":1580,"children":1581},{},[1582],{"type":52,"value":1583},"The key was minted with those scopes from the start — the MCP server caches scopes per token, so mint a fresh key instead of editing an existing one.",{"type":46,"tag":1469,"props":1585,"children":1587},{"id":1586},"port-5432-not-reachable-from-host",[1588],{"type":52,"value":1589},"Port 5432 not reachable from host",{"type":46,"tag":62,"props":1591,"children":1592},{},[1593,1595,1601],{"type":52,"value":1594},"The ",{"type":46,"tag":78,"props":1596,"children":1598},{"className":1597},[],[1599],{"type":52,"value":1600},"posthog-db-1",{"type":52,"value":1602}," Docker container may have stale port mappings\n(container created days ago without the current port binding config).\nFix by force-recreating:",{"type":46,"tag":179,"props":1604,"children":1606},{"className":181,"code":1605,"language":183,"meta":184,"style":184},"docker compose -f docker-compose.dev.yml -f docker-compose.profiles.yml \\\n  up -d --force-recreate db\n",[1607],{"type":46,"tag":78,"props":1608,"children":1609},{"__ignoreMap":184},[1610,1646],{"type":46,"tag":190,"props":1611,"children":1612},{"class":192,"line":193},[1613,1618,1623,1628,1633,1637,1642],{"type":46,"tag":190,"props":1614,"children":1615},{"style":197},[1616],{"type":52,"value":1617},"docker",{"type":46,"tag":190,"props":1619,"children":1620},{"style":203},[1621],{"type":52,"value":1622}," compose",{"type":46,"tag":190,"props":1624,"children":1625},{"style":203},[1626],{"type":52,"value":1627}," -f",{"type":46,"tag":190,"props":1629,"children":1630},{"style":203},[1631],{"type":52,"value":1632}," docker-compose.dev.yml",{"type":46,"tag":190,"props":1634,"children":1635},{"style":203},[1636],{"type":52,"value":1627},{"type":46,"tag":190,"props":1638,"children":1639},{"style":203},[1640],{"type":52,"value":1641}," docker-compose.profiles.yml",{"type":46,"tag":190,"props":1643,"children":1644},{"style":863},[1645],{"type":52,"value":866},{"type":46,"tag":190,"props":1647,"children":1648},{"class":192,"line":214},[1649,1654,1659,1664],{"type":46,"tag":190,"props":1650,"children":1651},{"style":203},[1652],{"type":52,"value":1653},"  up",{"type":46,"tag":190,"props":1655,"children":1656},{"style":203},[1657],{"type":52,"value":1658}," -d",{"type":46,"tag":190,"props":1660,"children":1661},{"style":203},[1662],{"type":52,"value":1663}," --force-recreate",{"type":46,"tag":190,"props":1665,"children":1666},{"style":203},[1667],{"type":52,"value":1668}," db\n",{"type":46,"tag":62,"props":1670,"children":1671},{},[1672,1674,1680],{"type":52,"value":1673},"Verify: ",{"type":46,"tag":78,"props":1675,"children":1677},{"className":1676},[],[1678],{"type":52,"value":1679},"nc -z 127.0.0.1 5432",{"type":52,"value":1681}," should succeed.",{"type":46,"tag":1469,"props":1683,"children":1685},{"id":1684},"secrets-causes-not-null-violation",[1686,1692],{"type":46,"tag":78,"props":1687,"children":1689},{"className":1688},[],[1690],{"type":52,"value":1691},"secrets={}",{"type":52,"value":1693}," causes NOT NULL violation",{"type":46,"tag":62,"props":1695,"children":1696},{},[1697,1702,1704,1710],{"type":46,"tag":78,"props":1698,"children":1700},{"className":1699},[],[1701],{"type":52,"value":417},{"type":52,"value":1703}," encrypts the value — an empty dict serializes to null.\nAlways pass a non-empty dict: ",{"type":46,"tag":78,"props":1705,"children":1707},{"className":1706},[],[1708],{"type":52,"value":1709},"secrets={'placeholder': 'true'}",{"type":52,"value":171},{"type":46,"tag":1469,"props":1712,"children":1714},{"id":1713},"batch-import-worker-modifies-seeded-records",[1715],{"type":52,"value":1716},"Batch import worker modifies seeded records",{"type":46,"tag":62,"props":1718,"children":1719},{},[1720,1722,1727,1729,1734,1736,1742,1744,1750,1752,1757],{"type":52,"value":1721},"The local ",{"type":46,"tag":78,"props":1723,"children":1725},{"className":1724},[],[1726],{"type":52,"value":623},{"type":52,"value":1728}," process automatically claims ",{"type":46,"tag":78,"props":1730,"children":1732},{"className":1731},[],[1733],{"type":52,"value":631},{"type":52,"value":1735}," records.\nIf it encounters a config validation error (e.g. missing ",{"type":46,"tag":78,"props":1737,"children":1739},{"className":1738},[],[1740],{"type":52,"value":1741},"skip_blanks",{"type":52,"value":1743},"),\nit will pause the import with a detailed Rust backtrace in ",{"type":46,"tag":78,"props":1745,"children":1747},{"className":1746},[],[1748],{"type":52,"value":1749},"status_message",{"type":52,"value":1751},".\nStop the worker or seed with non-",{"type":46,"tag":78,"props":1753,"children":1755},{"className":1754},[],[1756],{"type":52,"value":631},{"type":52,"value":1758}," statuses to prevent this.",{"type":46,"tag":1469,"props":1760,"children":1762},{"id":1761},"the-gates-end-to-end",[1763],{"type":52,"value":1764},"The gates, end to end",{"type":46,"tag":62,"props":1766,"children":1767},{},[1768],{"type":52,"value":1769},"A request passes through two independent layers:",{"type":46,"tag":1514,"props":1771,"children":1772},{},[1773,1806],{"type":46,"tag":72,"props":1774,"children":1775},{},[1776,1781,1783,1788,1790,1796,1798,1804],{"type":46,"tag":92,"props":1777,"children":1778},{},[1779],{"type":52,"value":1780},"MCP discovery",{"type":52,"value":1782}," (presentation): a tool requiring an OAuth-hidden scope surfaces only when the key explicitly carries the scope AND ",{"type":46,"tag":78,"props":1784,"children":1786},{"className":1785},[],[1787],{"type":52,"value":137},{"type":52,"value":1789}," confirms ",{"type":46,"tag":78,"props":1791,"children":1793},{"className":1792},[],[1794],{"type":52,"value":1795},"is_staff",{"type":52,"value":1797}," — otherwise it is hidden, fail-closed (",{"type":46,"tag":78,"props":1799,"children":1801},{"className":1800},[],[1802],{"type":52,"value":1803},"services\u002Fmcp\u002Fsrc\u002Flib\u002Fstaff-only-tools.ts",{"type":52,"value":1805},").",{"type":46,"tag":72,"props":1807,"children":1808},{},[1809,1814,1816,1822,1823,1829,1830,1836,1838,1844,1845,1850,1852,1857],{"type":46,"tag":92,"props":1810,"children":1811},{},[1812],{"type":52,"value":1813},"Django enforcement",{"type":52,"value":1815}," (the security boundary): ",{"type":46,"tag":78,"props":1817,"children":1819},{"className":1818},[],[1820],{"type":52,"value":1821},"IsAuthenticated",{"type":52,"value":1383},{"type":46,"tag":78,"props":1824,"children":1826},{"className":1825},[],[1827],{"type":52,"value":1828},"IsStaffUser",{"type":52,"value":1383},{"type":46,"tag":78,"props":1831,"children":1833},{"className":1832},[],[1834],{"type":52,"value":1835},"APIScopePermission",{"type":52,"value":1837}," with ",{"type":46,"tag":78,"props":1839,"children":1841},{"className":1840},[],[1842],{"type":52,"value":1843},"scope_object = \"INTERNAL\"",{"type":52,"value":106},{"type":46,"tag":78,"props":1846,"children":1848},{"className":1847},[],[1849],{"type":52,"value":104},{"type":52,"value":1851},". Sessions need staffness only; PATs need staffness plus the explicit scope; ",{"type":46,"tag":78,"props":1853,"children":1855},{"className":1854},[],[1856],{"type":52,"value":145},{"type":52,"value":1858},"-only keys always 403.",{"type":46,"tag":1860,"props":1861,"children":1862},"style",{},[1863],{"type":52,"value":1864},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":1866,"total":2037},[1867,1886,1898,1911,1924,1939,1955,1970,1984,1999,2009,2027],{"slug":1868,"name":1868,"fn":1869,"description":1870,"org":1871,"tags":1872,"stars":1883,"repoUrl":1884,"updatedAt":1885},"analyzing-expensive-users","analyze expensive users in AI observability","Analyze the most expensive users in AI observability and explain why they cost so much. Use when the user asks about top spenders, expensive users, per-user LLM cost, user-level cost drivers, or patterns behind high AI observability spend.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1873,1876,1879,1882],{"name":1874,"slug":1875,"type":15},"Analytics","analytics",{"name":1877,"slug":1878,"type":15},"Cost Optimization","cost-optimization",{"name":1880,"slug":1881,"type":15},"Observability","observability",{"name":9,"slug":8,"type":15},35568,"https:\u002F\u002Fgithub.com\u002FPostHog\u002Fposthog","2026-07-28T05:34:11.117757",{"slug":1887,"name":1887,"fn":1888,"description":1889,"org":1890,"tags":1891,"stars":1883,"repoUrl":1884,"updatedAt":1897},"auditing-endpoints","audit PostHog project endpoints","Audit every endpoint in a PostHog project for staleness, failed materialisations, and unused materialised versions. Use when the user asks \"what endpoints can I clean up?\", \"are any of my endpoints broken?\", \"which materialised versions are still being called?\", or wants a one-shot cleanup pass over the Endpoints product. Produces a prioritised report grouped by issue type, with recommended actions but does not modify anything without explicit confirmation.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1892,1893,1896],{"name":1874,"slug":1875,"type":15},{"name":1894,"slug":1895,"type":15},"Audit","audit",{"name":9,"slug":8,"type":15},"2026-06-08T08:08:33.693989",{"slug":1899,"name":1899,"fn":1900,"description":1901,"org":1902,"tags":1903,"stars":1883,"repoUrl":1884,"updatedAt":1910},"auditing-warehouse-source-health","audit PostHog data warehouse source health","Audit the health of a PostHog project's data warehouse sources and syncs — find every broken or degraded source connection, sync schema, and webhook channel. Use when the user asks \"why are my imports failing?\", \"what's broken with my sources?\", \"why is my warehouse data stale?\", or wants a one-shot triage of source\u002Fsync health before deciding where to dig in. Produces a prioritized report grouped by severity, with recommended next steps. For materialized-view health use `auditing-warehouse-view-health`; for a single failing sync use `diagnosing-failed-warehouse-syncs`.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1904,1905,1908,1909],{"name":1894,"slug":1895,"type":15},{"name":1906,"slug":1907,"type":15},"Data Warehouse","data-warehouse",{"name":1880,"slug":1881,"type":15},{"name":9,"slug":8,"type":15},"2026-06-18T08:22:57.67984",{"slug":1912,"name":1912,"fn":1913,"description":1914,"org":1915,"tags":1916,"stars":1883,"repoUrl":1884,"updatedAt":1923},"auditing-warehouse-view-health","audit PostHog materialized view health","Audit the health of a PostHog project's materialized views (saved queries) — find every failed materialization and flag unused or stale materialized views that cost storage and compute. Use when the user asks \"which of my views are broken?\", \"why is this materialized view failing?\", \"are any of my views wasting compute?\", or wants a one-shot triage of view health. For source\u002Fsync health use `auditing-warehouse-source-health`.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1917,1918,1919,1922],{"name":1894,"slug":1895,"type":15},{"name":1906,"slug":1907,"type":15},{"name":1920,"slug":1921,"type":15},"Performance","performance",{"name":9,"slug":8,"type":15},"2026-06-18T08:25:10.936787",{"slug":1925,"name":1925,"fn":1926,"description":1927,"org":1928,"tags":1929,"stars":1883,"repoUrl":1884,"updatedAt":1938},"authoring-error-tracking-alerts","author PostHog error tracking alerts","Author error tracking alerts that fire when an issue is created, reopened, or starts spiking. Use when the user asks to set up error notifications, route exceptions to Slack\u002Fwebhook\u002FLinear, or evaluate which error events are worth alerting on. Covers trigger-event selection, integration choice, dedup against existing alerts, and shipping with the canonical message body shape.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1930,1933,1936,1937],{"name":1931,"slug":1932,"type":15},"Alerting","alerting",{"name":1934,"slug":1935,"type":15},"Debugging","debugging",{"name":1880,"slug":1881,"type":15},{"name":9,"slug":8,"type":15},"2026-06-18T08:24:40.318583",{"slug":1940,"name":1940,"fn":1941,"description":1942,"org":1943,"tags":1944,"stars":1883,"repoUrl":1884,"updatedAt":1954},"authoring-log-alerts","author log alerts in PostHog","Author useful, low-noise log alerts on services in a PostHog project. Use when the user asks to set up alerts for their logs, suggest alerts they should add, or evaluate whether a service is worth monitoring. Covers service triage, baseline characterisation, threshold drafting, back-testing via simulate, and shipping with a notification destination.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1945,1946,1949,1950,1953],{"name":1874,"slug":1875,"type":15},{"name":1947,"slug":1948,"type":15},"Monitoring","monitoring",{"name":1880,"slug":1881,"type":15},{"name":1951,"slug":1952,"type":15},"Operations","operations",{"name":9,"slug":8,"type":15},"2026-07-18T05:10:54.430898",{"slug":1956,"name":1956,"fn":1957,"description":1958,"org":1959,"tags":1960,"stars":1883,"repoUrl":1884,"updatedAt":1969},"building-workflows","build and edit PostHog workflows","Build, edit, test, enable, and monitor PostHog workflows over MCP. Author the action\u002Fedge graph so it runs and opens cleanly in the visual editor, then change drafts surgically with patch operations. Use when asked to build, set up, automate, change, fix, or debug a workflow, campaign, broadcast, drip sequence, or event-triggered automation in the workflows product.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1961,1964,1965,1966],{"name":1962,"slug":1963,"type":15},"Automation","automation",{"name":20,"slug":21,"type":15},{"name":9,"slug":8,"type":15},{"name":1967,"slug":1968,"type":15},"Workflow Automation","workflow-automation","2026-07-28T05:34:12.167015",{"slug":1971,"name":1971,"fn":1972,"description":1973,"org":1974,"tags":1975,"stars":1883,"repoUrl":1884,"updatedAt":1983},"check-posthog-loading","inspect PostHog SDK loading across URLs","Inspect how the PostHog JavaScript SDK is loaded across a list of URLs. Use to confirm consistent installation across pages, find pages missing the snippet, detect mismatched API keys or hosts between pages, and verify the load method (head snippet vs deferred vs array.js).\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1976,1977,1978,1981,1982],{"name":1874,"slug":1875,"type":15},{"name":1934,"slug":1935,"type":15},{"name":1979,"slug":1980,"type":15},"Frontend","frontend",{"name":1880,"slug":1881,"type":15},{"name":9,"slug":8,"type":15},"2026-05-07T05:56:19.828048",{"slug":1985,"name":1985,"fn":1986,"description":1987,"org":1988,"tags":1989,"stars":1883,"repoUrl":1884,"updatedAt":1998},"consuming-endpoints-from-client-code","integrate PostHog endpoints into client applications","Wire a PostHog endpoint into a client app or SDK. Covers fetching the OpenAPI spec, generating a typed client with openapi-generator or @hey-api\u002Fopenapi-ts, sending the right auth header, shaping the variables payload (HogQL code_name vs insight breakdown property), handling rate-limit and materialised-endpoint error responses. Use when the user says \"how do I call my endpoint\", \"generate a client for this\", or \"what auth header do I use\".\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1990,1993,1994,1995],{"name":1991,"slug":1992,"type":15},"API Development","api-development",{"name":1979,"slug":1980,"type":15},{"name":9,"slug":8,"type":15},{"name":1996,"slug":1997,"type":15},"SDK","sdk","2026-06-08T08:08:34.929454",{"slug":2000,"name":2000,"fn":2001,"description":2002,"org":2003,"tags":2004,"stars":1883,"repoUrl":1884,"updatedAt":2008},"copying-endpoints-across-projects","copy PostHog endpoints across projects","Copy a PostHog endpoint (a saved HogQL\u002Finsight query exposed as an API route) to another project in the same organization, or duplicate it under a new name in the same project. Use when the user wants to duplicate an endpoint, promote an endpoint from staging to production, replicate an endpoint's query\u002Fvariables\u002Ffreshness config in another workspace, or clone an endpoint to iterate on it. Unlike feature flags and experiments, endpoints have NO native cross-project copy tool — this skill covers the read-then-recreate flow (endpoint-get then endpoint-create), the active-project switching it requires, name-collision checks, and the safe defaults (land unmaterialised in the target, verify with endpoint-run). Does not cover editing endpoint versions (see managing-endpoint-versions) or authoring a brand-new endpoint from scratch (see creating-an-endpoint).\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2005,2006,2007],{"name":1991,"slug":1992,"type":15},{"name":1951,"slug":1952,"type":15},{"name":9,"slug":8,"type":15},"2026-07-15T05:29:58.442727",{"slug":2010,"name":2010,"fn":2011,"description":2012,"org":2013,"tags":2014,"stars":1883,"repoUrl":1884,"updatedAt":2026},"creating-ai-subscription","schedule recurring AI-generated PostHog reports","Create a recurring AI-generated PostHog report — schedule a free-text prompt to run on a cron, with the LLM-synthesized markdown delivered to email or Slack on each tick. Use when the user wants a recurring AI summary of X on any cadence (daily, weekly, monthly, yearly) rather than a one-off report. (To attach an AI summary to an existing insight\u002Fdashboard subscription instead of a free-text prompt, see `managing-subscriptions` and its `summary_enabled` option.)\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2015,2016,2019,2020,2023],{"name":1962,"slug":1963,"type":15},{"name":2017,"slug":2018,"type":15},"Email","email",{"name":9,"slug":8,"type":15},{"name":2021,"slug":2022,"type":15},"Reporting","reporting",{"name":2024,"slug":2025,"type":15},"Slack","slack","2026-06-09T07:32:27.935712",{"slug":2028,"name":2028,"fn":2029,"description":2030,"org":2031,"tags":2032,"stars":1883,"repoUrl":1884,"updatedAt":2036},"creating-an-endpoint","create PostHog API endpoints","Create a PostHog endpoint with the right shape on the first try — covers query kind choice, name conventions, what to expose as variables (HogQL code_name vs insight breakdown), data_freshness_seconds, and whether to materialise on day one. Use when the user says \"create an endpoint\", \"expose this query as an API\", \"turn this insight into an endpoint\", or asks for help structuring a new endpoint. Steers away from common mistakes: materialising a query with cohort breakdowns or compare mode, inline-only variables on a materialised endpoint, unbounded date ranges, ambiguous names.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2033,2034,2035],{"name":1874,"slug":1875,"type":15},{"name":1991,"slug":1992,"type":15},{"name":9,"slug":8,"type":15},"2026-06-08T08:08:29.624498",231,{"items":2039,"total":2145},[2040,2055,2071,2086,2099,2111,2129],{"slug":2041,"name":2041,"fn":2042,"description":2043,"org":2044,"tags":2045,"stars":25,"repoUrl":26,"updatedAt":2054},"analyzing-experiment-session-replays","analyze session replays for PostHog experiments","Analyze session replay patterns across experiment variants to understand user behavior differences. Use when the user wants to see how users interact with different experiment variants, identify usability issues, compare behavior patterns between control and test groups, or get qualitative insights to complement quantitative experiment results.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2046,2047,2050,2051],{"name":1874,"slug":1875,"type":15},{"name":2048,"slug":2049,"type":15},"Design","design",{"name":9,"slug":8,"type":15},{"name":2052,"slug":2053,"type":15},"User Research","user-research","2026-04-06T18:44:38.291781",{"slug":2056,"name":2056,"fn":2057,"description":2058,"org":2059,"tags":2060,"stars":25,"repoUrl":26,"updatedAt":2070},"assessing-heatmaps","analyze page heatmaps and suggest improvements","Assesses what a page's heatmap is telling you and recommends concrete changes. Pulls click \u002F rageclick \u002F scroll-depth data for a URL, names the hot elements by cross-referencing autocapture events on the same page, and can create a saved heatmap the user opens in PostHog, then summarizes the behavior and proposes improvements.\nTRIGGER when: user asks what a heatmap shows, why people aren't clicking something, where users rage-click, how far they scroll, what to change on a page based on heatmap\u002Fclick data, or to 'analyze\u002Fassess\u002Freview the heatmap' for a URL.\nDO NOT TRIGGER when: the user only wants to create a saved heatmap screenshot with no analysis (use heatmaps-saved-create directly), or is asking about session replay in general (use investigating-replay).",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2061,2062,2063,2064,2067],{"name":1874,"slug":1875,"type":15},{"name":1979,"slug":1980,"type":15},{"name":9,"slug":8,"type":15},{"name":2065,"slug":2066,"type":15},"Product Management","product-management",{"name":2068,"slug":2069,"type":15},"UX Design","ux-design","2026-06-05T07:40:43.37798",{"slug":2072,"name":2072,"fn":2073,"description":2074,"org":2075,"tags":2076,"stars":25,"repoUrl":26,"updatedAt":2085},"auditing-experiments-flags","audit PostHog experiments and feature flags","Audit PostHog experiments and feature flags for configuration issues, staleness, and best-practice violations. Read when the user asks to audit, health-check, or review experiments or feature flags, check flag hygiene, or verify experiment setup.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2077,2078,2081,2082],{"name":1894,"slug":1895,"type":15},{"name":2079,"slug":2080,"type":15},"Feature Flags","feature-flags",{"name":9,"slug":8,"type":15},{"name":2083,"slug":2084,"type":15},"QA","qa","2026-04-06T18:44:30.657553",{"slug":2087,"name":2087,"fn":2088,"description":2089,"org":2090,"tags":2091,"stars":25,"repoUrl":26,"updatedAt":2098},"authoring-scouts","author and edit PostHog Signals scouts","How to author, edit, and adapt PostHog Signals scouts — the scheduled agents that scan a project and write reports into the Signals inbox. Use when a user wants to customize a canonical scout for their own setup (narrow its scope, retune its thresholds, add disqualifiers), tweak a scout's schedule or dry-run posture, or write a brand-new scout from scratch for a specific use case (a custom event, a product surface no canonical scout covers), or steer a scout without editing it at all by leaving it a note. Covers the scout SKILL.md anatomy, the report contract, the dedupe + scratchpad-memory conventions, the scout-notes steering channel, the per-team skills-store path vs the canonical in-repo path, and the write-and-inspect test loop (with dry-run as an optional safety net). Trigger on \"write\u002Fedit\u002Fcustomize a signals scout\", \"new scout for X\", \"tune my scout schedule\", \"make a scout that watches \u003Cevent>\", \"leave a note for \u002F give feedback to a scout\", \"tell the scouts about X\".\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2092,2095,2096,2097],{"name":2093,"slug":2094,"type":15},"Agents","agents",{"name":1962,"slug":1963,"type":15},{"name":1880,"slug":1881,"type":15},{"name":9,"slug":8,"type":15},"2026-07-28T05:33:45.509154",{"slug":2100,"name":2100,"fn":2101,"description":2102,"org":2103,"tags":2104,"stars":25,"repoUrl":26,"updatedAt":2110},"building-a-dashboard","build and update PostHog dashboards","Build a new dashboard, or update an existing one, from a set of insights — the same job the in-app assistant does with its upsert-dashboard tool, but over MCP. Use when a user asks to create a dashboard, put several metrics\u002Fcharts together on one page, assemble a dashboard for a topic (product analytics, retention, revenue, activation, etc.), or add\u002Fremove\u002Freplace insights on a dashboard they already have. Covers deciding create vs update, reusing existing insights vs creating new ones, and using PostHog's vetted dashboard templates as reference for what a strong dashboard on a topic looks like.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2105,2106,2109],{"name":1874,"slug":1875,"type":15},{"name":2107,"slug":2108,"type":15},"Dashboards","dashboards",{"name":20,"slug":21,"type":15},"2026-07-21T06:07:38.060598",{"slug":2112,"name":2112,"fn":2113,"description":2114,"org":2115,"tags":2116,"stars":25,"repoUrl":26,"updatedAt":2128},"checking-deploy-timing","correlate PostHog deployments with GitHub commits","Determine when a PostHog code change reached a given environment by reading the hidden GIT deploy annotations in the project and correlating them with the merge commit on GitHub. Use when PostHog staff ask \"when was X deployed\", \"is my change live in the US\u002FEU yet\", \"has my PR shipped\", \"did the fix roll out to prod-us\", or otherwise want to know whether\u002Fwhen a commit, PR, or feature went out to a region. Do not answer deploy-timing questions from event\u002Fdata volume alone — that only shows when data changed, not when code shipped.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2117,2120,2123,2126,2127],{"name":2118,"slug":2119,"type":15},"Deployment","deployment",{"name":2121,"slug":2122,"type":15},"Git","git",{"name":2124,"slug":2125,"type":15},"GitHub","github",{"name":1880,"slug":1881,"type":15},{"name":9,"slug":8,"type":15},"2026-06-28T07:46:59.53536",{"slug":2130,"name":2130,"fn":2131,"description":2132,"org":2133,"tags":2134,"stars":25,"repoUrl":26,"updatedAt":2144},"choosing-trend-or-slope-view","visualize trends and growth over time","Clarify how to visualize change over a time range before building a trend. Use whenever the user asks how much something changed, grew, dropped, improved, or regressed between two points or periods — \"how much did X change from A to B\", \"before vs after\", \"start vs end\", \"week over week\", \"compare this month to last\", \"change over time\" — or mentions a \"slope chart\" \u002F \"slopegraph\". Two readings of \"change\" need different charts: the whole trend (a line, every interval) versus just the two endpoints (a slope, start vs end). Ask which they want, then render it. Not for choosing a saved insight ChartDisplayType in the insight editor.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2135,2136,2139,2142,2143],{"name":1874,"slug":1875,"type":15},{"name":2137,"slug":2138,"type":15},"Charts","charts",{"name":2140,"slug":2141,"type":15},"Data Visualization","data-visualization",{"name":9,"slug":8,"type":15},{"name":2021,"slug":2022,"type":15},"2026-06-18T08:18:57.960157",56]