@posthog/mcp 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +25 -10
  2. package/dist/extensions/constants.d.ts +1 -1
  3. package/dist/extensions/constants.d.ts.map +1 -1
  4. package/dist/extensions/constants.js +1 -1
  5. package/dist/extensions/constants.mjs +1 -1
  6. package/dist/extensions/instrumentation.d.ts.map +1 -1
  7. package/dist/extensions/instrumentation.js +4 -1
  8. package/dist/extensions/instrumentation.mjs +5 -2
  9. package/dist/extensions/mcp-payloads.d.ts +10 -0
  10. package/dist/extensions/mcp-payloads.d.ts.map +1 -1
  11. package/dist/extensions/mcp-payloads.js +64 -0
  12. package/dist/extensions/mcp-payloads.mjs +62 -1
  13. package/dist/extensions/model-parameters.d.ts +20 -13
  14. package/dist/extensions/model-parameters.d.ts.map +1 -1
  15. package/dist/extensions/model-parameters.js +26 -2
  16. package/dist/extensions/model-parameters.mjs +24 -3
  17. package/dist/extensions/posthog-mcp.d.ts +3 -3
  18. package/dist/extensions/posthog-mcp.d.ts.map +1 -1
  19. package/dist/extensions/posthog-mcp.js +8 -9
  20. package/dist/extensions/posthog-mcp.mjs +9 -10
  21. package/dist/extensions/sanitization.d.ts.map +1 -1
  22. package/dist/extensions/sanitization.js +1 -1
  23. package/dist/extensions/sanitization.mjs +2 -2
  24. package/dist/types.d.ts +20 -20
  25. package/dist/types.d.ts.map +1 -1
  26. package/dist/version.d.ts +1 -1
  27. package/dist/version.js +1 -1
  28. package/dist/version.mjs +1 -1
  29. package/package.json +3 -3
  30. package/src/extensions/capture.ts +2 -2
  31. package/src/extensions/constants.ts +1 -1
  32. package/src/extensions/instrumentation.ts +6 -7
  33. package/src/extensions/mcp-payloads.ts +129 -0
  34. package/src/extensions/model-parameters.ts +50 -14
  35. package/src/extensions/posthog-events.ts +2 -2
  36. package/src/extensions/posthog-mcp.ts +11 -15
  37. package/src/extensions/sanitization.ts +8 -5
  38. package/src/types.ts +20 -20
  39. package/src/version.ts +1 -1
@@ -6,7 +6,7 @@ import { captureException } from "./exceptions.mjs";
6
6
  import { normalizeHeaderString } from "./headers.mjs";
7
7
  import { applyMcpLibIdentity } from "./lib-identity.mjs";
8
8
  import { log } from "./logger.mjs";
9
- import { addModelParameterToTool, getModelArgument, getModelDescription, isCaptureModelEnabled, setEventModel } from "./model-parameters.mjs";
9
+ import { addModelParameterToTool, getModelDescription, isCaptureModelEnabled, resolveModel, setEventModel } from "./model-parameters.mjs";
10
10
  import { McpEventSink } from "./sink.mjs";
11
11
  import { GET_MORE_TOOLS_NAME, getReportMissingToolDescriptor } from "./tools.mjs";
