:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
MCP tools
The autoresearch-* tool surface. Unusually for a PostHog product, these tools are not primarily for users or for Max — they are how the training agent operates the product on itself.
During a run, the sandbox agent has no other write path. It records iterations, materializes features, uploads its bundle, and finalizes its run entirely through these tools. Everything a tool description does not say, the agent has to guess.
What lives here
tools.yamlThe whole surface: 24 enabled tools,category: Autoresearch,feature: autoresearch,url_prefix: /autoresearch. The family must stay at or below 25 tools: above that the exec tool's compact domain index splits it into sub-domains, and the serialized exec schema crosses the claude.ai registry cap (seeservices/mcp/tests/unit/instructions-formatter-snapshot.test.ts). Duplicative tools (suggestions-retrieve,templates-list,validate-online-create,artifacts-delete-create) are disabled rather than removed.resolve-template-createnames every template key, so it replacestemplates-listas the template entry point. Each entry names anoperation(an operation id from the OpenAPI spec), anenabledflag, requiredscopes(autoresearch:read/autoresearch:write, plus every extra scope the endpoint'srequired_scopesnames, such asquery:read: MCP hides a tool whose scopes the key lacks),annotations(readOnly,destructive,idempotent), and atitle+description.
Tools are opt-in: pnpm --filter=@posthog/mcp run scaffold-yaml -- --candidates --product autoresearch lists the operations without an entry, and --add <operationId> adds one. A disabled entry needs a disabled_reason, or sync removes it. Everything editorial (description, title, enrich_url, exclude_params) is yours to write.
The two tool families
Agent-facing — the training loop's own control surface, backed by AutoresearchTrainingRunViewSet:
autoresearch-training-runs-iterations-create, -materialize-features, -artifacts-upload-create, -artifacts-get-create, -artifacts-retrieve, -complete-create, -history.
Bring-your-own agents — an agent that trains outside PostHog (for example on a laptop) calls autoresearch-training-runs-create to open a run, then the agent-facing tools above except -materialize-features, which writes into a PostHog sandbox; it pulls data with execute-sql instead. A sandbox request to open a run is refused.
User-facing — creating and inspecting pipelines: autoresearch-resolve-template-create, -validate-create, -create, -train-create, -score-create, -list, -retrieve, -training-runs-list, -online-performance-retrieve (realized metrics per model per validated date), -suggestions-create, -suggestions-list (to read the agent's response).
autoresearch-score-create scores today's prediction date on demand, so an MCP caller does not have to wait for the daily run after a champion is promoted. The training sandbox never sees it, because TRAINING_MCP_SCOPES has no person:write.
Pipeline lifecycle (archive, pause, resume) stays disabled. autoresearch-partial-update is enabled, needs person:write, and is marked destructive, because turning write_person_property off removes the property from the people the pipeline scored. The endpoint asks for person:write only when the request changes that field. The inference-run list is enabled so callers can check the status of background scoring.
The split matters when you change a description. An agent-facing description is a contract: autoresearch-training-runs-iterations-create has to tell the agent what a valid feature_sql looks like, because the server will reject anything that is not a read-only SELECT keyed on person_id and the agent has no other way to learn that.
Descriptions are the product
The descriptions here already do real work, and that is the standard to hold. Examples of what "good" looks like in this file:
autoresearch-createspells out the mutual exclusion — passtarget_eventortarget_definition, exactly one — and names the next call (autoresearch-train-create).- It also tells the caller to run
autoresearch-validate-createfirst and warns that the endpoint does not block on validation errors, so the model knows the check is advisory. autoresearch-train-createsays what happens to the existing champion on a retrain and names every refusal (run in progress, paused pipeline, no PostHog Desktop access).
Write for a model that has read nothing else. Name the prerequisite call, the next call, and the failure mode.
Cross-run memory
These tools are also how a run learns from previous ones. A training agent can call autoresearch-models-list and autoresearch-training-runs-history on sibling pipelines and build on what already worked — that behavior has been observed in practice, with a run opening by reading an earlier pipeline's champion recipe and using it as its baseline.
That makes the read tools load-bearing for model quality, not just for introspection. Do not disable or narrow them casually.
Where the rest of the system meets this file
- Backed by —
../backend/presentation/views/views.py. A tool is only as good as its serializer annotations;help_textand@extend_schemaflow directly into these schemas. - Generated into —
services/mcp/src/tools/generated/autoresearch.tsandservices/mcp/src/generated/autoresearch/api.ts. - Consumed by — the sandbox agent during
../backend/training/runs, plus any normal MCP client.
enrich_url needs a documented response schema
enrich_url: '{id}' makes the generated handler read result.id, so the operation's response type has to actually carry that field.
This broke once: autoresearch-create failed MCP typecheck with Property 'id' does not exist on type 'AutoresearchPipelineCreate'. The endpoint returned the read serializer at runtime but only declared the write one, so drf-spectacular typed the response as the request body — which has no id. Fixed by declaring responses={201: AutoresearchPipelineSerializer} on the viewset's create.
If you add enrich_url to a tool, check the operation's declared response schema contains the field you interpolate. Fix it on the endpoint and regenerate; never patch the generated file.
When editing this file
- Adding an endpoint does not expose it. A tool exists only once it has an entry here with
enabled: true. - Set
scopesandannotationsdeliberately —readOnlyanddestructivechange how clients treat a tool. - Prefer improving the serializer's
help_textover writing a longer tool description; the serializer feeds the frontend types too, so the fix lands in both places. - After any change run
pnpm --filter=@posthog/mcp run typecheckand commit the regenerated files — CI checks for drift. - If you add or retire a tool, update this file to match.