: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): redirect the removed experiment-get-all tool to experiment-list (#103254)
ruby childs62ee5292b505
diff --git a/.agents/skills/implementing-mcp-tools/SKILL.md b/.agents/skills/implementing-mcp-tools/SKILL.mdindex 44d6f174ab36..d83e07846f67 100644--- a/.agents/skills/implementing-mcp-tools/SKILL.md+++ b/.agents/skills/implementing-mcp-tools/SKILL.md@@ -200,6 +200,31 @@ That hits a whole agent fleet at once.operation, until the new name has deployed everywhere. Sunset it with`feature_flag_behavior: disable` on the same flag key, which swaps the two atomically.+### Deprecating a tool++A rename or a removal has two stages. Do not stop after the first one.++1. **Alias, while callers migrate.** Register the old name as a thin wrapper that calls the current+ handler and adds a `_deprecation_notice` to the response. The call still succeeds, and the agent+ learns the new name. See `services/mcp/src/tools/skills/deprecatedAliases.ts`, spread into+ `TOOL_MAP` in `services/mcp/src/tools/index.ts`. Use an alias only when the replacement accepts+ the same arguments.+2. **Redirect, when you delete the alias.** In the same change, add the old name to+ `DEPRECATED_TOOL_REDIRECTS` in `services/mcp/src/tools/exec.ts`. The call then fails with a+ `deprecated_tool` error that names the replacement, instead of the generic `Unknown tool: "..."`.+ State any argument changes in the text — see the `self-driving-inbox-get` entry.++Go directly to stage 2 when the replacement is not a drop-in. An alias that quietly drops renamed+parameters is worse than a call that fails.++Keep the redirect entry until the old name stops receiving traffic. `isRecordableToolName` records+`$mcp_exec_target_tool` only for a name the server owns: a live tool, or a+`DEPRECATED_TOOL_REDIRECTS` key. If you delete the entry too early, the remaining calls become+unattributable in MCP analytics, and you can no longer tell whether anything still uses the old name.++A tool that a feature flag removes is a different case. It keeps its definition, declares+`superseded_by` in the YAML, and `flagGatedToolMessage` answers the call.+### Syncing after endpoint changes```shdiff --git a/services/mcp/src/tools/exec.ts b/services/mcp/src/tools/exec.tsindex 309fcaa8c8fd..bd951e3d532c 100644--- a/services/mcp/src/tools/exec.ts+++ b/services/mcp/src/tools/exec.ts@@ -598,6 +598,10 @@ const DEPRECATED_TOOL_REDIRECTS: Record<string, (allTools: Tool<ZodObjectAny>[])// caller gets an unfiltered list instead of an error.'self-driving-inbox-get': () =>'Tool "self-driving-inbox-get" was removed. Use "inbox-reports-list", which lists the same reports. For the old default, pass { "view": "actionable", "use_priority_preference": true, "sort": "priority", "limit": 10 }. The array filters became comma-separated strings: `priorities` is now `priority`, `source_products` is now `source_product`, and `scouts` is now `scout`. `view`, `scope`, `teammate_uuid`, `search`, and `offset` keep their names.',+ // The `experiment-get-all` -> `experiment-list` deprecation alias was deleted in #101042.+ // Same arguments, so the redirect only has to hand over the new name.+ 'experiment-get-all': () =>+ 'Tool "experiment-get-all" was removed. It was a deprecation alias for "experiment-list", which takes the same arguments. Call "experiment-list" instead.',}/** The form caller keys and field names are matched on, so `date_from` reaches a fielddiff --git a/services/mcp/tests/unit/exec.test.ts b/services/mcp/tests/unit/exec.test.tsindex 78d810f87a1d..f1015e7ef38a 100644--- a/services/mcp/tests/unit/exec.test.ts+++ b/services/mcp/tests/unit/exec.test.ts@@ -1810,6 +1810,7 @@ describe('exec tool', () => {['query-generate-hogql-from-question', 'execute-sql'],['query-run', 'execute-sql'],['self-driving-inbox-get', 'inbox-reports-list'],+ ['experiment-get-all', 'experiment-list'],])('throws redirect when calling deprecated %s', async (deprecated, replacement) => {const exec = createExec()await expect(exec.handler(mockContext, { command: `call ${deprecated} {}` })).rejects.toThrow(