: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(mcp): trim published exec command reference (#73615)
Robbiee2f83f9a8b41
diff --git a/services/mcp/schema/exec-command-reference.md b/services/mcp/schema/exec-command-reference.mdindex ddb858833598..8e5e6ab589e6 100644--- a/services/mcp/schema/exec-command-reference.md+++ b/services/mcp/schema/exec-command-reference.md@@ -4,8 +4,6 @@In [CLI mode](/docs/model-context-protocol/faq#choosing-a-tool-mode), the default for most clients, the MCP server registers a single `exec` tool instead of one tool per endpoint. Agents pass it CLI-style command strings to list, search, inspect, and call the tools above on demand, which keeps context usage small.-This section is generated from the same templates the server serves to agents at runtime, so it always matches the deployed command surface.-```textlearn <topic...> - load one or more learning topicstools — list available tool names@@ -21,21 +19,6 @@ The `learn` command is only registered on hosts that use the guided help catalog### How agents use these commands-This is the workflow the tool description asks agents to follow.--PostHog: dashboards, insights, funnels, SQL, experiments, surveys, replay, error tracking, flags.--Pass CLI-style commands in the `command` parameter for all PostHog interactions.--**Requirements**--1. Find unknown tools with `search` or `tools`.-2. Run `info <tool_name>` once if its schema is not in context. Reuse it unless the tool changes or a schema error occurs.--Never guess a schema or run `info` before every call.--**Commands (in order):**-```text# 1. Find unknown toolsposthog:exec({ "command": "search <regex>" })@@ -52,18 +35,8 @@ posthog:exec({ "command": "call <tool_name> <json_input>" })posthog:exec({ "command": "call --json <tool_name> <json_input>" })```-**Schema drill-down:**--- `info` returns the full schema if it fits the token budget; otherwise it auto-summarizes (names, types, required, enums, defaults) and attaches `hint` entries pointing to `schema <tool> <path>` for complex fields.-- `schema <tool>` (no path) returns the summarized top-level schema.-- `schema <tool> <path>` resolves a dot path, descending through:- - object `properties` (e.g. `query.source`)- - array `items` — numeric segments step into items (`events.0.properties`), or jump to a property on the item type (`events.id`)- - `anyOf`/`oneOf` — numeric segment picks a variant by index, or a property name matches any object variant defining it-- Oversized sub-schemas are also summarized with a `note` to drill further.-- Unknown paths return an error listing available child paths.--**Not supported:**+### Tips-- `search` matches tool metadata only, not input schemas.-- No pattern-based field projection — drill one path at a time.+- Run `info <tool_name>` once when a schema isn't already in context, then reuse it. Running it before every call wastes context, and guessing a schema instead fails the call.+- When `info` returns fields carrying a `hint`, drill into each one with `schema <tool_name> <field_path>` before building that field's value.+- `search` matches tool names, titles, and descriptions, not input schemas. Search for the tool, then inspect its schema.diff --git a/services/mcp/scripts/generate-exec-docs.ts b/services/mcp/scripts/generate-exec-docs.tsindex c042c20764fa..5f253053373c 100644--- a/services/mcp/scripts/generate-exec-docs.ts+++ b/services/mcp/scripts/generate-exec-docs.ts@@ -15,14 +15,34 @@ function readSection(name: string): string {return fs.readFileSync(path.join(SECTIONS_DIR, name), 'utf8').trim()}-// Leading lines that only make sense inside a tool parameter description are dropped;-// the replaces are no-ops if the template wording changes, so drift shows up in review.+// Throws rather than emitting an empty section, so a template edit that moves the marker+// fails the build instead of silently gutting the published page.+function extractFencedBlockAfter(markdown: string, source: string, marker: string): string {+ const markerIndex = markdown.indexOf(marker)+ if (markerIndex === -1) {+ throw new Error(`${source}: marker not found: ${marker}`)+ }+ const fence = markdown.slice(markerIndex).match(/```[\s\S]*?```/)+ if (!fence) {+ throw new Error(`${source}: no fenced code block after marker: ${marker}`)+ }+ return fence[0]+}++// The leading line only makes sense inside a tool parameter description; the replace is a+// no-op if the template wording changes, so drift shows up in review.const cliSyntax = readSection('cli-syntax.md').replace('CLI-style command string. Supported commands:', '').replace('{extra_commands}', LEARN_COMMAND_LINE).trim()-const execBlurb = readSection('exec-tool-blurb.md').replace('### Using the `posthog` tool', '').trim()+// The blurb is written for agents and repeats the tool catalog and schema rules the page+// already covers, so only its ordered command walkthrough is published.+const execWorkflow = extractFencedBlockAfter(+ readSection('exec-tool-blurb.md'),+ 'exec-tool-blurb.md',+ '**Commands (in order):**'+)const fragment = `<!-- Generated by services/mcp/scripts/generate-exec-docs.ts (part of \`hogli build:openapi\`). Do not edit directly. -->@@ -30,17 +50,19 @@ const fragment = `<!-- Generated by services/mcp/scripts/generate-exec-docs.ts (In [CLI mode](/docs/model-context-protocol/faq#choosing-a-tool-mode), the default for most clients, the MCP server registers a single \`exec\` tool instead of one tool per endpoint. Agents pass it CLI-style command strings to list, search, inspect, and call the tools above on demand, which keeps context usage small.-This section is generated from the same templates the server serves to agents at runtime, so it always matches the deployed command surface.-${cliSyntax}The \`learn\` command is only registered on hosts that use the guided help catalog (currently Claude web and desktop). On hosts that support MCP apps, CLI mode also registers a separate \`render-ui\` tool for rendering interactive visualizations.### How agents use these commands-This is the workflow the tool description asks agents to follow.+${execWorkflow}++### Tips-${execBlurb}+- Run \`info <tool_name>\` once when a schema isn't already in context, then reuse it. Running it before every call wastes context, and guessing a schema instead fails the call.+- When \`info\` returns fields carrying a \`hint\`, drill into each one with \`schema <tool_name> <field_path>\` before building that field's value.+- \`search\` matches tool names, titles, and descriptions, not input schemas. Search for the tool, then inspect its schema.`fs.writeFileSync(OUTPUT_PATH, fragment)