: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
fix(mcp): make posthog-local just work on devboxes (#59500)
Raúl Negrón-Oterof3373e9707ee
diff --git a/.mcp.json b/.mcp.jsonindex a1b79e824e39..f82083e802f5 100644--- a/.mcp.json+++ b/.mcp.json@@ -7,6 +7,10 @@"traffic-sim": {"command": "uv","args": ["run", "python", "tools/traffic-sim/mcp_server.py"]+ },+ "posthog-local": {+ "type": "http",+ "url": "http://localhost:8787/mcp"}}}diff --git a/bin/start-mcp-server b/bin/start-mcp-serverindex 0f473ab85d6d..fba076790d50 100755--- a/bin/start-mcp-server+++ b/bin/start-mcp-server@@ -15,5 +15,23 @@ elseif [ ! -f .dev.vars ]; thencp .dev.vars.example .dev.varsfi++ # SITE_URL on devboxes points at the public per-workspace subdomain; rewrite+ # the three PostHog-pointing keys so MCP's OAuth metadata advertises a host+ # browsers can actually reach. Runs every start (not just first creation) so+ # .dev.vars stays in sync when the workspace subdomain changes.+ loopback_re='^https?://(localhost|127\.0\.0\.1)([:/]|$)'+ if [ -n "${SITE_URL:-}" ] && ! [[ "${SITE_URL}" =~ $loopback_re ]]; then+ tmp=$(mktemp)+ grep -Ev '^(POSTHOG_API_BASE_URL|POSTHOG_MCP_APPS_ANALYTICS_BASE_URL|POSTHOG_ANALYTICS_HOST)=' .dev.vars > "$tmp" || true+ mv "$tmp" .dev.vars+ # Leading \n guards against the prior file missing a trailing newline.+ printf '\n%s\n%s\n%s\n' \+ "POSTHOG_API_BASE_URL=${SITE_URL}" \+ "POSTHOG_MCP_APPS_ANALYTICS_BASE_URL=${SITE_URL}" \+ "POSTHOG_ANALYTICS_HOST=${SITE_URL}" \+ >> .dev.vars+ fi+exec pnpm run devfi