Skip to content

: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.

chore(mcp): move the live github manifest test off the required gate (#110199)

Georges-Antoine Assif698ccbd78f1
diff --git a/.github/workflows/ci-mcp-live-canary.yml b/.github/workflows/ci-mcp-live-canary.yml
new file mode 100644
index 000000000000..8bff7dbe0746
--- /dev/null
+++ b/.github/workflows/ci-mcp-live-canary.yml
@@ -0,0 +1,75 @@
+# Canary for the upstream artifacts the MCP server downloads at runtime.
+#
+# The MCP unit and integration suites never reach a third party, so a slow or broken GitHub
+# release cannot fail the required `MCP Tests Pass` check. This workflow is the safety net:
+# it runs services/mcp/tests/live against the real context-mill release on a schedule, and
+# posts to Slack when the test itself fails. It is not a required check and is not in the
+# master-red alerter's lanes.
+
+name: MCP live canary
+
+on:
+ schedule:
+ - cron: '37 */6 * * *'
+ workflow_dispatch:
+ pull_request:
+ paths:
+ - '.github/workflows/ci-mcp-live-canary.yml'
+ - 'services/mcp/vitest.live.config.mts'
+ - 'services/mcp/tests/live/**'
+ - 'services/mcp/src/resources/internals.ts'
+ - 'services/mcp/src/resources/manifest-loader.ts'
+ - 'services/mcp/src/resources/manifest-types.ts'
+
+env:
+ SLACK_CHANNEL: 'C0AS64N6DJL' # #alerts-devex
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+jobs:
+ canary:
+ name: Live context-mill manifest
+ runs-on: ubuntu-24.04
+ timeout-minutes: 15
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+
+ - name: Install pnpm dependencies
+ uses: ./.github/actions/pnpm-install
+ with:
+ install-command: pnpm --filter=@posthog/mcp... install --frozen-lockfile
+
+ - name: Run live tests
+ id: live
+ run: pnpm --filter=@posthog/mcp run test:live
+
+ # Only the live test failing means the upstream artifact is unreachable or no longer
+ # parses. Checkout and install failures are CI noise, so they do not post. A PR run
+ # has an author watching it, so only unattended runs post.
+ - name: Notify Slack on canary failure
+ if: failure() && steps.live.outcome == 'failure' && github.event_name == 'schedule'
+ uses: slackapi/slack-github-action@af78098f536edbc4de71162a307590698245be95 # v3.0.1
+ with:
+ method: chat.postMessage
+ token: ${{ secrets.SLACK_DEVEX_BOT_TOKEN }}
+ errors: true
+ payload: |
+ channel: "${{ env.SLACK_CHANNEL }}"
+ text: ":red_circle: MCP live canary failed: the context-mill release may be unreachable or invalid"
+ blocks:
+ - type: "section"
+ text:
+ type: "mrkdwn"
+ text: ":red_circle: *MCP live canary failed*. The latest context-mill release could not be downloaded or did not parse. The MCP server loads its skills resources from this release. Owner: team-context-mcp."
+ - type: "actions"
+ elements:
+ - type: "button"
+ text:
+ type: "plain_text"
+ text: "View run"
+ url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
diff --git a/services/mcp/package.json b/services/mcp/package.json
index 9d64fb842d98..d9be68e6f9a9 100644
--- a/services/mcp/package.json
+++ b/services/mcp/package.json
@@ -29,6 +29,7 @@
"build:cli:release": "tsx scripts/build-cli-release.ts",
"test": "vitest",
"test:integration": "vitest run --config vitest.integration.config.mts",
+ "test:live": "vitest run --config vitest.live.config.mts",
"test:hono": "vitest run --config vitest.hono.config.mts",
"test:perf": "vitest run --config vitest.perf.config.mts",
"test:watch": "vitest watch",
diff --git a/services/mcp/src/hono/constants.ts b/services/mcp/src/hono/constants.ts
index 8f4e434f0a2a..82d1ad61ef49 100644
--- a/services/mcp/src/hono/constants.ts
+++ b/services/mcp/src/hono/constants.ts
@@ -40,6 +40,7 @@ export function getEnv(): Env {
POSTHOG_ANALYTICS_API_KEY: process.env.POSTHOG_ANALYTICS_API_KEY || undefined,
POSTHOG_ANALYTICS_HOST: process.env.POSTHOG_ANALYTICS_HOST || undefined,
POSTHOG_MCP_SKILLS_URL: process.env.POSTHOG_MCP_SKILLS_URL || undefined,
+ POSTHOG_MCP_LOCAL_SKILLS_URL: process.env.POSTHOG_MCP_LOCAL_SKILLS_URL || undefined,
...extras,
}
}
diff --git a/services/mcp/src/hono/resource-catalog.ts b/services/mcp/src/hono/resource-catalog.ts
index 75191952ddbd..c1dc4b46c79d 100644
--- a/services/mcp/src/hono/resource-catalog.ts
+++ b/services/mcp/src/hono/resource-catalog.ts
@@ -146,7 +146,7 @@ export class ResourceCatalog {
}
private contextMillLocalUrl(): string | undefined {
- const localUrlRaw = (this.env as Record<string, string | undefined>)?.POSTHOG_MCP_LOCAL_SKILLS_URL
+ const localUrlRaw = this.env.POSTHOG_MCP_LOCAL_SKILLS_URL
return localUrlRaw && localUrlRaw.trim() !== '' ? localUrlRaw : undefined
}
diff --git a/services/mcp/src/tools/types.ts b/services/mcp/src/tools/types.ts
index e935d51b807a..02bf21d49159 100644
--- a/services/mcp/src/tools/types.ts
+++ b/services/mcp/src/tools/types.ts
@@ -105,6 +105,7 @@ export type Env = {
POSTHOG_ANALYTICS_HOST: string | undefined
/** Override the published product skills archive, primarily for local development. */
POSTHOG_MCP_SKILLS_URL?: string | undefined
+ POSTHOG_MCP_LOCAL_SKILLS_URL?: string | undefined
}
export type Context = {
diff --git a/services/mcp/tests/hono/integration-harness.test.ts b/services/mcp/tests/hono/integration-harness.test.ts
index 231cccc09136..0bbb87bfc426 100644
--- a/services/mcp/tests/hono/integration-harness.test.ts
+++ b/services/mcp/tests/hono/integration-harness.test.ts
@@ -1,6 +1,9 @@
import { createServer } from 'node:net'
import { afterEach, describe, expect, it, vi } from 'vitest'
+import { getEnv } from '@/hono/constants'
+import { fetchAndExtractEntries } from '@/resources/internals'
+
import { startHonoHarness } from '../integration/harness/hono'
const { warmup } = vi.hoisted(() => ({ warmup: vi.fn() }))
@@ -20,7 +23,8 @@ vi.mock('@/hono/app', () => ({
}),
}))
-vi.mock('../integration/harness/skill-archive', () => ({
+vi.mock('../integration/harness/skill-archive', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('../integration/harness/skill-archive')>()),
startSkillArchiveServer: async () => ({ url: 'http://127.0.0.1/skills.zip', stop: async () => {} }),
}))
@@ -36,6 +40,7 @@ describe('Hono integration harness', () => {
vi.stubEnv('MCP_APPS_BASE_URL', '')
vi.stubEnv('POSTHOG_API_BASE_URL', '')
vi.stubEnv('POSTHOG_MCP_SKILLS_URL', '')
+ vi.stubEnv('POSTHOG_MCP_LOCAL_SKILLS_URL', '')
let port = 0
warmup.mockImplementationOnce(async () => {
port = Number(new URL(process.env.MCP_APPS_BASE_URL!).port)
@@ -45,6 +50,10 @@ describe('Hono integration harness', () => {
competitor.listen(port, '127.0.0.1', () => competitor.close(() => resolve(null)))
})
expect(error?.code).toBe('EADDRINUSE')
+ const contextMillUrl = getEnv().POSTHOG_MCP_LOCAL_SKILLS_URL
+ expect(contextMillUrl).toMatch(/^http:\/\/127\.0\.0\.1:\d+\//)
+ const entries = await fetchAndExtractEntries(contextMillUrl)
+ expect(entries.some((entry) => entry.uri.startsWith('posthog://'))).toBe(true)
if (fails) {
throw new Error('warmup failed')
}
diff --git a/services/mcp/tests/integration/harness/hono.ts b/services/mcp/tests/integration/harness/hono.ts
index 1648f7f842bf..efffdf9e715f 100644
--- a/services/mcp/tests/integration/harness/hono.ts
+++ b/services/mcp/tests/integration/harness/hono.ts
@@ -5,7 +5,7 @@ import type { AddressInfo } from 'node:net'
import { createApp } from '@/hono/app'
-import { startSkillArchiveServer, type SkillArchiveServer } from './skill-archive'
+import { startContextMillArchiveServer, startSkillArchiveServer, type ArchiveServer } from './skill-archive'
import type { IntegrationEnv, IntegrationHarness } from './types'
// Pinned test DB so we don't collide with the dev Redis (DB 0). Must be in
@@ -49,18 +49,22 @@ export async function startHonoHarness(env: IntegrationEnv): Promise<Integration
process.env.MCP_APPS_BASE_URL = baseUrl.toString().replace(/\/$/, '')
let redis: Awaited<ReturnType<typeof startTestRedis>> | undefined
- let skillArchive: SkillArchiveServer | undefined
+ let skillArchive: ArchiveServer | undefined
+ let contextMillArchive: ArchiveServer | undefined
const stop = async (): Promise<void> => {
await new Promise<void>((resolve) => server.close(() => resolve()))
await skillArchive?.stop().catch(() => undefined)
+ await contextMillArchive?.stop().catch(() => undefined)
await redis?.quit().catch(() => undefined)
}
try {
redis = await startTestRedis()
skillArchive = await startSkillArchiveServer()
- // The dispatcher reads this when `createApp` constructs it.
+ // The dispatcher reads both archive URLs when `createApp` constructs it.
process.env.POSTHOG_MCP_SKILLS_URL = skillArchive.url
+ contextMillArchive = await startContextMillArchiveServer()
+ process.env.POSTHOG_MCP_LOCAL_SKILLS_URL = contextMillArchive.url
const { app, warmup } = createApp(redis as unknown as Parameters<typeof createApp>[0])
await warmup()
fetchHandler = app.fetch
diff --git a/services/mcp/tests/integration/harness/skill-archive.ts b/services/mcp/tests/integration/harness/skill-archive.ts
index ba1a53facb0d..6afee1ab8dd9 100644
--- a/services/mcp/tests/integration/harness/skill-archive.ts
+++ b/services/mcp/tests/integration/harness/skill-archive.ts
@@ -6,7 +6,7 @@ import type { AddressInfo } from 'node:net'
// republished by deleting the asset and uploading its replacement, so the URL 404s
// during a publish. A miss costs `SkillCatalogService.warmup` a 60s retry budget,
// which is longer than the `beforeAll` budget of every suite that boots the app.
-const ARCHIVE = zipSync({
+const SKILL_ARCHIVE = zipSync({
'integration-harness/SKILL.md': strToU8(
[
'---',
@@ -22,15 +22,39 @@ const ARCHIVE = zipSync({
),
})
-export type SkillArchiveServer = {
+export type ArchiveServer = {
url: string
stop: () => Promise<void>
}
-export async function startSkillArchiveServer(): Promise<SkillArchiveServer> {
+// Boot also downloads the context-mill resources archive from a GitHub release. The
+// resource catalog tests need at least one posthog:// resource with a readable body.
+const CONTEXT_MILL_ARCHIVE = zipSync({
+ 'manifest.json': strToU8(
+ JSON.stringify({
+ version: '1.0',
+ resources: [
+ {
+ id: 'integration-harness-doc',
+ name: 'Integration harness doc',
+ uri: 'posthog://integration-harness/doc',
+ file: 'integration-harness/doc.md',
+ resource: {
+ mimeType: 'text/markdown',
+ description: 'Placeholder resource so the harness boots without reaching the network.',
+ text: '# integration-harness doc',
+ },
+ },
+ ],
+ })
+ ),
+ 'integration-harness/doc.md': strToU8('# integration-harness doc\n'),
+})
+
+async function startArchiveServer(archive: Uint8Array, fileName: string): Promise<ArchiveServer> {
const server: Server = createServer((_request, response) => {
response.writeHead(200, { 'content-type': 'application/zip' })
- response.end(Buffer.from(ARCHIVE))
+ response.end(Buffer.from(archive))
})
// A failed bind emits `error` instead of calling the listen callback, so without
// this listener the promise never settles and node ends the worker before the
@@ -46,7 +70,15 @@ export async function startSkillArchiveServer(): Promise<SkillArchiveServer> {
const { port } = server.address() as AddressInfo
return {
- url: `http://127.0.0.1:${port}/skills.zip`,
+ url: `http://127.0.0.1:${port}/${fileName}`,
stop: () => new Promise<void>((resolve) => server.close(() => resolve())),
}
}
+
+export function startSkillArchiveServer(): Promise<ArchiveServer> {
+ return startArchiveServer(SKILL_ARCHIVE, 'skills.zip')
+}
+
+export function startContextMillArchiveServer(): Promise<ArchiveServer> {
+ return startArchiveServer(CONTEXT_MILL_ARCHIVE, 'skills-mcp-resources.zip')
+}
diff --git a/services/mcp/tests/integration/manifest.integration.test.ts b/services/mcp/tests/live/context-mill-manifest.live.test.ts
similarity index 100%
rename from services/mcp/tests/integration/manifest.integration.test.ts
rename to services/mcp/tests/live/context-mill-manifest.live.test.ts
diff --git a/services/mcp/tests/unit/context-mill-archive.test.ts b/services/mcp/tests/unit/context-mill-archive.test.ts
new file mode 100644
index 000000000000..869f3893c079
--- /dev/null
+++ b/services/mcp/tests/unit/context-mill-archive.test.ts
@@ -0,0 +1,58 @@
+import { strToU8, zipSync } from 'fflate'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+
+import { fetchAndExtractEntries } from '@/resources/internals'
+import type { ContextMillResource } from '@/resources/manifest-types'
+
+const ARCHIVE_URL = 'http://127.0.0.1/skills-mcp-resources.zip'
+
+function manifestEntry(id: string, file?: string): ContextMillResource {
+ return {
+ id,
+ name: `name-${id}`,
+ uri: `posthog://skills/${id}`,
+ ...(file ? { file } : {}),
+ resource: { mimeType: 'text/markdown', description: `desc-${id}`, text: `# ${id}` },
+ }
+}
+
+function stubArchiveResponse(files: Record<string, Uint8Array>): void {
+ const bytes = new Uint8Array(zipSync(files))
+ vi.stubGlobal(
+ 'fetch',
+ vi.fn(async () => new Response(bytes, { status: 200 }))
+ )
+}
+
+describe('fetchAndExtractEntries', () => {
+ afterEach(() => {
+ vi.unstubAllGlobals()
+ vi.restoreAllMocks()
+ })
+
+ it('serves the manifest entries whose backing file is in the archive', async () => {
+ vi.spyOn(console, 'warn').mockImplementation(() => {})
+ const manifest = {
+ version: '1.0',
+ resources: [
+ manifestEntry('bundled', 'skills/bundled.md'),
+ manifestEntry('inline'),
+ manifestEntry('missing', 'skills/missing.md'),
+ ],
+ }
+ stubArchiveResponse({
+ 'manifest.json': strToU8(JSON.stringify(manifest)),
+ 'skills/bundled.md': strToU8('# bundled'),
+ })
+
+ const entries = await fetchAndExtractEntries(ARCHIVE_URL)
+
+ expect(entries.map((entry) => entry.id)).toEqual(['bundled', 'inline'])
+ })
+
+ it('rejects an archive without a manifest', async () => {
+ stubArchiveResponse({ 'skills/bundled.md': strToU8('# bundled') })
+
+ await expect(fetchAndExtractEntries(ARCHIVE_URL)).rejects.toThrow('manifest.json not found in archive')
+ })
+})
diff --git a/services/mcp/vitest.config.mts b/services/mcp/vitest.config.mts
index 091e27ea2664..d1bc3cee65e7 100644
--- a/services/mcp/vitest.config.mts
+++ b/services/mcp/vitest.config.mts
@@ -29,6 +29,7 @@ export default defineConfig({
'node_modules/**',
'dist/**',
'tests/**/*.integration.test.ts',
+ 'tests/live/**',
'tests/workers/**',
'tests/hono/**',
],
diff --git a/services/mcp/vitest.live.config.mts b/services/mcp/vitest.live.config.mts
new file mode 100644
index 000000000000..c138e439d387
--- /dev/null
+++ b/services/mcp/vitest.live.config.mts
@@ -0,0 +1,16 @@
+import tsconfigPaths from 'vite-tsconfig-paths'
+import { defineConfig } from 'vitest/config'
+
+// Tests that download real upstream artifacts. They stay out of the unit and integration
+// configs so a slow or broken third party cannot fail a required check; the scheduled
+// ci-mcp-live-canary.yml workflow runs them instead.
+export default defineConfig({
+ plugins: [tsconfigPaths({ root: '.' })],
+ test: {
+ globals: true,
+ environment: 'node',
+ testTimeout: 30000,
+ retry: 1,
+ include: ['tests/live/**/*.live.test.ts'],
+ },
+})