Files
Lucas FariaandGitHub 2f9e64d60e feat(mcp): scaffold @posthog/mcp package (1/2) (#3652)
* feat(mcp): scaffold @posthog/mcp package

First half of a two-PR stack that ports the previous standalone @posthog/mcp
SDK into this monorepo. This PR is intentionally just the package skeleton:
configs, monorepo wiring, a stub `src/index.ts`, and one placeholder test.
The actual SDK implementation lands in the stacked follow-up PR.

Splitting it this way so reviewers can approve the wiring (build, lint,
tests, release matrix, eslint overrides) in isolation from the ~3k-line
SDK port that follows.

What this PR contains:

- `packages/mcp/package.json` — npm name `@posthog/mcp`, `workspace:*` dep
  on `@posthog/core`, peer on `@modelcontextprotocol/sdk`.
- `packages/mcp/tsconfig.json` + `tsconfig.build.json` extending the
  monorepo `@posthog-tooling/tsconfig-base`.
- `packages/mcp/rslib.config.ts` — same dual ESM + CJS + .d.ts shape as
  posthog-node and @posthog/core.
- `packages/mcp/jest.config.mjs` + `babel.config.mjs` matching posthog-node.
- `packages/mcp/.prettierrc` (2-space, no-semi, single-quote, printWidth 120).
- `packages/mcp/README.md` — install + usage stub.
- `packages/mcp/src/version.ts` — generated by the `prebuild` script.
- `packages/mcp/src/index.ts` — stub exporting `version` only. Replaced
  by the real SDK entry in the stacked follow-up PR.
- `packages/mcp/src/__tests__/scaffold.test.ts` — single placeholder test
  so jest doesn't error on `no tests found`. Also removed in the
  follow-up PR.
- `.eslintrc.cjs` — adds `packages/mcp/**` to the existing
  `no-console`/relaxed override block.
- `.github/workflows/release.yml` — adds `@posthog/mcp` to the publish
  matrix.
- `.changeset/posthog-mcp-initial.md` — describes the cumulative
  `@posthog/mcp 0.1.0` release.
- `pnpm-lock.yaml` — lockfile update.

Verification:
- `pnpm --filter=@posthog/mcp build` — clean.
- `pnpm --filter=@posthog/mcp test:unit` — 1 passing.
- `pnpm --filter=@posthog/mcp lint` — clean.

Task-Id: baa7e0cd-4946-4524-a05f-42c547a55f44

* fix(mcp): gitignore generated src/version.ts (matches posthog-node)

Every other monorepo package that uses the `prebuild` script pattern
(posthog-node, posthog-react-native, packages/web) gitignores
`src/version.ts` so the file is regenerated from `package.json` on
every build. Without this, changesets bumps `package.json` but the
committed `version.ts` stays stale until someone runs `pnpm build` and
commits the result.

Task-Id: baa7e0cd-4946-4524-a05f-42c547a55f44

* fix(mcp): move changeset to the implementation PR

The scaffold PR alone publishes a useless `@posthog/mcp 0.1.0` (just a
stub `index.ts` exporting `version`). Keeping the changeset here means
merging the scaffold ahead of the implementation PR fires the release
workflow and pings Slack for approval. Move the changeset to the
implementation PR so the release proposal only appears once the SDK is
actually ready to ship.

Task-Id: baa7e0cd-4946-4524-a05f-42c547a55f44

* fix(mcp): pin @modelcontextprotocol/sdk to ~1.29 and patch test:unit script

Per Greptile / graphite-app / mendral-app review on PR #3652:

- Bump @modelcontextprotocol/sdk devDep ~1.24.2 -> ~1.29.0 to
  pick up the GHSA-345p-7cg4-v4c7 (data leak, 1.26.0) and
  GHSA-8r9q-7v3j-jr4g (ReDoS, 1.25.2) fixes.
- Raise peerDependencies floor >=1.11 -> >=1.26.0 so consumers
  cannot resolve to a known-vulnerable host SDK.
- Extract the src/version.ts generator into a reusable
  `generate-version` script and hook it from both `pretest:unit`
  and `prebuild`, so `pnpm --filter=@posthog/mcp test:unit` works
  standalone (Greptile flagged that test:unit failed against a
  fresh checkout because version.ts had not been generated yet).
- Reorder prepublishOnly to build before test:unit for the same
  reason.

Task-Id: baa7e0cd-4946-4524-a05f-42c547a55f44
2026-05-28 10:07:00 -03:00

13 lines
305 B
JavaScript

export default {
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
modulePathIgnorePatterns: ['<rootDir>/src/__tests__/test-utils/*'],
collectCoverage: true,
clearMocks: true,
fakeTimers: { enableGlobally: false },
coverageDirectory: 'coverage',
silent: true,
verbose: false,
}