: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
feat(mcp): add mcp-session-id to logs (#58443)
Lucas Ricoy9f31ad60b8f9
diff --git a/services/mcp/src/lib/logging.ts b/services/mcp/src/lib/logging.tsindex 88699d0798bf..174c24f194e8 100644--- a/services/mcp/src/lib/logging.ts+++ b/services/mcp/src/lib/logging.ts@@ -42,11 +42,16 @@ export function withLogging<Props>(handler: FetchHandler<Props>) {method: request.method,pathname: url.pathname,search: url.search,+ mcpSessionId: request.headers.get('mcp-session-id') ?? undefined,headers,})try {const response = await handler(request, env, ctx, log)+ const responseSessionId = response.headers.get('mcp-session-id')+ if (responseSessionId && responseSessionId !== request.headers.get('mcp-session-id')) {+ log.extend({ mcpSessionId: responseSessionId })+ }log.emit(response.status)return response} catch (error) {