: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(ci): run MCP agent API diff without workspace dependencies (#126790)
posthog[bot]d4e8f0ff98d1
diff --git a/.github/workflows/ci-mcp-agent-api-diff.yml b/.github/workflows/ci-mcp-agent-api-diff.ymlindex 039091f7b022..81efc20c8c70 100644--- a/.github/workflows/ci-mcp-agent-api-diff.yml+++ b/.github/workflows/ci-mcp-agent-api-diff.yml@@ -48,12 +48,10 @@ jobs:fetch-depth: 2persist-credentials: false- - name: Install pnpm dependencies- # Match services/mcp/Dockerfile exactly. No App token here: this job runs PR code and- # the action's token only feeds setup-node's rate-limited manifest lookups.- uses: ./.github/actions/pnpm-install+ - name: Set up Node.js+ uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0with:- install-command: pnpm --filter=@posthog/mcp... install --frozen-lockfile+ node-version-file: .nvmrc# Guarded for branches that predate the scripts, and for a checkout without a base parent.# Exit 3 from the script means the comparison could not run. The post job is then@@ -71,7 +69,7 @@ jobs:exit 1fimkdir -p agent-api-diff- pnpm --filter=@posthog/mcp exec tsx scripts/agent-api-diff.ts --base-ref 'HEAD^1' > agent-api-diff/agent-api-diff.md+ node services/mcp/scripts/agent-api-diff.ts --base-ref 'HEAD^1' > agent-api-diff/agent-api-diff.md- name: Upload agent API diffif: steps.diff.outcome == 'success'diff --git a/services/mcp/scripts/agent-api-diff.ts b/services/mcp/scripts/agent-api-diff.tsindex e7f9de6294a6..02f64665b88f 100644--- a/services/mcp/scripts/agent-api-diff.ts+++ b/services/mcp/scripts/agent-api-diff.ts@@ -1,4 +1,4 @@-#!/usr/bin/env tsx+#!/usr/bin/env node/*** Summarizes what a PR changes for agents: tools added or removed, top-level params,* scopes, annotations and input schema size. Reads the tool schema snapshots and the@@ -11,7 +11,7 @@* Callers must not read empty output as "no change" unless the exit code is 0.** Usage:- * pnpm --filter=@posthog/mcp exec tsx scripts/agent-api-diff.ts [--base-ref HEAD^1] [--base-dir <dir>]+ * node services/mcp/scripts/agent-api-diff.ts [--base-ref HEAD^1] [--base-dir <dir>]*/import { spawnSync } from 'node:child_process'import * as fs from 'node:fs'@@ -19,9 +19,9 @@ import * as os from 'node:os'import * as path from 'node:path'import { parseArgs } from 'node:util'-import { diffToolSurfaces, loadToolSurface, renderAgentApiDiff } from './lib/agent-api-diff'+import { diffToolSurfaces, loadToolSurface, renderAgentApiDiff } from './lib/agent-api-diff.ts'-const REPO_ROOT = path.resolve(__dirname, '../../..')+const REPO_ROOT = path.resolve(import.meta.dirname, '../../..')const TRACKED_PATHS = ['services/mcp/schema', 'services/mcp/tests/unit/__snapshots__/tool-schemas']const EXIT_UNAVAILABLE = 3diff --git a/services/mcp/tests/unit/agent-api-diff.test.ts b/services/mcp/tests/unit/agent-api-diff.test.tsindex 0672857ca7f1..51e18dce5ea4 100644--- a/services/mcp/tests/unit/agent-api-diff.test.ts+++ b/services/mcp/tests/unit/agent-api-diff.test.ts@@ -1,3 +1,5 @@+import { spawnSync } from 'node:child_process'+import * as path from 'node:path'import { describe, expect, it } from 'vitest'import {@@ -22,6 +24,17 @@ function surface(}describe('agent API diff', () => {+ it('runs the CLI with native Node.js without a TypeScript loader', () => {+ const root = path.resolve(import.meta.dirname, '../../../..')+ const result = spawnSync(+ process.execPath,+ [path.join(root, 'services/mcp/scripts/agent-api-diff.ts'), '--base-dir', root],+ { encoding: 'utf-8' }+ )++ expect({ status: result.status, stdout: result.stdout }).toEqual({ status: 0, stdout: '' })+ })+it('renders nothing when the tool surface is unchanged', () => {const same = surface({ 'a-list': { params: ['limit'] } })expect(renderAgentApiDiff(diffToolSurfaces(same, surface({ 'a-list': { params: ['limit'] } })))).toBe('')diff --git a/services/mcp/tsconfig.json b/services/mcp/tsconfig.jsonindex 93d00494d3d3..838b333d3010 100644--- a/services/mcp/tsconfig.json+++ b/services/mcp/tsconfig.json@@ -9,6 +9,7 @@"allowJs": true,"checkJs": false,"noEmit": true,+ "allowImportingTsExtensions": true,"isolatedModules": true,"allowSyntheticDefaultImports": true,"forceConsistentCasingInFileNames": true,