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): serve the skill archive locally in integration tests (#102538)

Georges-Antoine Assib57a4c7f9e9c
diff --git a/services/mcp/tests/integration/harness/hono.ts b/services/mcp/tests/integration/harness/hono.ts
index 9da72fbd4171..abab36cab156 100644
--- a/services/mcp/tests/integration/harness/hono.ts
+++ b/services/mcp/tests/integration/harness/hono.ts
@@ -4,6 +4,7 @@ import type { AddressInfo } from 'node:net'
import { createApp } from '@/hono/app'
+import { startSkillArchiveServer } 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,8 +50,22 @@ export async function startHonoHarness(env: IntegrationEnv): Promise<Integration
process.env.MCP_APPS_BASE_URL = baseUrl.toString().replace(/\/$/, '')
const redis = await startTestRedis()
+
+ // The dispatcher reads this when `createApp` constructs it.
+ const skillArchive = await startSkillArchiveServer().catch(async (err: unknown) => {
+ await redis.quit().catch(() => undefined)
+ throw err
+ })
+ process.env.POSTHOG_MCP_SKILLS_URL = skillArchive.url
+
const { app, warmup } = createApp(redis as unknown as Parameters<typeof createApp>[0])
- await warmup()
+ try {
+ await warmup()
+ } catch (err) {
+ await skillArchive.stop().catch(() => undefined)
+ await redis.quit().catch(() => undefined)
+ throw err
+ }
const server = serve({ fetch: app.fetch, port: probePort })
@@ -58,6 +73,7 @@ export async function startHonoHarness(env: IntegrationEnv): Promise<Integration
baseUrl,
stop: async () => {
await new Promise<void>((resolve) => server.close(() => resolve()))
+ await skillArchive.stop().catch(() => undefined)
await redis.quit().catch(() => undefined)
},
}
diff --git a/services/mcp/tests/integration/harness/skill-archive.ts b/services/mcp/tests/integration/harness/skill-archive.ts
new file mode 100644
index 000000000000..ba1a53facb0d
--- /dev/null
+++ b/services/mcp/tests/integration/harness/skill-archive.ts
@@ -0,0 +1,52 @@
+import { strToU8, zipSync } from 'fflate'
+import { createServer, type Server } from 'node:http'
+import type { AddressInfo } from 'node:net'
+
+// Boot downloads this archive from the agent-skills-latest GitHub release, which is
+// 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({
+ 'integration-harness/SKILL.md': strToU8(
+ [
+ '---',
+ 'name: integration-harness',
+ 'description: Placeholder skill so the harness boots without reaching the network.',
+ '---',
+ '',
+ '# integration-harness',
+ '',
+ 'Stands in for the published skill bundle.',
+ '',
+ ].join('\n')
+ ),
+})
+
+export type SkillArchiveServer = {
+ url: string
+ stop: () => Promise<void>
+}
+
+export async function startSkillArchiveServer(): Promise<SkillArchiveServer> {
+ const server: Server = createServer((_request, response) => {
+ response.writeHead(200, { 'content-type': 'application/zip' })
+ 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
+ // caller can release what it already opened.
+ await new Promise<void>((resolve, reject) => {
+ const onError = (err: Error): void => reject(err)
+ server.once('error', onError)
+ server.listen(0, '127.0.0.1', () => {
+ server.off('error', onError)
+ resolve()
+ })
+ })
+ const { port } = server.address() as AddressInfo
+
+ return {
+ url: `http://127.0.0.1:${port}/skills.zip`,
+ stop: () => new Promise<void>((resolve) => server.close(() => resolve())),
+ }
+}
diff --git a/services/mcp/tests/integration/proxy.cf.integration.test.ts b/services/mcp/tests/integration/proxy.cf.integration.test.ts
index c51700aef182..ae3b1866e1be 100644
--- a/services/mcp/tests/integration/proxy.cf.integration.test.ts
+++ b/services/mcp/tests/integration/proxy.cf.integration.test.ts
@@ -12,9 +12,9 @@ import { defineAuthTests, defineResilienceTests, type ProtocolTestHarness } from
// - Real Redis (TEST_REDIS_URL / db TEST_REDIS_DB, default localhost:6379 db 15)
// - Real local PostHog stack at TEST_POSTHOG_API_BASE_URL (default localhost:8010)
//
-// Nothing is mocked. The Worker is configured with `MCP_HONO_URL` pointing at
-// the in-process Hono, so authenticated `/mcp` traffic travels the full
-// client → proxy → Hono → PostHog chain.
+// Only the product-skill archive is served locally. The Worker is configured with
+// `MCP_HONO_URL` pointing at the in-process Hono, so authenticated `/mcp` traffic
+// travels the full client → proxy → Hono → PostHog chain.
//
// The worker owns OAuth metadata, redirects, health, and the bearer-token gate
// locally and proxies only `/mcp` — it is not a transparent pass-through. The