12
12
  class PostHogMCP extends PostHog {
@@ -31,8 +31,7 @@ class PostHogMCP extends PostHog {
31
31
  event.isError = data.isError;
32
32
  event.errorType = data.errorType;
33
33
  applyIntent(event, data.intent, data.intentSource);
34
- setEventModel(event, data.llmModel);
35
- if (event.llmModel && data.llmModelSource) event.llmModelSource = data.llmModelSource;
34
+ setEventModel(event, data.llmModel, data.llmModelSource);
36
35
  if (data.isError) event.error = captureException(data.error ?? `Tool ${data.toolName} returned an error`);
37
36
  this.#emit(event);
38
37
  }
@@ -83,17 +82,18 @@ class PostHogMCP extends PostHog {
83
82
  const rawContext = args?.context;
84
83
  const intent = 'string' == typeof rawContext && rawContext.trim() ? rawContext.trim() : void 0;
85
84
  const ownsModel = isCaptureModelEnabled(this.#captureModel) && (options.originalTool ? analyticsOwnsParameter(options.originalTool.inputSchema, 'llm_model') : true === this.#modelParameterOwnership.get(name));
86
- const llmModel = ownsModel ? getModelArgument({
85
+ const resolvedModel = isCaptureModelEnabled(this.#captureModel) ? resolveModel({
87
86
  params: {
88
- arguments: args
87
+ arguments: args,
88
+ _meta: options.requestMeta
89
89
  }
90
- }) : void 0;
90
+ }, ownsModel) : void 0;
91
91
  const strippedArgs = stripContext(args);
92
92
  return {
93
93
  intent,
94
94
  intentSource: intent ? 'context_parameter' : void 0,
95
- llmModel,
96
- llmModelSource: llmModel ? 'self_reported' : void 0,
95
+ llmModel: resolvedModel?.model,
96
+ llmModelSource: resolvedModel?.source,
97
97
  args: ownsModel ? stripOwnedAnalyticsArguments(strippedArgs, {
98
98
  context: false,
99
99
  conversationId: false,
@@ -107,8 +107,7 @@ class PostHogMCP extends PostHog {
107
107
  event.resourceName = this.#missingCapabilityToolName;
108
108
  event.parameters = data.parameters;
109
109
  applyIntent(event, data.context, 'context_parameter');
110
- setEventModel(event, data.llmModel);
111
- if (event.llmModel && data.llmModelSource) event.llmModelSource = data.llmModelSource;
110
+ setEventModel(event, data.llmModel, data.llmModelSource);
112
111
  this.#emit(event);
113
112
  }
114
113
  #emit(event) {
@@ -1 +1 @@
1
- {"version":3,"file":"sanitization.d.ts","sourceRoot":"","sources":["../../src/extensions/sanitization.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAmB,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAShE;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,KAAK,GAAG,QAAQ,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CA2BrE"}
1
+ {"version":3,"file":"sanitization.d.ts","sourceRoot":"","sources":["../../src/extensions/sanitization.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAmB,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAShE;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,KAAK,GAAG,QAAQ,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CA8BrE"}
@@ -40,7 +40,7 @@ function sanitizeEvent(event) {
40
40
  };
41
41
  if (null != result.response) result.response = sanitizeResponse(result.response);
42
42
  if (null != result.parameters) result.parameters = sanitizeParameters(result.parameters);
43
- if (null != result.userIntent) result.userIntent = (0, external_mcp_payloads_js_namespaceObject.sanitizeCapturedValue)(result.userIntent);
43
+ if (null != result.userIntent) result.userIntent = (0, external_mcp_payloads_js_namespaceObject.redactPii)((0, external_mcp_payloads_js_namespaceObject.sanitizeCapturedValue)(result.userIntent));
44
44
  if (null != result.llmModel) result.llmModel = (0, external_mcp_payloads_js_namespaceObject.sanitizeCapturedValue)(result.llmModel);
45
45
  if (null != result.error) result.error = sanitizeExceptionValues(result.error);
46
46
  return result;
@@ -1,4 +1,4 @@
1
- import { sanitizeCapturedValue } from "./mcp-payloads.mjs";
1
+ import { redactPii, sanitizeCapturedValue } from "./mcp-payloads.mjs";
2
2
  function isRecord(value) {
3
3
  return !!value && 'object' == typeof value && !Array.isArray(value);
4
4
  }
@@ -8,7 +8,7 @@ function sanitizeEvent(event) {
8
8
  };
9
9
  if (null != result.response) result.response = sanitizeResponse(result.response);
10
10
  if (null != result.parameters) result.parameters = sanitizeParameters(result.parameters);
11
- if (null != result.userIntent) result.userIntent = sanitizeCapturedValue(result.userIntent);
11
+ if (null != result.userIntent) result.userIntent = redactPii(sanitizeCapturedValue(result.userIntent));
12
12
  if (null != result.llmModel) result.llmModel = sanitizeCapturedValue(result.llmModel);
13
13
  if (null != result.error) result.error = sanitizeExceptionValues(result.error);
14
14
  return result;
package/dist/types.d.ts CHANGED
@@ -58,6 +58,7 @@ export interface CompatibleTextToolResult {
58
58
  isError?: boolean;
59
59
  }
60
60
  export interface MCPRequestParamsLike {
61
+ _meta?: JsonRecord;
61
62
  arguments?: JsonRecord;
62
63
  name?: string;
63
64
  [key: string]: unknown;
@@ -118,17 +119,15 @@ export interface MCPAnalyticsOptions {
118
119
  /** Inject a required `context` parameter on every tool to capture user intent. */
119
120
  context?: boolean | MCPAnalyticsContextOptions;
120
121
  /**
121
- * Inject a required `llm_model` parameter on every tool so the calling agent
122
- * self-reports the model it runs as, captured as `$mcp_llm_model` with
123
- * `$mcp_llm_model_source = "self_reported"`. Off by default.
122
+ * Capture the calling model as `$mcp_llm_model`. Recognized client metadata
123
+ * takes precedence, with an injected `llm_model` parameter as the fallback.
124
+ * Off by default.
124
125
  *
125
- * The MCP wire deliberately carries no model identity, so self-report is the
126
- * only capture path — harnesses inject the model id into the agent's system
127
- * prompt, and agents restate it accurately. Like `clientInfo` in the MCP
128
- * spec, the value is unverified: use it for per-model quality analytics, not
129
- * billing or security. An honest `"unknown"` from the agent is dropped
130
- * rather than captured. Reasoning effort is intentionally not collected —
131
- * agents don't reliably know it, so it would only ever be noise.
126
+ * MCP does not standardize model identity. Some clients expose it through
127
+ * vendor metadata; other harnesses inject it into the agent's system prompt
128
+ * so the agent can restate it. `$mcp_llm_model_source` records which path won.
129
+ * Both paths are unverified: use them for quality analytics, not billing or
130
+ * security. Missing, blank, and `"unknown"` values are dropped.
132
131
  */
133
132
  captureModel?: boolean | MCPAnalyticsModelOptions;
134
133
  /**
@@ -168,7 +167,7 @@ export interface MCPAnalyticsModelOptions {
168
167
  }
169
168
  export type MaybePromise<T> = T | Promise<T>;
170
169
  export type MCPAnalyticsIntentSource = 'context_parameter' | 'inferred';
171
- export type MCPAnalyticsModelSource = 'self_reported';
170
+ export type MCPAnalyticsModelSource = 'client_metadata' | 'self_reported';
172
171
  export type ToolCallback = ((args: unknown, extra: CompatibleRequestHandlerExtra) => CompatibleToolResultLike | Promise<CompatibleToolResultLike>) | ((extra: CompatibleRequestHandlerExtra) => CompatibleToolResultLike | Promise<CompatibleToolResultLike>);
173
172
  export type RegisteredTool = {
174
173
  description?: string;
@@ -217,12 +216,11 @@ export interface Event {
217
216
  eventType: MCPAnalyticsEventType;
218
217
  groups?: Record<string, string>;
219
218
  /**
220
- * The calling agent's self-reported model id → `$mcp_llm_model`. Read off
221
- * the SDK-injected `llm_model` argument (`captureModel` option); unverified
222
- * by design, like the MCP spec's own `clientInfo`.
219
+ * The calling model id → `$mcp_llm_model`. Resolved from recognized client
220
+ * metadata first, then the SDK-injected `llm_model` argument; unverified.
223
221
  */
224
222
  llmModel?: string;
225
- /** How the model id was obtained → `$mcp_llm_model_source`. Always `self_reported` today. */
223
+ /** How the model id was obtained → `$mcp_llm_model_source`. */
226
224
  llmModelSource?: MCPAnalyticsModelSource;
227
225
  /**
228
226
  * Explicit PostHog event name. When set (via `capture(server, { event })`) it
@@ -476,8 +474,8 @@ export interface ToolCallCaptureData extends McpCaptureCommon {
476
474
  */
477
475
  intentSource?: MCPAnalyticsIntentSource;
478
476
  /**
479
- * The calling agent's self-reported model id -> `$mcp_llm_model`. On the
480
- * custom-dispatcher path, read it from {@link PostHogMCP.prepareToolCall}.
477
+ * The calling model id -> `$mcp_llm_model`. On the custom-dispatcher path,
478
+ * read it from {@link PostHogMCP.prepareToolCall}.
481
479
  */
482
480
  llmModel?: string;
483
481
  /** How the model id was obtained -> `$mcp_llm_model_source`. */
@@ -562,6 +560,8 @@ export interface PrepareToolCallOptions {
562
560
  originalTool?: {
563
561
  inputSchema?: unknown;
564
562
  };
563
+ /** The incoming `tools/call` request's `_meta`, used for recognized client model metadata. */
564
+ requestMeta?: JsonRecord;
565
565
  }
566
566
  /**
567
567
  * Result of {@link PostHogMCP.prepareToolCall}: the intent pulled off the
@@ -573,9 +573,9 @@ export interface PreparedToolCall {
573
573
  intent?: string;
574
574
  /** Where the intent came from. Always `context_parameter` here when set. */
575
575
  intentSource?: MCPAnalyticsIntentSource;
576
- /** The agent's self-reported model id, when `captureModel` is enabled and owned by the SDK. */
576
+ /** The calling model id, when `captureModel` is enabled and a supported source provides it. */
577
577
  llmModel?: string;
578
- /** How the model id was obtained. Always `self_reported` when present. */
578
+ /** How the model id was obtained. */
579
579
  llmModelSource?: MCPAnalyticsModelSource;
580
580
  /** The call arguments with SDK-owned `context` and `llm_model` keys removed. */
581
581
  args?: Record<string, unknown>;
@@ -589,7 +589,7 @@ export interface MissingCapabilityCaptureData extends McpCaptureCommon {
589
589
  * on the `get_more_tools` call) → `$mcp_intent`.
590
590
  */
591
591
  context?: string;
592
- /** The calling agent's self-reported model id -> `$mcp_llm_model`. */
592
+ /** The calling model id -> `$mcp_llm_model`. */
593
593
  llmModel?: string;
594
594
  /** How the model id was obtained -> `$mcp_llm_model_source`. */
595
595
  llmModelSource?: MCPAnalyticsModelSource;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAA;AACtF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEnD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEhD,+FAA+F;AAC/F,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC,eAAe,CAAA;AAC3D,qEAAqE;AACrE,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,UAAU,CAAA;AAEjD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAA;IACnB,iBAAiB,CAAC,EAAE,UAAU,CAAA;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,2DAA2D;AAC3D,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,oFAAoF;IACpF,WAAW,CAAC,EAAE,6BAA6B,CAAA;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAA;I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,CAAA;CACnB;AAED,sDAAsD;AACtD,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,0BAA0B,CAAA;IAC9C;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,sDAAsD;AACtD,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,YAAY,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;IACxC,8FAA8F;IAC9F,WAAW,CAAC,EAAE,UAAU,CAAA;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,4EAA4E;IAC5E,YAAY,CAAC,EAAE,wBAAwB,CAAA;IACvC,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,qCAAqC;IACrC,cAAc,CAAC,EAAE,uBAAuB,CAAA;IACxC,gFAAgF;IAChF,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,6DAA6D;IAC7D,mBAAmB,EAAE,OAAO,CAAA;CAC7B;AAED,gGAAgG;AAChG,MAAM,WAAW,4BAA6B,SAAQ,gBAAgB;IACpE;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gEAAgE;IAChE,cAAc,CAAC,EAAE,uBAAuB,CAAA;IACxC,2EAA2E;IAC3E,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const version = "0.13.0";
1
+ export declare const version = "0.14.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -27,7 +27,7 @@ var __webpack_require__ = {};
27
27
  })();
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
- const version = '0.13.0';
30
+ const version = '0.14.0';
31
31
  __webpack_require__.d(__webpack_exports__, {}, {
32
32
  version: version
33
33
  });
package/dist/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- const version = '0.13.0';
1
+ const version = '0.14.0';
2
2
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/mcp",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "bugs": {
5
5
  "url": "https://github.com/PostHog/posthog-js/issues"
6
6
  },
@@ -28,7 +28,7 @@
28
28
  "module": "dist/index.mjs",
29
29
  "types": "dist/index.d.ts",
30
30
  "dependencies": {
31
- "@posthog/core": "^1.50.3"
31
+ "@posthog/core": "^1.51.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/preset-env": "^7.27.1",
@@ -53,7 +53,7 @@
53
53
  "@vitest/coverage-v8": "^1.6.1",
54
54
  "vitest": "^1.6.1",
55
55
  "@posthog-tooling/tsconfig-base": "1.1.1",
56
- "posthog-node": "^5.51.6"
56
+ "posthog-node": "^5.51.7"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "@modelcontextprotocol/sdk": ">=1.26.0",
@@ -81,8 +81,8 @@ export function captureEvent(
81
81
  response: eventInput.response,
82
82
  userIntent: eventInput.userIntent,
83
83
  userIntentSource: eventInput.userIntentSource,
84
- // Self-reported per request (`captureModel`), so like the header-borne
85
- // fields above there is deliberately no sessionInfo fallback.
84
+ // Resolved per request (`captureModel`), so like the header-borne fields
85
+ // above there is deliberately no sessionInfo fallback.
86
86
  llmModel: eventInput.llmModel,
87
87
  llmModelSource: eventInput.llmModelSource,
88
88
  isError: eventInput.isError,
@@ -5,7 +5,7 @@
5
5
 
6
6
  export const INACTIVITY_TIMEOUT_IN_MINUTES = 30
7
7
 
8
- export const DEFAULT_CONTEXT_PARAMETER_DESCRIPTION = `Explain why you are calling this tool and how it fits into the user's overall goal. This parameter is used for analytics and user intent tracking. YOU MUST provide 15-25 words (count carefully). NEVER use first person ('I', 'we', 'you') - maintain third-person perspective. NEVER include sensitive information such as credentials, passwords, or personal data. Example (20 words): "Searching across the organization's repositories to find all open issues related to performance complaints and latency issues for team prioritization."`
8
+ export const DEFAULT_CONTEXT_PARAMETER_DESCRIPTION = `Explain in 15-25 words, in third person, why this tool is called and how it supports the user's goal. For analytics only. You MUST describe only the abstract purpose of the tool call. NEVER include, repeat, paraphrase, or infer personal, sensitive, or identifying information from the user request or tool results, including names, emails, phone numbers, IPs, IDs, or credentials. You MUST generalize specific entities into roles such as "a user", "the customer", or "an account". Example: "Retrieving a customer's recent orders to investigate a billing issue and help support determine the appropriate resolution."`
9
9
 
10
10
  export const DEFAULT_MODEL_PARAMETER_DESCRIPTION = `The exact model identifier you (the assistant) are running as, taken from your system prompt or environment (e.g. "claude-opus-4-8", "gpt-5.2"). Used for analytics only. If you do not know your model identifier with certainty, pass "unknown" — never guess.`
11
11
 
@@ -18,9 +18,9 @@ import { getAnalyticsParameterOwnership, stripOwnedAnalyticsArguments } from './
18
18
  import { addContextParameterToTools, getContextDescription, isContextEnabled } from './context-parameters'
19
19
  import {
20
20
  addModelParameterToTools,
21
- getModelArgument,
22
21
  getModelDescription,
23
22
  isCaptureModelEnabled,
23
+ resolveModel,
24
24
  setEventModel,
25
25
  } from './model-parameters'
26
26
  import {
@@ -271,12 +271,11 @@ async function prepareToolCallEvent(
271
271
 
272
272
  await applyResolvedMetadata(event, data, request, extra)
273
273
  setEventIntent(event, await resolveToolCallIntent(data, request, canCaptureContextIntent, extra))
274
- // Unlike intent, the model is only read under positive ownership: with
275
- // ownership unresolved, `llm_model` may be the application's own argument,
276
- // and recording a customer value as the calling agent's model is worse
277
- // than a gap in coverage.
278
- if (ownership.llmModel) {
279
- setEventModel(event, getModelArgument(request))
274
+ // Client metadata does not collide with an application's tool arguments.
275
+ // Self-report still requires positive ownership before we read `llm_model`.
276
+ if (isCaptureModelEnabled(data.options.captureModel)) {
277
+ const resolvedModel = resolveModel(request, ownership.llmModel)
278
+ setEventModel(event, resolvedModel?.model, resolvedModel?.source)
280
279
  }
281
280
  return { event, requestAttribution }
282
281
  } catch (error) {
@@ -16,6 +16,55 @@ const POSTHOG_TOKEN_PATTERN = /\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g
16
16
  const SENSITIVE_KEY_PATTERN =
17
17
  /^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i
18
18
 
19
+ // PII redaction for the agent-narrated intent string only. `$mcp_intent` is free
20
+ // text the calling LLM writes into the injected `context` argument, so it can
21
+ // carry personal data the model read aloud despite being told not to. We redact
22
+ // well-defined *structured identifiers* — the kind regex can match with high
23
+ // precision. Person names and postal addresses are deliberately out of scope:
24
+ // they need an NER model that a client SDK cannot ship, and naive patterns would
25
+ // over-redact ordinary prose. Patterns are ordered so an earlier pass never eats
26
+ // digits a later pass needs (email before phone, IPs before phone, cards before
27
+ // the generic phone pass). See `redactPii`.
28
+ // Horizontal Unicode spaces (NBSP, narrow NBSP, ideographic space, ...) are what
29
+ // appear when text is copied from web pages or PDFs. `redactPii` normalizes them
30
+ // to an ASCII space first so the separator-based card/phone/SSN candidates match
31
+ // them instead of leaking the identifier they group.
32
+ const UNICODE_SPACE_PATTERN = /[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g
33
+ // Quantifiers are bounded to RFC-ish limits (local-part <=64, domain <=255,
34
+ // TLD <=24) rather than open-ended `+`. Unbounded `+` here is quadratic: on a
35
+ // long run of local-part chars with no valid `.tld`, `replace` rescans from
36
+ // every start position. `$mcp_intent` is attacker-influenceable free text seen
37
+ // before truncation, so an open-ended pattern is a reachable event-loop stall.
38
+ const EMAIL_PATTERN = /[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g
39
+ const IPV4_PATTERN = /\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g
40
+ // Four forms: full 8-group, `::`-terminated (`2001:db8::`), a middle `::`
41
+ // (`2001:db8::8a2e:1`), and a leading `::` (`::1`). The compressed branches use a
42
+ // `(?<![\w:])` boundary so a hex-looking C++ scope like `std::bad` — whose left
43
+ // side is not a valid hex group — is not mistaken for an address, while a
44
+ // genuinely address-shaped `dead::beef` still matches.
45
+ const IPV6_PATTERN =
46
+ /\b(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}\b|(?<![\w:])(?:[0-9A-Fa-f]{1,4}:){1,7}:(?![\w:])|(?<![\w:])(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}(?![\w])|(?<![\w:])::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})(?![\w])/g
47
+ // A separator (space, dot, or dash) is required between the 3-2-4 groups so bare
48
+ // 9-digit IDs are never mistaken for an SSN.
49
+ const US_SSN_PATTERN = /\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g
50
+ // A run of >=13 digits optionally grouped by a single space, dot, dash, or
51
+ // slash. This only marks the numeric region; `redactCardInMatch` then looks for
52
+ // the actual card as a run of whole separator-delimited groups that passes Luhn,
53
+ // so an adjacent field such as an expiry (`4111 1111 1111 1111 12/30`) is not
54
+ // absorbed into a failing check that would leak the card.
55
+ const CREDIT_CARD_CANDIDATE_PATTERN = /\b\d(?:[ ./-]?\d){12,}\b/g
56
+ // Matches each separator-delimited digit group inside a card candidate.
57
+ const DIGIT_GROUP_PATTERN = /\d+/g
58
+ // Phone matching is structural rather than "any 10–15 digits", so dates
59
+ // (`2024-01-15 12:30`) and dotted versions are not mistaken for numbers. Two
60
+ // forms: a North-American 3-3-4 grouping, and an international number that must
61
+ // start with `+` and a country code. The area code is either `(415)` (the
62
+ // separator after it is optional, so `(415)555-0142` matches) or a bare `415`
63
+ // that must be followed by a separator (space, dot, dash, or slash) — so a bare
64
+ // digit run is never taken for a phone number.
65
+ const PHONE_NANP_PATTERN = /(?<![\w+])(?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4}(?![\w])/g
66
+ const PHONE_INTL_PATTERN = /(?<!\w)\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13}(?![\w])/g
67
+
19
68
  type JsonRecord = Record<string, unknown>
20
69
 
21
70
  function isRecord(value: unknown): value is JsonRecord {
@@ -54,6 +103,86 @@ function sanitizeString(value: string): string {
54
103
  return value.replace(POSTHOG_TOKEN_PATTERN, REDACTED_VALUE)
55
104
  }
56
105
 
106
+ function passesLuhn(digits: string): boolean {
107
+ let sum = 0
108
+ let double = false
109
+ for (let index = digits.length - 1; index >= 0; index--) {
110
+ let digit = digits.charCodeAt(index) - 48
111
+ if (digit < 0 || digit > 9) {
112
+ return false
113
+ }
114
+ if (double) {
115
+ digit *= 2
116
+ if (digit > 9) {
117
+ digit -= 9
118
+ }
119
+ }
120
+ sum += digit
121
+ double = !double
122
+ }
123
+ return sum % 10 === 0
124
+ }
125
+
126
+ // A card candidate can span more than one card plus adjacent fields (e.g. an
127
+ // expiry, or a second card). This redacts every card in it: scanning
128
+ // left-to-right over the whole separator-delimited digit groups, at each start it
129
+ // takes the longest run whose joined digits are 13–19 long and pass Luhn, redacts
130
+ // just that span, and resumes after it; a group that begins no valid run is kept
131
+ // and skipped. Checking group-aligned runs rather than arbitrary digit windows
132
+ // keeps the false-positive rate at Luhn's own ~1-in-10, instead of letting a
133
+ // chance-valid sub-window of an ordinary long ID trigger redaction.
134
+ function redactCardInMatch(match: string): string {
135
+ const groups: { digits: string; start: number; end: number }[] = []
136
+ for (let m = DIGIT_GROUP_PATTERN.exec(match); m !== null; m = DIGIT_GROUP_PATTERN.exec(match)) {
137
+ groups.push({ digits: m[0], start: m.index, end: m.index + m[0].length })
138
+ }
139
+ let output = ''
140
+ let cursor = 0
141
+ let first = 0
142
+ while (first < groups.length) {
143
+ let digits = ''
144
+ let matchedLast = -1
145
+ for (let last = first; last < groups.length; last++) {
146
+ digits += groups[last].digits
147
+ if (digits.length > 19) {
148
+ break
149
+ }
150
+ if (digits.length >= 13 && passesLuhn(digits)) {
151
+ matchedLast = last
152
+ }
153
+ }
154
+ if (matchedLast >= 0) {
155
+ output += match.slice(cursor, groups[first].start) + REDACTED_VALUE
156
+ cursor = groups[matchedLast].end
157
+ first = matchedLast + 1
158
+ } else {
159
+ first++
160
+ }
161
+ }
162
+ return output + match.slice(cursor)
163
+ }
164
+
165
+ /**
166
+ * Redacts structured personal identifiers (emails, IP addresses, credit-card
167
+ * numbers, US SSNs, and phone numbers) from a free-text string. Intended for the
168
+ * agent-narrated `$mcp_intent` value only — not for structured tool parameters or
169
+ * responses, where the same shapes are often legitimate data. Horizontal Unicode
170
+ * spaces are first normalized to an ASCII space so copy-pasted identifiers still
171
+ * match. Returns a new string; leaves the input's identifiers untouched when
172
+ * nothing matches.
173
+ */
174
+ export function redactPii(value: string): string {
175
+ let result = value.replace(UNICODE_SPACE_PATTERN, ' ')
176
+ result = result.replace(EMAIL_PATTERN, REDACTED_VALUE)
177
+ result = result.replace(IPV4_PATTERN, REDACTED_VALUE)
178
+ result = result.replace(IPV6_PATTERN, REDACTED_VALUE)
179
+ result = result.replace(CREDIT_CARD_CANDIDATE_PATTERN, redactCardInMatch)
180
+ result = result.replace(US_SSN_PATTERN, REDACTED_VALUE)
181
+ result = result.replace(PHONE_NANP_PATTERN, REDACTED_VALUE)
182
+ result = result.replace(PHONE_INTL_PATTERN, REDACTED_VALUE)
183
+ return result
184
+ }
185
+
57
186
  export function sanitizeCapturedValue(value: unknown): unknown {
58
187
  if (value == null) {
59
188
  return value
@@ -1,24 +1,21 @@
1
- import type { MCPAnalyticsOptions, MCPRequestLike, McpEvent } from '../types'
1
+ import type { MCPAnalyticsModelSource, MCPAnalyticsOptions, MCPRequestLike, McpEvent } from '../types'
2
2
  import { addAnalyticsParameterToTool, type AnalyticsInjectableJsonSchema } from './analytics-parameters'
3
3
  import { DEFAULT_MODEL_PARAMETER_DESCRIPTION } from './constants'
4
4
  import { log, type LoggerFn } from './logger'
5
5
 
6
6
  /**
7
- * Self-reported model capture (`captureModel`).
7
+ * Model capture (`captureModel`).
8
8
  *
9
- * MCP keeps servers deliberately model-ignorant: the wire carries client
10
- * name/version and protocol version, never the LLM behind the client, and no
11
- * spec revision changes that. The one place the information exists on the
12
- * server side of the connection is the agent itself — harnesses inject the
13
- * model id into the system prompt, so the agent can state it the same way it
14
- * states its intent through the `context` parameter.
9
+ * MCP does not standardize model identity. Some clients expose it through
10
+ * vendor metadata, while other harnesses inject the model id into the system
11
+ * prompt so the agent can state it like intent through the `context` parameter.
15
12
  *
16
13
  * This module injects a required `llm_model` string parameter into every tool
17
14
  * (mirroring `context-parameters.ts`), strips it before the tool runs, and
18
- * captures it as `$mcp_llm_model` with `$mcp_llm_model_source = "self_reported"`.
19
- * The source property is deliberate: like `clientInfo` in the MCP spec, the
20
- * value is self-reported and unverified — right for degradation analytics
21
- * ("does our MCP get worse on model X?"), never for billing or security.
15
+ * captures the best available value as `$mcp_llm_model`. Client metadata wins
16
+ * over self-report, and `$mcp_llm_model_source` preserves that provenance.
17
+ * Both sources are unverified — right for degradation analytics ("does our MCP
18
+ * get worse on model X?"), never for billing or security.
22
19
  *
23
20
  * Reasoning effort is deliberately NOT captured: it never crosses the wire,
24
21
  * and models cannot reliably self-report it (harnesses apply it as a sampling
@@ -77,6 +74,41 @@ export function getModelArgument(request: MCPRequestLike): string | undefined {
77
74
  return normalizeModel(request.params?.arguments?.llm_model)
78
75
  }
79
76
 
77
+ const CODEX_TURN_METADATA_KEY = 'x-codex-turn-metadata'
78
+
79
+ export interface ResolvedModel {
80
+ model: string
81
+ source: MCPAnalyticsModelSource
82
+ }
83
+
84
+ /**
85
+ * Resolves model identity from sources visible to an MCP server. The Codex
86
+ * request metadata is host-generated and therefore more reliable than a model
87
+ * filling an injected argument, but remains unverified client input.
88
+ */
89
+ export function resolveModel(request: MCPRequestLike, allowSelfReported: boolean): ResolvedModel | undefined {
90
+ const codexMetadata = request.params?._meta?.[CODEX_TURN_METADATA_KEY]
91
+ if (isRecord(codexMetadata) && Object.prototype.hasOwnProperty.call(codexMetadata, 'model')) {
92
+ const model = normalizeModel(codexMetadata.model)
93
+ if (model) {
94
+ return { model, source: 'client_metadata' }
95
+ }
96
+ }
97
+
98
+ if (allowSelfReported) {
99
+ const model = getModelArgument(request)
100
+ if (model) {
101
+ return { model, source: 'self_reported' }
102
+ }
103
+ }
104
+
105
+ return undefined
106
+ }
107
+
108
+ function isRecord(value: unknown): value is Record<string, unknown> {
109
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
110
+ }
111
+
80
112
  function normalizeModel(model: unknown): string | undefined {
81
113
  if (typeof model !== 'string') {
82
114
  return undefined
@@ -88,11 +120,15 @@ function normalizeModel(model: unknown): string | undefined {
88
120
  return trimmed
89
121
  }
90
122
 
91
- export function setEventModel(event: McpEvent, model: string | undefined): void {
123
+ export function setEventModel(
124
+ event: McpEvent,
125
+ model: string | undefined,
126
+ source: MCPAnalyticsModelSource = 'self_reported'
127
+ ): void {
92
128
  const normalizedModel = normalizeModel(model)
93
129
  if (!normalizedModel) {
94
130
  return
95
131
  }
96
132
  event.llmModel = normalizedModel
97
- event.llmModelSource = 'self_reported'
133
+ event.llmModelSource = source
98
134
  }
@@ -170,8 +170,8 @@ function addCommonEventProperties(event: Event, properties: Record<string, unkno
170
170
  if (event.userIntentSource) {
171
171
  properties[PostHogMCPAnalyticsProperty.IntentSource] = event.userIntentSource
172
172
  }
173
- // Self-reported by the calling agent (`captureModel`), so present only on the
174
- // requests where the agent supplied a definite value — never inferred.
173
+ // Supplied by recognized client metadata or the calling agent (`captureModel`),
174
+ // so it is present only on requests carrying a definite value.
175
175
  if (event.llmModel) {
176
176
  properties[PostHogMCPAnalyticsProperty.LlmModel] = event.llmModel
177
177
  }