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): remove dead code left after the CF MCP server removal (#61884)

Georgiy Tarasovd5d005f6327a
diff --git a/services/mcp/schema/tool-inputs.json b/services/mcp/schema/tool-inputs.json
index 3bbe1419acac..044077728ca1 100644
--- a/services/mcp/schema/tool-inputs.json
+++ b/services/mcp/schema/tool-inputs.json
@@ -24,15 +24,6 @@
}
}
},
- "DocumentationSearchSchema": {
- "type": "object",
- "properties": {
- "query": {
- "type": "string"
- }
- },
- "required": ["query"]
- },
"EventDefinitionUpdateInputSchema": {
"type": "object",
"properties": {
@@ -112,250 +103,6 @@
},
"required": ["query"]
},
- "ExperimentCreateSchema": {
- "type": "object",
- "properties": {
- "name": {
- "type": "string",
- "minLength": 1,
- "description": "Experiment name - should clearly describe what is being tested"
- },
- "description": {
- "description": "Detailed description of the experiment hypothesis, what changes are being tested, and expected outcomes",
- "type": "string"
- },
- "feature_flag_key": {
- "type": "string",
- "description": "Feature flag key (letters, numbers, hyphens, underscores only). IMPORTANT: First search for existing feature flags that might be suitable using the feature-flags-get-all tool, then suggest reusing existing ones or creating a new key based on the experiment name"
- },
- "primary_metrics": {
- "description": "Primary metrics to measure experiment success. IMPORTANT: Each metric needs event_name to track data. For funnels, provide funnel_steps array with event names for each step. Ask user what events they track, or use project-property-definitions to find available events.",
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "name": {
- "description": "Human-readable metric name",
- "type": "string"
- },
- "metric_type": {
- "type": "string",
- "enum": ["mean", "funnel", "ratio"],
- "description": "Metric type: 'mean' for average values (revenue, time spent), 'funnel' for conversion flows, 'ratio' for comparing two metrics"
- },
- "event_name": {
- "type": "string",
- "description": "REQUIRED for metrics to work: PostHog event name (e.g., '$pageview', 'add_to_cart', 'purchase'). For funnels, this is the first step. Use '$pageview' if unsure. Search project-property-definitions tool for available events."
- },
- "funnel_steps": {
- "description": "For funnel metrics only: Array of event names for each funnel step (e.g., ['product_view', 'add_to_cart', 'checkout', 'purchase'])",
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "properties": {
- "description": "Event property filters as an array, e.g. [{ key: \"$browser\", value: \"Chrome\", operator: \"exact\", type: \"event\" }]",
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "key": {
- "type": "string"
- },
- "value": {
- "anyOf": [
- {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "number"
- },
- {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- {
- "type": "array",
- "items": {
- "type": "number"
- }
- }
- ]
- },
- {
- "type": "null"
- }
- ]
- },
- "operator": {
- "type": "string"
- },
- "type": {
- "type": "string"
- }
- },
- "required": ["key"]
- }
- },
- "description": {
- "description": "What this metric measures and why it's important for the experiment",
- "type": "string"
- }
- },
- "required": ["metric_type", "event_name"]
- }
- },
- "secondary_metrics": {
- "description": "Secondary metrics to monitor for potential side effects or additional insights. Each metric needs event_name.",
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "name": {
- "description": "Human-readable metric name",
- "type": "string"
- },
- "metric_type": {
- "type": "string",
- "enum": ["mean", "funnel", "ratio"],
- "description": "Metric type: 'mean' for average values, 'funnel' for conversion flows, 'ratio' for comparing two metrics"
- },
- "event_name": {
- "type": "string",
- "description": "REQUIRED: PostHog event name. Use '$pageview' if unsure."
- },
- "funnel_steps": {
- "description": "For funnel metrics only: Array of event names for each funnel step",
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "properties": {
- "description": "Event property filters as an array, e.g. [{ key: \"$browser\", value: \"Chrome\", operator: \"exact\", type: \"event\" }]",
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "key": {
- "type": "string"
- },
- "value": {
- "anyOf": [
- {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "number"
- },
- {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- {
- "type": "array",
- "items": {
- "type": "number"
- }
- }
- ]
- },
- {
- "type": "null"
- }
- ]
- },
- "operator": {
- "type": "string"
- },
- "type": {
- "type": "string"
- }
- },
- "required": ["key"]
- }
- },
- "description": {
- "description": "What this secondary metric measures",
- "type": "string"
- }
- },
- "required": ["metric_type", "event_name"]
- }
- },
- "variants": {
- "description": "Experiment variants. If not specified, defaults to 50/50 control/test split. Ask user how many variants they need and what each tests",
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "key": {
- "type": "string",
- "description": "Variant key (e.g., 'control', 'variant_a', 'new_design')"
- },
- "name": {
- "description": "Human-readable variant name",
- "type": "string"
- },
- "split_percent": {
- "description": "Percentage of traffic allocated to this variant (0-100). All variants must sum to 100. One of split_percent (recommended) or rollout_percentage (deprecated) must be provided per variant.",
- "type": "number",
- "minimum": 0,
- "maximum": 100
- },
- "rollout_percentage": {
- "description": "Deprecated: use split_percent instead. Accepted for backward compatibility.",
- "type": "number",
- "minimum": 0,
- "maximum": 100
- }
- },
- "required": ["key"]
- }
- },
- "minimum_detectable_effect": {
- "default": 30,
- "description": "Minimum detectable effect in percentage. Lower values require more users but detect smaller changes. Suggest 20-30% for most experiments",
- "type": "number"
- },
- "filter_test_accounts": {
- "default": true,
- "description": "Whether to filter out internal test accounts",
- "type": "boolean"
- },
- "target_properties": {
- "description": "Properties to target specific user segments (e.g., country, subscription type)",
- "type": "object",
- "propertyNames": {
- "type": "string"
- },
- "additionalProperties": {}
- },
- "draft": {
- "default": true,
- "description": "Create as draft (true) or launch immediately (false). Recommend draft for review first",
- "type": "boolean"
- },
- "holdout_id": {
- "description": "Holdout group ID if this experiment should exclude users from other experiments",
- "type": "number"
- },
- "allow_unknown_events": {
- "description": "Suppresses the validation that rejects metrics referencing events not yet ingested by this project. REQUIRES explicit user confirmation before being set to true — never flip this silently to retry a failed call. The default validation catches typo'd event names and missing instrumentation. Set this to true only when the user has confirmed the event is intentional (e.g. they are about to instrument it).",
- "type": "boolean"
- }
- },
- "required": ["name", "feature_flag_key"]
- },
"ExperimentResultsGetSchema": {
"type": "object",
"properties": {
@@ -371,421 +118,6 @@
},
"required": ["id"]
},
- "ExperimentUpdateInputSchema": {
- "type": "object",
- "properties": {
- "name": {
- "description": "Update experiment name",
- "type": "string"
- },
- "description": {
- "description": "Update experiment description",
- "type": "string"
- },
- "primary_metrics": {
- "description": "Update primary metrics",
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "name": {
- "description": "Human-readable metric name",
- "type": "string"
- },
- "metric_type": {
- "type": "string",
- "enum": ["mean", "funnel", "ratio"],
- "description": "Metric type: 'mean' for average values, 'funnel' for conversion flows, 'ratio' for comparing two metrics"
- },
- "event_name": {
- "type": "string",
- "description": "PostHog event name (e.g., '$pageview', 'add_to_cart', 'purchase')"
- },
- "funnel_steps": {
- "description": "For funnel metrics only: Array of event names for each funnel step",
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "properties": {
- "description": "Event property filters as an array, e.g. [{ key: \"$browser\", value: \"Chrome\", operator: \"exact\", type: \"event\" }]",
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "key": {
- "type": "string"
- },
- "value": {
- "anyOf": [
- {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "number"
- },
- {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- {
- "type": "array",
- "items": {
- "type": "number"
- }
- }
- ]
- },
- {
- "type": "null"
- }
- ]
- },
- "operator": {
- "type": "string"
- },
- "type": {
- "type": "string"
- }
- },
- "required": ["key"]
- }
- },
- "description": {
- "description": "What this metric measures",
- "type": "string"
- }
- },
- "required": ["metric_type", "event_name"]
- }
- },
- "secondary_metrics": {
- "description": "Update secondary metrics",
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "name": {
- "description": "Human-readable metric name",
- "type": "string"
- },
- "metric_type": {
- "type": "string",
- "enum": ["mean", "funnel", "ratio"],
- "description": "Metric type"
- },
- "event_name": {
- "type": "string",
- "description": "PostHog event name"
- },
- "funnel_steps": {
- "description": "For funnel metrics only: Array of event names",
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "properties": {
- "description": "Event property filters as an array, e.g. [{ key: \"$browser\", value: \"Chrome\", operator: \"exact\", type: \"event\" }]",
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "key": {
- "type": "string"
- },
- "value": {
- "anyOf": [
- {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "number"
- },
- {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- {
- "type": "array",
- "items": {
- "type": "number"
- }
- }
- ]
- },
- {
- "type": "null"
- }
- ]
- },
- "operator": {
- "type": "string"
- },
- "type": {
- "type": "string"
- }
- },
- "required": ["key"]
- }
- },
- "description": {
- "description": "What this metric measures",
- "type": "string"
- }
- },
- "required": ["metric_type", "event_name"]
- }
- },
- "minimum_detectable_effect": {
- "description": "Update minimum detectable effect in percentage",
- "type": "number"
- },
- "launch": {
- "description": "Launch experiment (set start_date) or keep as draft",
- "type": "boolean"
- },
- "conclude": {
- "description": "Conclude experiment with result",
- "type": "string",
- "enum": ["won", "lost", "inconclusive", "stopped_early", "invalid"]
- },
- "conclusion_comment": {
- "description": "Comment about experiment conclusion",
- "type": "string"
- },
- "restart": {
- "description": "Restart concluded experiment as draft (clears start_date, end_date, and conclusion)",
- "type": "boolean"
- },
- "archive": {
- "description": "Archive or unarchive experiment",
- "type": "boolean"
- }
- }
- },
- "ExperimentUpdateSchema": {
- "type": "object",
- "properties": {
- "experimentId": {
- "type": "number",
- "description": "The ID of the experiment to update"
- },
- "data": {
- "type": "object",
- "properties": {
- "name": {
- "description": "Update experiment name",
- "type": "string"
- },
- "description": {
- "description": "Update experiment description",
- "type": "string"
- },
- "primary_metrics": {
- "description": "Update primary metrics",
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "name": {
- "description": "Human-readable metric name",
- "type": "string"
- },
- "metric_type": {
- "type": "string",
- "enum": ["mean", "funnel", "ratio"],
- "description": "Metric type: 'mean' for average values, 'funnel' for conversion flows, 'ratio' for comparing two metrics"
- },
- "event_name": {
- "type": "string",
- "description": "PostHog event name (e.g., '$pageview', 'add_to_cart', 'purchase')"
- },
- "funnel_steps": {
- "description": "For funnel metrics only: Array of event names for each funnel step",
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "properties": {
- "description": "Event property filters as an array, e.g. [{ key: \"$browser\", value: \"Chrome\", operator: \"exact\", type: \"event\" }]",
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "key": {
- "type": "string"
- },
- "value": {
- "anyOf": [
- {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "number"
- },
- {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- {
- "type": "array",
- "items": {
- "type": "number"
- }
- }
- ]
- },
- {
- "type": "null"
- }
- ]
- },
- "operator": {
- "type": "string"
- },
- "type": {
- "type": "string"
- }
- },
- "required": ["key"]
- }
- },
- "description": {
- "description": "What this metric measures",
- "type": "string"
- }
- },
- "required": ["metric_type", "event_name"]
- }
- },
- "secondary_metrics": {
- "description": "Update secondary metrics",
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "name": {
- "description": "Human-readable metric name",
- "type": "string"
- },
- "metric_type": {
- "type": "string",
- "enum": ["mean", "funnel", "ratio"],
- "description": "Metric type"
- },
- "event_name": {
- "type": "string",
- "description": "PostHog event name"
- },
- "funnel_steps": {
- "description": "For funnel metrics only: Array of event names",
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- "properties": {
- "description": "Event property filters as an array, e.g. [{ key: \"$browser\", value: \"Chrome\", operator: \"exact\", type: \"event\" }]",
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "key": {
- "type": "string"
- },
- "value": {
- "anyOf": [
- {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "number"
- },
- {
- "type": "array",
- "items": {
- "type": "string"
- }
- },
- {
- "type": "array",
- "items": {
- "type": "number"
- }
- }
- ]
- },
- {
- "type": "null"
- }
- ]
- },
- "operator": {
- "type": "string"
- },
- "type": {
- "type": "string"
- }
- },
- "required": ["key"]
- }
- },
- "description": {
- "description": "What this metric measures",
- "type": "string"
- }
- },
- "required": ["metric_type", "event_name"]
- }
- },
- "minimum_detectable_effect": {
- "description": "Update minimum detectable effect in percentage",
- "type": "number"
- },
- "launch": {
- "description": "Launch experiment (set start_date) or keep as draft",
- "type": "boolean"
- },
- "conclude": {
- "description": "Conclude experiment with result",
- "type": "string",
- "enum": ["won", "lost", "inconclusive", "stopped_early", "invalid"]
- },
- "conclusion_comment": {
- "description": "Comment about experiment conclusion",
- "type": "string"
- },
- "restart": {
- "description": "Restart concluded experiment as draft (clears start_date, end_date, and conclusion)",
- "type": "boolean"
- },
- "archive": {
- "description": "Archive or unarchive experiment",
- "type": "boolean"
- }
- },
- "description": "The experiment data to update using user-friendly format"
- }
- },
- "required": ["experimentId", "data"]
- },
"ExternalDataJobsAfterSchema": {
"type": "string",
"description": "ISO timestamp — only return jobs created after this date (e.g. \"2025-01-01T00:00:00Z\")."
@@ -1186,10 +518,6 @@
],
"description": "Immutable scorer configuration. Pick the shape matching the scorer kind: categorical (options + selection_mode), numeric (min/max/step), or boolean (true_label/false_label). The server validates the shape against the kind on the parent scorer and returns 400 on a mismatch."
},
- "SurveyResponseCountsSchema": {
- "type": "object",
- "properties": {}
- },
"UsageMetricFiltersSchema": {
"anyOf": [
{
diff --git a/services/mcp/src/hono/constants.ts b/services/mcp/src/hono/constants.ts
index 067e9f5c8699..6fcb0ed71080 100644
--- a/services/mcp/src/hono/constants.ts
+++ b/services/mcp/src/hono/constants.ts
@@ -12,7 +12,6 @@ export {
getPublicBaseUrl,
getAuthorizationServerUrl,
MCP_DOCS_URL,
- OAUTH_PROXY_URL,
OAUTH_SCOPES_SUPPORTED,
} from '@/lib/constants'
diff --git a/services/mcp/src/hono/request-utils.ts b/services/mcp/src/hono/request-utils.ts
index 0d0f10a8682b..9b7f3d2567aa 100644
--- a/services/mcp/src/hono/request-utils.ts
+++ b/services/mcp/src/hono/request-utils.ts
@@ -1,6 +1,6 @@
import { z } from 'zod'
-import { mapErrorToAuthResponse, mapKnownErrorMessage, validateBearerToken } from '@/lib/auth-errors'
+import { mapErrorToAuthResponse, validateBearerToken } from '@/lib/auth-errors'
import { getPostHogClient } from '@/lib/posthog'
import {
type ClientInfo,
@@ -111,11 +111,3 @@ export function handleCatchError(error: unknown, props: RequestProperties): Resp
} catch {}
return new Response('Internal server error', { status: 500 })
}
-
-export async function passThrough(response: Response): Promise<Response> {
- if (response.ok) {
- return response
- }
- const body = await response.clone().text()
- return mapKnownErrorMessage(body) ?? response
-}
diff --git a/services/mcp/src/lib/constants.ts b/services/mcp/src/lib/constants.ts
index 587873529a48..63134c6db1b9 100644
--- a/services/mcp/src/lib/constants.ts
+++ b/services/mcp/src/lib/constants.ts
@@ -11,7 +11,6 @@ export {
isCloudApi,
isLocalApi,
MCP_DOCS_URL,
- OAUTH_PROXY_URL,
OAUTH_SCOPES_SUPPORTED,
} from './oauth-constants'
diff --git a/services/mcp/src/resources/index.ts b/services/mcp/src/resources/index.ts
index f362ea1e4f90..593526e4f18a 100644
--- a/services/mcp/src/resources/index.ts
+++ b/services/mcp/src/resources/index.ts
@@ -1,7 +1,4 @@
import type { ResourceManifest } from './manifest-types'
-import { fetchContextMillResources, filterValidEntries, loadManifestFromArchive } from './internals'
-
-export { fetchContextMillResources, filterValidEntries, loadManifestFromArchive }
export async function getPromptsFromManifest(): Promise<ResourceManifest['resources']['prompts']> {
return []
diff --git a/services/mcp/src/resources/manifest-loader.ts b/services/mcp/src/resources/manifest-loader.ts
index df8592f7a6da..690bc06835c0 100644
--- a/services/mcp/src/resources/manifest-loader.ts
+++ b/services/mcp/src/resources/manifest-loader.ts
@@ -1,46 +1,4 @@
-import { type Unzipped, strFromU8 } from 'fflate'
-
-import type { ContextMillManifest, ResourceManifest } from './manifest-types'
-
-const MANIFEST_FILENAME = 'manifest.json'
-
-/**
- * Load and parse the manifest from the unzipped archive
- */
-export function loadManifest(archive: Unzipped): ResourceManifest {
- const manifestData = archive[MANIFEST_FILENAME]
-
- if (!manifestData) {
- throw new Error(`Manifest file "${MANIFEST_FILENAME}" not found in archive`)
- }
-
- const manifestJson = strFromU8(manifestData)
-
- const manifest = JSON.parse(manifestJson) as ResourceManifest
-
- // Validate manifest version
- if (!manifest.version) {
- throw new Error('Manifest is missing required "version" field')
- }
-
- if (!manifest.resources || typeof manifest.resources !== 'object') {
- throw new Error('Manifest is missing required "resources" object')
- }
-
- if (!Array.isArray(manifest.resources.workflows)) {
- throw new Error('Manifest resources is missing "workflows" array')
- }
-
- if (!Array.isArray(manifest.resources.docs)) {
- throw new Error('Manifest resources is missing "docs" array')
- }
-
- if (!Array.isArray(manifest.resources.prompts)) {
- throw new Error('Manifest resources is missing "prompts" array')
- }
-
- return manifest
-}
+import type { ContextMillManifest } from './manifest-types'
/**
* Validate a context-mill manifest object
diff --git a/services/mcp/src/schema/properties.ts b/services/mcp/src/schema/properties.ts
deleted file mode 100644
index 82e2394d13b6..000000000000
--- a/services/mcp/src/schema/properties.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export interface PropertyDefinition {
- name: string
- property_type?: 'String' | 'Numeric' | 'Boolean' | 'DateTime' | null
-}
-
-export interface EventDefinition {
- name: string
- last_seen_at?: string | null
-}
diff --git a/services/mcp/src/schema/tool-inputs.ts b/services/mcp/src/schema/tool-inputs.ts
index a44abf1452fc..9a8c938aa753 100644
--- a/services/mcp/src/schema/tool-inputs.ts
+++ b/services/mcp/src/schema/tool-inputs.ts
@@ -1,7 +1,5 @@
import { z } from 'zod'
-import { PropertyFilter } from './query'
-
export const ExternalDataJobsAfterSchema = z
.string()
.describe('ISO timestamp — only return jobs created after this date (e.g. "2025-01-01T00:00:00Z").')
@@ -148,10 +146,6 @@ export const PromptListInputSchema = z.object({
),
})
-export const DocumentationSearchSchema = z.object({
- query: z.string(),
-})
-
export const FeedbackSubmitSchema = z.object({
summary: z
.string()
@@ -194,7 +188,7 @@ export const FeedbackSubmitSchema = z.object({
.string()
.optional()
.describe(
- 'Clear, concise bullet points describing friction with the MCP server itself — what slowed you down or made you guess. Quote the exact tool name, parameter, or error text. Keep it about the MCP, not the user\'s task or data.'
+ "Clear, concise bullet points describing friction with the MCP server itself — what slowed you down or made you guess. Quote the exact tool name, parameter, or error text. Keep it about the MCP, not the user's task or data."
),
suggested_improvement: z
.string()
@@ -225,231 +219,6 @@ export const ExperimentResultsGetSchema = z.object({
.describe('Force refresh of results instead of using cached values. Defaults to false.'),
})
-/**
- * User-friendly input schema for experiment updates
- * This provides a simplified interface that gets transformed to API format
- */
-export const ExperimentUpdateInputSchema = z.object({
- name: z.string().optional().describe('Update experiment name'),
-
- description: z.string().optional().describe('Update experiment description'),
-
- // Primary metrics with guidance
- primary_metrics: z
- .array(
- z.object({
- name: z.string().optional().describe('Human-readable metric name'),
- metric_type: z
- .enum(['mean', 'funnel', 'ratio'])
- .describe(
- "Metric type: 'mean' for average values, 'funnel' for conversion flows, 'ratio' for comparing two metrics"
- ),
- event_name: z.string().describe("PostHog event name (e.g., '$pageview', 'add_to_cart', 'purchase')"),
- funnel_steps: z
- .array(z.string())
- .optional()
- .describe('For funnel metrics only: Array of event names for each funnel step'),
- properties: z
- .array(PropertyFilter)
- .optional()
- .describe(
- 'Event property filters as an array, e.g. [{ key: "$browser", value: "Chrome", operator: "exact", type: "event" }]'
- ),
- description: z.string().optional().describe('What this metric measures'),
- })
- )
- .optional()
- .describe('Update primary metrics'),
-
- secondary_metrics: z
- .array(
- z.object({
- name: z.string().optional().describe('Human-readable metric name'),
- metric_type: z.enum(['mean', 'funnel', 'ratio']).describe('Metric type'),
- event_name: z.string().describe('PostHog event name'),
- funnel_steps: z.array(z.string()).optional().describe('For funnel metrics only: Array of event names'),
- properties: z
- .array(PropertyFilter)
- .optional()
- .describe(
- 'Event property filters as an array, e.g. [{ key: "$browser", value: "Chrome", operator: "exact", type: "event" }]'
- ),
- description: z.string().optional().describe('What this metric measures'),
- })
- )
- .optional()
- .describe('Update secondary metrics'),
-
- minimum_detectable_effect: z.number().optional().describe('Update minimum detectable effect in percentage'),
-
- // Experiment state management
- launch: z.boolean().optional().describe('Launch experiment (set start_date) or keep as draft'),
-
- conclude: z
- .enum(['won', 'lost', 'inconclusive', 'stopped_early', 'invalid'])
- .optional()
- .describe('Conclude experiment with result'),
-
- conclusion_comment: z.string().optional().describe('Comment about experiment conclusion'),
-
- restart: z
- .boolean()
- .optional()
- .describe('Restart concluded experiment as draft (clears start_date, end_date, and conclusion)'),
-
- archive: z.boolean().optional().describe('Archive or unarchive experiment'),
-})
-
-export const ExperimentUpdateSchema = z.object({
- experimentId: z.number().describe('The ID of the experiment to update'),
- data: ExperimentUpdateInputSchema.describe('The experiment data to update using user-friendly format'),
-})
-
-export const ExperimentCreateSchema = z.object({
- name: z.string().min(1).describe('Experiment name - should clearly describe what is being tested'),
-
- description: z
- .string()
- .optional()
- .describe(
- 'Detailed description of the experiment hypothesis, what changes are being tested, and expected outcomes'
- ),
-
- feature_flag_key: z
- .string()
- .describe(
- 'Feature flag key (letters, numbers, hyphens, underscores only). IMPORTANT: First search for existing feature flags that might be suitable using the feature-flags-get-all tool, then suggest reusing existing ones or creating a new key based on the experiment name'
- ),
-
- // Primary metrics with guidance
- primary_metrics: z
- .array(
- z.object({
- name: z.string().optional().describe('Human-readable metric name'),
- metric_type: z
- .enum(['mean', 'funnel', 'ratio'])
- .describe(
- "Metric type: 'mean' for average values (revenue, time spent), 'funnel' for conversion flows, 'ratio' for comparing two metrics"
- ),
- event_name: z
- .string()
- .describe(
- "REQUIRED for metrics to work: PostHog event name (e.g., '$pageview', 'add_to_cart', 'purchase'). For funnels, this is the first step. Use '$pageview' if unsure. Search project-property-definitions tool for available events."
- ),
- funnel_steps: z
- .array(z.string())
- .optional()
- .describe(
- "For funnel metrics only: Array of event names for each funnel step (e.g., ['product_view', 'add_to_cart', 'checkout', 'purchase'])"
- ),
- properties: z
- .array(PropertyFilter)
- .optional()
- .describe(
- 'Event property filters as an array, e.g. [{ key: "$browser", value: "Chrome", operator: "exact", type: "event" }]'
- ),
- description: z
- .string()
- .optional()
- .describe("What this metric measures and why it's important for the experiment"),
- })
- )
- .optional()
- .describe(
- 'Primary metrics to measure experiment success. IMPORTANT: Each metric needs event_name to track data. For funnels, provide funnel_steps array with event names for each step. Ask user what events they track, or use project-property-definitions to find available events.'
- ),
-
- // Secondary metrics for additional insights
- secondary_metrics: z
- .array(
- z.object({
- name: z.string().optional().describe('Human-readable metric name'),
- metric_type: z
- .enum(['mean', 'funnel', 'ratio'])
- .describe(
- "Metric type: 'mean' for average values, 'funnel' for conversion flows, 'ratio' for comparing two metrics"
- ),
- event_name: z.string().describe("REQUIRED: PostHog event name. Use '$pageview' if unsure."),
- funnel_steps: z
- .array(z.string())
- .optional()
- .describe('For funnel metrics only: Array of event names for each funnel step'),
- properties: z
- .array(PropertyFilter)
- .optional()
- .describe(
- 'Event property filters as an array, e.g. [{ key: "$browser", value: "Chrome", operator: "exact", type: "event" }]'
- ),
- description: z.string().optional().describe('What this secondary metric measures'),
- })
- )
- .optional()
- .describe(
- 'Secondary metrics to monitor for potential side effects or additional insights. Each metric needs event_name.'
- ),
-
- // Feature flag variants
- variants: z
- .array(
- z.object({
- key: z.string().describe("Variant key (e.g., 'control', 'variant_a', 'new_design')"),
- name: z.string().optional().describe('Human-readable variant name'),
- split_percent: z
- .number()
- .min(0)
- .max(100)
- .optional()
- .describe(
- 'Percentage of traffic allocated to this variant (0-100). All variants must sum to 100. One of split_percent (recommended) or rollout_percentage (deprecated) must be provided per variant.'
- ),
- rollout_percentage: z
- .number()
- .min(0)
- .max(100)
- .optional()
- .describe('Deprecated: use split_percent instead. Accepted for backward compatibility.'),
- })
- )
- .optional()
- .describe(
- 'Experiment variants. If not specified, defaults to 50/50 control/test split. Ask user how many variants they need and what each tests'
- ),
-
- // Experiment parameters
- minimum_detectable_effect: z
- .number()
- .default(30)
- .describe(
- 'Minimum detectable effect in percentage. Lower values require more users but detect smaller changes. Suggest 20-30% for most experiments'
- ),
-
- // Exposure and targeting
- filter_test_accounts: z.boolean().default(true).describe('Whether to filter out internal test accounts'),
-
- target_properties: z
- .record(z.string(), z.any())
- .optional()
- .describe('Properties to target specific user segments (e.g., country, subscription type)'),
-
- // Control flags
- draft: z
- .boolean()
- .default(true)
- .describe('Create as draft (true) or launch immediately (false). Recommend draft for review first'),
-
- holdout_id: z
- .number()
- .optional()
- .describe('Holdout group ID if this experiment should exclude users from other experiments'),
-
- allow_unknown_events: z
- .boolean()
- .optional()
- .describe(
- "Suppresses the validation that rejects metrics referencing events not yet ingested by this project. REQUIRES explicit user confirmation before being set to true — never flip this silently to retry a failed call. The default validation catches typo'd event names and missing instrumentation. Set this to true only when the user has confirmed the event is intentional (e.g. they are about to instrument it)."
- ),
-})
-
export const InsightQueryInputSchema = z.object({
insightId: z.string().describe('The insight ID or short_id to run.'),
output_format: z
@@ -511,8 +280,6 @@ export const ProjectSetActiveSchema = z.object({
projectId: z.number().int().positive(),
})
-export const SurveyResponseCountsSchema = z.object({})
-
// Debug MCP UI Apps
export const DebugMcpUiAppsSchema = z.object({
message: z.string().optional().describe('Optional message to include in the debug data'),
diff --git a/services/mcp/src/tools/insights/utils.ts b/services/mcp/src/tools/insights/utils.ts
index 52915653153a..aae4865bdb7f 100644
--- a/services/mcp/src/tools/insights/utils.ts
+++ b/services/mcp/src/tools/insights/utils.ts
@@ -1,24 +1,3 @@
-import type { Context } from '@/tools/types'
-
export const isShortId = (id: string): boolean => {
return /^[A-Za-z0-9]{8}$/.test(id)
}
-
-export const resolveInsightId = async (context: Context, insightId: string, projectId: string): Promise<number> => {
- if (isShortId(insightId)) {
- const result = await context.api.insights({ projectId }).get({ insightId })
-
- if (!result.success) {
- throw new Error(`Failed to resolve insight: ${result.error.message}`)
- }
-
- return result.data.id
- }
-
- const numericId = Number.parseInt(insightId, 10)
- if (Number.isNaN(numericId)) {
- throw new Error(`Invalid insight ID format: ${insightId}`)
- }
-
- return numericId
-}
diff --git a/services/mcp/src/tools/posthogAiTools/index.ts b/services/mcp/src/tools/posthogAiTools/index.ts
index 19ebd96c6011..d3f098dd45ad 100644
--- a/services/mcp/src/tools/posthogAiTools/index.ts
+++ b/services/mcp/src/tools/posthogAiTools/index.ts
@@ -4,4 +4,3 @@ export { default as externalDataSourcesJobs } from './externalDataSourcesJobs'
export { default as externalDataSyncLogs } from './externalDataSyncLogs'
export { default as readDataSchema } from './readDataSchema'
export { default as readDataWarehouseSchema } from './readDataWarehouseSchema'
-export { invokeMcpTool, type McpToolResult } from './invokeTool'
diff --git a/services/mcp/src/ui-apps/analytics/index.ts b/services/mcp/src/ui-apps/analytics/index.ts
deleted file mode 100644
index 4704de847af0..000000000000
--- a/services/mcp/src/ui-apps/analytics/index.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-export {
- initPostHog,
- identifyUser,
- capture,
- captureAppConnected,
- captureAppConnectionError,
- captureToolInput,
- captureToolResult,
- captureToolCancelled,
- captureHostContextChanged,
- captureLinkOpened,
- captureDisplayModeRequested,
-} from './posthog'
diff --git a/services/mcp/src/ui-apps/analytics/posthog.ts b/services/mcp/src/ui-apps/analytics/posthog.ts
index e0a71842a130..ad3407762f0d 100644
--- a/services/mcp/src/ui-apps/analytics/posthog.ts
+++ b/services/mcp/src/ui-apps/analytics/posthog.ts
@@ -157,10 +157,3 @@ export function captureHostContextChanged(params: {
export function captureLinkOpened(url: string): void {
capture('mcp_ui_app_link_opened', { url })
}
-
-/**
- * Capture display mode change requested.
- */
-export function captureDisplayModeRequested(mode: string): void {
- capture('mcp_ui_app_display_mode_requested', { mode })
-}
diff --git a/services/mcp/src/ui-apps/apps/visual-review-snapshots.tsx b/services/mcp/src/ui-apps/apps/visual-review-snapshots.tsx
index c8c33dc30b1b..e3f81ea1ae8c 100644
--- a/services/mcp/src/ui-apps/apps/visual-review-snapshots.tsx
+++ b/services/mcp/src/ui-apps/apps/visual-review-snapshots.tsx
@@ -82,7 +82,9 @@ function VisualReviewSnapshotsContent({
const result = await app.callServerTool({ name: toolName, arguments: args })
if (result.isError) {
- const message = result.content?.find((c) => c.type === 'text')?.text ?? `${action} failed.`
+ const message =
+ result.content?.find((c): c is { type: 'text'; text: string } => c.type === 'text')?.text ??
+ `${action} failed.`
updateState(snapshot.id, { loadingAs: null, error: message })
return
}
diff --git a/services/mcp/src/ui-apps/components/index.ts b/services/mcp/src/ui-apps/components/index.ts
deleted file mode 100644
index 2e252ddde451..000000000000
--- a/services/mcp/src/ui-apps/components/index.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-// Main entry point - routes to the correct visualizer based on _visualization field
-export { Component } from './Component'
-
-// Smart visualizers - transform structured data for rendering
-export { TrendsVisualizer } from './TrendsVisualizer'
-export { FunnelVisualizer } from './FunnelVisualizer'
-export { LifecycleVisualizer } from './LifecycleVisualizer'
-export { RetentionVisualizer } from './RetentionVisualizer'
-export { TableVisualizer } from './TableVisualizer'
-// Dumb chart components - receive pre-processed data
-export * from './charts'
-
-export * from './types'
-export * from './utils'
diff --git a/services/mcp/src/ui-apps/hooks/index.ts b/services/mcp/src/ui-apps/hooks/index.ts
deleted file mode 100644
index 0b66c4f39411..000000000000
--- a/services/mcp/src/ui-apps/hooks/index.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export { useToolResult, type UseToolResultOptions, type UseToolResultReturn } from './useToolResult'
-
-// Re-export capture for direct usage in components
-export { capture } from '../analytics/posthog'
-
-// Re-export types for convenience
-export type { AnalyticsMetadata, WithAnalytics, ExtractData } from '../types'
-export { hasAnalytics, extractAnalytics } from '../types'
diff --git a/services/mcp/tests/global-setup.ts b/services/mcp/tests/global-setup.ts
new file mode 100644
index 000000000000..812348ba4d54
--- /dev/null
+++ b/services/mcp/tests/global-setup.ts
@@ -0,0 +1,31 @@
+// vitest globalSetup for the default (unit + workers) suite.
+//
+// `src/hono/dispatcher.ts` and `tests/unit/exec.test.ts` import
+// `@shared/guidelines.md`, which the `@shared/*` tsconfig alias maps to
+// `shared/guidelines.md`. That file is gitignored and produced by
+// `scripts/copy-instructions.ts`, so we materialize it once before the suite runs —
+// otherwise the import fails to resolve on a fresh checkout or in any CI job that
+// doesn't run a separate pre-build step first.
+
+import { spawnSync } from 'node:child_process'
+import { resolve } from 'node:path'
+
+const MCP_DIR = resolve(__dirname, '..')
+
+// Spawned (rather than imported and called) because copy-instructions.ts relies on
+// CommonJS globals (`__dirname`, `require.main`) that aren't reliably present in
+// vitest's ESM module runner; running it through tsx keeps it in its native context.
+export function copySharedInstructions(): void {
+ const result = spawnSync('pnpm', ['exec', 'tsx', 'scripts/copy-instructions.ts'], {
+ cwd: MCP_DIR,
+ stdio: 'inherit',
+ env: process.env,
+ })
+ if (result.status !== 0) {
+ throw new Error(`copy-instructions failed (exit code ${result.status})`)
+ }
+}
+
+export async function setup(): Promise<void> {
+ copySharedInstructions()
+}
diff --git a/services/mcp/tests/integration/global-setup.ts b/services/mcp/tests/integration/global-setup.ts
index b25c58004b69..8253a6bade8f 100644
--- a/services/mcp/tests/integration/global-setup.ts
+++ b/services/mcp/tests/integration/global-setup.ts
@@ -10,6 +10,8 @@ import { spawnSync } from 'node:child_process'
import { existsSync, readdirSync } from 'node:fs'
import { resolve } from 'node:path'
+import { copySharedInstructions } from '../global-setup'
+
const MCP_DIR = resolve(__dirname, '..', '..')
const UI_APPS_DIR = resolve(MCP_DIR, 'public', 'ui-apps')
@@ -21,6 +23,9 @@ function uiAppsAlreadyBuilt(): boolean {
}
export async function setup(): Promise<void> {
+ // Always run first: the dispatcher imports `@shared/guidelines.md`, which must be
+ // on disk regardless of whether the UI app bundles are already cached below.
+ copySharedInstructions()
if (uiAppsAlreadyBuilt()) {
return
}
diff --git a/services/mcp/vitest.config.mts b/services/mcp/vitest.config.mts
index 06d8de7288ed..ede36fd41984 100644
--- a/services/mcp/vitest.config.mts
+++ b/services/mcp/vitest.config.mts
@@ -23,6 +23,9 @@ const markdownLoader = {
// aren't suitable for the default run.
export default defineConfig({
test: {
+ // Materializes `shared/guidelines.md` (imported via the `@shared/*` alias by the
+ // dispatcher and the unit suite) before any project runs — see tests/global-setup.ts.
+ globalSetup: ['tests/global-setup.ts'],
projects: [
{
plugins: [tsconfigPaths({ root: '.' }), markdownLoader],