@posthog/mcp 0.15.0 → 0.16.1

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 (59) hide show
  1. package/README.md +69 -0
  2. package/dist/extensions/constants.d.ts +9 -0
  3. package/dist/extensions/constants.d.ts.map +1 -1
  4. package/dist/extensions/constants.js +9 -0
  5. package/dist/extensions/constants.mjs +9 -0
  6. package/dist/extensions/event-types.d.ts +1 -0
  7. package/dist/extensions/event-types.d.ts.map +1 -1
  8. package/dist/extensions/event-types.js +1 -0
  9. package/dist/extensions/event-types.mjs +1 -0
  10. package/dist/extensions/feedback.d.ts +41 -0
  11. package/dist/extensions/feedback.d.ts.map +1 -0
  12. package/dist/extensions/feedback.js +261 -0
  13. package/dist/extensions/feedback.mjs +202 -0
  14. package/dist/extensions/instrument-highlevel.d.ts.map +1 -1
  15. package/dist/extensions/instrument-highlevel.js +19 -1
  16. package/dist/extensions/instrument-highlevel.mjs +20 -2
  17. package/dist/extensions/instrument-lowlevel.d.ts.map +1 -1
  18. package/dist/extensions/instrument-lowlevel.js +19 -1
  19. package/dist/extensions/instrument-lowlevel.mjs +20 -2
  20. package/dist/extensions/instrumentation.d.ts +30 -13
  21. package/dist/extensions/instrumentation.d.ts.map +1 -1
  22. package/dist/extensions/instrumentation.js +27 -7
  23. package/dist/extensions/instrumentation.mjs +27 -7
  24. package/dist/extensions/mcp-payloads.d.ts +9 -3
  25. package/dist/extensions/mcp-payloads.d.ts.map +1 -1
  26. package/dist/extensions/mcp-payloads.js +16 -7
  27. package/dist/extensions/mcp-payloads.mjs +11 -5
  28. package/dist/extensions/posthog-events.d.ts.map +1 -1
  29. package/dist/extensions/posthog-events.js +1 -0
  30. package/dist/extensions/posthog-events.mjs +1 -0
  31. package/dist/extensions/posthog-mcp.d.ts +28 -4
  32. package/dist/extensions/posthog-mcp.d.ts.map +1 -1
  33. package/dist/extensions/posthog-mcp.js +27 -1
  34. package/dist/extensions/posthog-mcp.mjs +27 -1
  35. package/dist/extensions/sanitization.js +1 -1
  36. package/dist/extensions/sanitization.mjs +2 -2
  37. package/dist/index.d.ts +2 -1
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +10 -0
  40. package/dist/index.mjs +5 -1
  41. package/dist/types.d.ts +119 -1
  42. package/dist/types.d.ts.map +1 -1
  43. package/dist/version.d.ts +1 -1
  44. package/dist/version.js +1 -1
  45. package/dist/version.mjs +1 -1
  46. package/package.json +3 -3
  47. package/src/extensions/constants.ts +9 -0
  48. package/src/extensions/event-types.ts +1 -0
  49. package/src/extensions/feedback.ts +357 -0
  50. package/src/extensions/instrument-highlevel.ts +39 -2
  51. package/src/extensions/instrument-lowlevel.ts +39 -2
  52. package/src/extensions/instrumentation.ts +65 -17
  53. package/src/extensions/mcp-payloads.ts +19 -6
  54. package/src/extensions/posthog-events.ts +1 -0
  55. package/src/extensions/posthog-mcp.ts +85 -4
  56. package/src/extensions/sanitization.ts +3 -3
  57. package/src/index.ts +21 -0
  58. package/src/types.ts +125 -1
  59. package/src/version.ts +1 -1
package/dist/types.d.ts CHANGED
@@ -89,6 +89,20 @@ export interface MCPAnalyticsOptions {
89
89
  logger?: LoggerFn;
90
90
  /** Enable the `get_more_tools` virtual tool so agents can report missing functionality. */
91
91
  reportMissing?: boolean;
92
+ /**
93
+ * Inject the `send_feedback` virtual tool so agents can send feedback about
94
+ * this server to its developers — a missing capability (the priority
95
+ * category), a tool that failed or confused them, or praise. Calls to it emit
96
+ * `$mcp_feedback` (never a `$mcp_tool_call`). Off by default.
97
+ *
98
+ * `true` uses the defaults; the object form renames the tool, replaces its
99
+ * description, declares host-specific `extraProperties`, or wires an
100
+ * `onFeedback` handler that routes reports to a real backend.
101
+ *
102
+ * Covers what `reportMissing` covers (as `feedback_type: "missing_capability"`),
103
+ * so new integrations should enable only one of the two.
104
+ */
105
+ collectFeedback?: CollectFeedbackConfig;
92
106
  /**
93
107
  * Rename the `get_more_tools` virtual tool (the `reportMissing` feature).
94
108
  * Defaults to `get_more_tools`. Set once here so the tool is advertised and
@@ -163,6 +177,73 @@ export interface MCPAnalyticsOptions {
163
177
  export interface MCPAnalyticsContextOptions {
164
178
  description?: string;
165
179
  }
180
+ export type FeedbackType = 'missing_capability' | 'issue' | 'praise' | 'other';
181
+ export type FeedbackSentiment = 'positive' | 'neutral' | 'negative' | 'mixed';
182
+ /** The `collectFeedback` option: `true` for the defaults, or the object form. */
183
+ export type CollectFeedbackConfig = boolean | CollectFeedbackOptions;
184
+ /**
185
+ * A host-declared input-schema fragment for one `send_feedback` extra property —
186
+ * plain JSON Schema, the same shape the MCP `tools/list` wire format uses.
187
+ */
188
+ export interface FeedbackExtraPropertySchema {
189
+ type: string;
190
+ description?: string;
191
+ enum?: string[];
192
+ [key: string]: unknown;
193
+ }
194
+ /** Object form of {@link CollectFeedbackConfig}. */
195
+ export interface CollectFeedbackOptions {
196
+ /**
197
+ * Rename the `send_feedback` virtual tool. Set once so the tool is advertised
198
+ * and detected under the same name. Defaults to `send_feedback`.
199
+ */
200
+ toolName?: string;
201
+ /** Replace the default tool description. */
202
+ description?: string;
203
+ /**
204
+ * Host-specific fields merged into the tool's advertised input schema. Each
205
+ * declared key is captured as a `$mcp_feedback_<key>` event property (through
206
+ * the standard sanitize/truncate pipeline); arguments the agent invents beyond
207
+ * the schema are never captured. A key that collides with a core field or an
208
+ * SDK-injected argument throws at configuration time.
209
+ */
210
+ extraProperties?: Record<string, FeedbackExtraPropertySchema>;
211
+ /** Keys of `extraProperties` to advertise as required. */
212
+ extraRequired?: string[];
213
+ /**
214
+ * Route each report to a real backend (`instrument()` path only — a custom
215
+ * dispatcher routes reports itself, see {@link PreparedToolCall.isFeedback}).
216
+ * Return a string to replace the default acknowledgement text. A throw is
217
+ * logged and falls back to the default reply; the `$mcp_feedback` event is
218
+ * captured either way. The returned string is captured as `$mcp_response`
219
+ * through the generic sanitize pipeline only — unlike `$mcp_feedback_summary`
220
+ * / `details`, it does not get structured-PII redaction, so avoid echoing
221
+ * the agent's raw report text back in it.
222
+ */
223
+ onFeedback?: (report: FeedbackReport) => MaybePromise<string | void>;
224
+ }
225
+ /** One parsed `send_feedback` call, as handed to `onFeedback` and the dispatcher. */
226
+ export interface FeedbackReport {
227
+ /** Invalid or missing values fall back to `other`. */
228
+ feedbackType: FeedbackType;
229
+ /** One-sentence summary; empty string when the agent omitted it. */
230
+ summary: string;
231
+ sentiment?: FeedbackSentiment;
232
+ frictionPoints?: string;
233
+ suggestedImprovement?: string;
234
+ details?: string;
235
+ /** The existing tool the feedback is about (`tool_name` argument). */
236
+ toolName?: string;
237
+ taskCompleted?: boolean;
238
+ /**
239
+ * Values of the declared `extraProperties` fields that match their declared
240
+ * `type`/`enum`. A value the agent sent with the wrong shape is left out
241
+ * (find it in `raw` if you need it), so these are safe to trust as declared.
242
+ */
243
+ extras: JsonRecord;
244
+ /** The full raw arguments, for the handler only — never captured. */
245
+ raw: JsonRecord;
246
+ }
166
247
  export interface MCPAnalyticsModelOptions {
167
248
  description?: string;
168
249
  }
@@ -551,12 +632,23 @@ export interface PrepareToolListOptions {
551
632
  * {@link PostHogMCP.captureMissingCapability} and reply with `getMoreToolsResult()`.
552
633
  */
553
634
  reportMissing?: boolean;
635
+ /**
636
+ * Append the `send_feedback` virtual tool so agents can send feedback.
637
+ * Defaults to `false`, and requires the `PostHogMCP` constructor's
638
+ * `collectFeedback` option (the enable switch that also gates detection).
639
+ * When the agent calls it, route the call to
640
+ * {@link PostHogMCP.captureFeedback} and reply with `sendFeedbackResult()`.
641
+ */
642
+ collectFeedback?: boolean;
554
643
  }
555
644
  /** Options for {@link PostHogMCP.prepareToolCall}. */
556
645
  export interface PrepareToolCallOptions {
557
646
  /**
558
- * The tool descriptor before PostHog preparation. Pass this on stateless or
647
+ * The tool descriptor before PostHog preparation, from the host's own tool
648
+ * list (the SDK's virtual tools never exist there). Pass this on stateless or
559
649
  * multi-replica servers so SDK argument ownership is resolved per request.
650
+ * Passing it also disambiguates a feedback-tool name collision: a real tool
651
+ * by that name is dispatched normally instead of being flagged as feedback.
560
652
  */
561
653
  originalTool?: {
562
654
  inputSchema?: unknown;
@@ -582,6 +674,20 @@ export interface PreparedToolCall {
582
674
  args?: Record<string, unknown>;
583
675
  /** True when `name` is the `get_more_tools` virtual tool. */
584
676
  isMissingCapability: boolean;
677
+ /**
678
+ * True when `name` is the `send_feedback` virtual tool AND the constructor's
679
+ * `collectFeedback` option is set AND no `originalTool` was supplied. Always
680
+ * false without that opt-in — and a supplied `originalTool` proves a real
681
+ * application tool owns the name — so a real tool that happens to use the
682
+ * name is never shadowed.
683
+ */
684
+ isFeedback: boolean;
685
+ /**
686
+ * The parsed feedback report, set only when {@link PreparedToolCall.isFeedback}
687
+ * is true. Pass it to {@link PostHogMCP.captureFeedback} and to your own
688
+ * feedback backend, then reply with `sendFeedbackResult()` or a custom text.
689
+ */
690
+ feedbackReport?: FeedbackReport;
585
691
  }
586
692
  /** Payload for {@link PostHogMCP.captureMissingCapability}. Emits `$mcp_missing_capability`. */
587
693
  export interface MissingCapabilityCaptureData extends McpCaptureCommon {
@@ -597,4 +703,16 @@ export interface MissingCapabilityCaptureData extends McpCaptureCommon {
597
703
  /** Captured call arguments → `$mcp_parameters` (sanitized + truncated). */
598
704
  parameters?: unknown;
599
705
  }
706
+ /** Payload for {@link PostHogMCP.captureFeedback}. Emits `$mcp_feedback`. */
707
+ export interface FeedbackCaptureData extends McpCaptureCommon {
708
+ /**
709
+ * The parsed report (from {@link PreparedToolCall.feedbackReport}) →
710
+ * `$mcp_feedback_*` properties, with the summary and details as `$mcp_intent`.
711
+ */
712
+ report: FeedbackReport;
713
+ /** The calling model id -> `$mcp_llm_model`. */
714
+ llmModel?: string;
715
+ /** How the model id was obtained -> `$mcp_llm_model_source`. */
716
+ llmModelSource?: MCPAnalyticsModelSource;
717
+ }
600
718
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":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CAAC,EAAE,MAAM,CAAA;IACjB,gEAAgE;IAChE,cAAc,CAAC,EAAE,uBAAuB,CAAA;IACxC,2EAA2E;IAC3E,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,6EAA6E;AAC7E,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D;;;OAGG;IACH,MAAM,EAAE,cAAc,CAAA;IACtB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gEAAgE;IAChE,cAAc,CAAC,EAAE,uBAAuB,CAAA;CACzC"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const version = "0.15.0";
1
+ export declare const version = "0.16.1";
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.15.0';
30
+ const version = '0.16.1';
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.15.0';
1
+ const version = '0.16.1';
2
2
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/mcp",
3
- "version": "0.15.0",
3
+ "version": "0.16.1",
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.52.2"
31
+ "@posthog/core": "^1.53.3"
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.8"
56
+ "posthog-node": "^5.52.1"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "@modelcontextprotocol/sdk": ">=1.26.0",
@@ -25,6 +25,7 @@ export const POSTHOG_MCP_LIB_NAME = 'posthog-node-mcp'
25
25
  export const PostHogMCPAnalyticsEvent = {
26
26
  Custom: '$mcp_custom',
27
27
  Exception: '$exception',
28
+ Feedback: '$mcp_feedback',
28
29
  Identify: '$identify',
29
30
  Initialize: '$mcp_initialize',
30
31
  MissingCapability: '$mcp_missing_capability',
@@ -46,6 +47,14 @@ export const PostHogMCPAnalyticsProperty = {
46
47
  DurationMs: '$mcp_duration_ms',
47
48
  ErrorMessage: '$mcp_error_message',
48
49
  ErrorType: '$mcp_error_type',
50
+ FeedbackDetails: '$mcp_feedback_details',
51
+ FeedbackFrictionPoints: '$mcp_feedback_friction_points',
52
+ FeedbackSentiment: '$mcp_feedback_sentiment',
53
+ FeedbackSuggestedImprovement: '$mcp_feedback_suggested_improvement',
54
+ FeedbackSummary: '$mcp_feedback_summary',
55
+ FeedbackTaskCompleted: '$mcp_feedback_task_completed',
56
+ FeedbackTool: '$mcp_feedback_tool',
57
+ FeedbackType: '$mcp_feedback_type',
49
58
  IsError: '$mcp_is_error',
50
59
  Intent: '$mcp_intent',
51
60
  IntentSource: '$mcp_intent_source',
@@ -13,6 +13,7 @@
13
13
  export const MCPAnalyticsEventType = {
14
14
  identify: 'posthog:identify',
15
15
  custom: 'posthog:custom',
16
+ mcpFeedback: 'mcp:feedback',
16
17
  mcpMissingCapability: 'mcp:missing_capability',
17
18
  mcpInitialize: 'mcp:initialize',
18
19
  mcpPromptsGet: 'mcp:prompts/get',
@@ -0,0 +1,357 @@
1
+ import type {
2
+ CollectFeedbackOptions,
3
+ FeedbackExtraPropertySchema,
4
+ FeedbackReport,
5
+ FeedbackSentiment,
6
+ FeedbackType,
7
+ CollectFeedbackConfig,
8
+ CompatibleTextToolResult,
9
+ CompatibleToolsListLike,
10
+ JsonRecord,
11
+ } from '../types'
12
+ import { PostHogMCPAnalyticsProperty } from './constants'
13
+ import { log, type LoggerFn } from './logger'
14
+ import { sanitizeFreeText, sanitizeFreeTextValue } from './mcp-payloads'
15
+
16
+ export const SEND_FEEDBACK_TOOL_NAME = 'send_feedback' as const
17
+
18
+ const FEEDBACK_TYPES: readonly FeedbackType[] = ['missing_capability', 'issue', 'praise', 'other']
19
+ const SENTIMENTS: readonly FeedbackSentiment[] = ['positive', 'neutral', 'negative', 'mixed']
20
+
21
+ // Free-text fields are agent-narrated, like `$mcp_intent`; bound them the same way.
22
+ const MAX_FEEDBACK_TEXT_LENGTH = 2048
23
+ const MAX_FEEDBACK_TOOL_NAME_LENGTH = 256
24
+ const TRUNCATION_SUFFIX = '...'
25
+
26
+ const DEFAULT_FEEDBACK_DESCRIPTION =
27
+ 'Send feedback about this server to its developers. Most important: report a missing capability whenever no ' +
28
+ 'available tool fits your task, even if you can work around it (feedback_type "missing_capability"). Also ' +
29
+ 'welcome: a tool that failed or confused you, an unhelpful error, or something that worked well. This records ' +
30
+ 'the feedback; it does not add or change tools. Do not include user PII or sensitive content.'
31
+
32
+ const CORE_FEEDBACK_SCHEMA_PROPERTIES = {
33
+ feedback_type: {
34
+ type: 'string',
35
+ enum: [...FEEDBACK_TYPES],
36
+ description:
37
+ "What kind of feedback this is. Use 'missing_capability' when the tool you needed does not exist in the " +
38
+ 'tool list - nothing failed, the capability is absent (this is the most valuable report; send it even if ' +
39
+ "you found a workaround). Use 'issue' when an existing tool behaved badly: it failed, returned a confusing " +
40
+ "error, or its description or schema misled you. Use 'praise' when something worked notably well. Use " +
41
+ "'other' for anything else.",
42
+ },
43
+ summary: {
44
+ type: 'string',
45
+ description:
46
+ "One self-contained sentence. For 'missing_capability': the capability you needed, e.g. 'No tool to " +
47
+ "delete multiple cohorts in one call.' For 'issue': the tool and the problem, e.g. 'query-trends rejects " +
48
+ "relative date ranges with an unclear error.'",
49
+ },
50
+ details: {
51
+ type: 'string',
52
+ description:
53
+ 'Optional longer context: what you tried, exact parameter values, the error text you saw, and any ' +
54
+ 'workaround you used. Omit when the summary says it all.',
55
+ },
56
+ friction_points: {
57
+ type: 'string',
58
+ description:
59
+ 'Optional: the specific moments that slowed you down, as short bullet-like sentences, quoting exact tool ' +
60
+ 'names, parameters, or error text.',
61
+ },
62
+ suggested_improvement: {
63
+ type: 'string',
64
+ description:
65
+ 'Optional: the concrete change that would have helped, e.g. the tool to add, the description to reword, ' +
66
+ 'or the error message to improve.',
67
+ },
68
+ tool_name: {
69
+ type: 'string',
70
+ description:
71
+ "Optional: the existing tool this feedback is about (for 'issue' or 'praise'). Leave empty for " +
72
+ "'missing_capability' - the point is that no tool fits.",
73
+ },
74
+ sentiment: {
75
+ type: 'string',
76
+ enum: [...SENTIMENTS],
77
+ description: 'Optional: how the experience felt overall.',
78
+ },
79
+ task_completed: {
80
+ type: 'boolean',
81
+ description: "Optional: whether you still completed the user's task despite the problem.",
82
+ },
83
+ } as const
84
+
85
+ /**
86
+ * Extra-property names a host may not declare: the core fields themselves, the
87
+ * names whose `$mcp_feedback_<key>` property would collide with a core property
88
+ * (`type` → `$mcp_feedback_type`, `tool` → `$mcp_feedback_tool`), and the
89
+ * SDK-injected analytics arguments — the report is parsed from the raw
90
+ * arguments before those are stripped, so an extra by the same name would
91
+ * capture an SDK-owned value.
92
+ */
93
+ const RESERVED_EXTRA_PROPERTY_KEYS = new Set([
94
+ ...Object.keys(CORE_FEEDBACK_SCHEMA_PROPERTIES),
95
+ 'type',
96
+ 'tool',
97
+ 'context',
98
+ 'conversation_id',
99
+ 'llm_model',
100
+ ])
101
+
102
+ type FeedbackToolDescriptor = CompatibleToolsListLike['tools'][number]
103
+
104
+ /** `collectFeedback` normalized to its object form; `undefined` when the feature is off. */
105
+ export function resolveCollectFeedbackOptions(
106
+ config: CollectFeedbackConfig | undefined
107
+ ): CollectFeedbackOptions | undefined {
108
+ if (!config) {
109
+ return undefined
110
+ }
111
+ return config === true ? {} : config
112
+ }
113
+
114
+ /**
115
+ * The advertised descriptor: the core feedback schema plus the host's declared
116
+ * `extraProperties`. Throws on a config error (a reserved extra key, or an
117
+ * `extraRequired` entry that was never declared) so a bad setup fails at
118
+ * configuration time instead of silently corrupting the advertised schema.
119
+ */
120
+ export function getFeedbackToolDescriptor(options: CollectFeedbackOptions = {}): FeedbackToolDescriptor {
121
+ const extraProperties = options.extraProperties ?? {}
122
+ const extraRequired = options.extraRequired ?? []
123
+
124
+ for (const key of Object.keys(extraProperties)) {
125
+ if (RESERVED_EXTRA_PROPERTY_KEYS.has(key)) {
126
+ throw new Error(
127
+ `collectFeedback.extraProperties key "${key}" collides with a core or SDK-reserved send_feedback field. Rename it.`
128
+ )
129
+ }
130
+ }
131
+ for (const key of extraRequired) {
132
+ if (!Object.prototype.hasOwnProperty.call(extraProperties, key)) {
133
+ throw new Error(`collectFeedback.extraRequired key "${key}" is not declared in extraProperties.`)
134
+ }
135
+ }
136
+
137
+ // Deep copy: the host may reuse or mutate the fragments it handed us.
138
+ const copiedExtras =
139
+ Object.keys(extraProperties).length > 0
140
+ ? (JSON.parse(JSON.stringify(extraProperties)) as Record<string, unknown>)
141
+ : undefined
142
+
143
+ return {
144
+ name: options.toolName ?? SEND_FEEDBACK_TOOL_NAME,
145
+ description: options.description ?? DEFAULT_FEEDBACK_DESCRIPTION,
146
+ inputSchema: {
147
+ type: 'object',
148
+ properties: {
149
+ ...(JSON.parse(JSON.stringify(CORE_FEEDBACK_SCHEMA_PROPERTIES)) as Record<string, unknown>),
150
+ ...copiedExtras,
151
+ },
152
+ required: ['feedback_type', 'summary', ...extraRequired],
153
+ },
154
+ annotations: {
155
+ title: 'Send feedback',
156
+ readOnlyHint: true,
157
+ // Interacts with an external entity: the report lands in analytics.
158
+ openWorldHint: true,
159
+ // Only records the feedback, so repeat calls are harmless — and advertising
160
+ // it as idempotent makes agents more willing to call it proactively.
161
+ idempotentHint: true,
162
+ destructiveHint: false,
163
+ },
164
+ }
165
+ }
166
+
167
+ function readString(value: unknown): string | undefined {
168
+ return typeof value === 'string' && value.trim() ? value : undefined
169
+ }
170
+
171
+ function parseFeedbackType(value: unknown): FeedbackType {
172
+ return FEEDBACK_TYPES.includes(value as FeedbackType) ? (value as FeedbackType) : 'other'
173
+ }
174
+
175
+ function parseSentiment(value: unknown): FeedbackSentiment | undefined {
176
+ return SENTIMENTS.includes(value as FeedbackSentiment) ? (value as FeedbackSentiment) : undefined
177
+ }
178
+
179
+ /**
180
+ * True when the value conforms to the declared fragment's `type` and `enum` —
181
+ * the same advisory-schema enforcement the core fields get, so `extras` only
182
+ * ever holds schema-conforming values and a misbehaving agent shows up as
183
+ * absence rather than as an unexpected shape in the host's handler.
184
+ */
185
+ function matchesExtraSchema(value: unknown, schema: FeedbackExtraPropertySchema): boolean {
186
+ const type = Array.isArray(value) ? 'array' : value === null ? 'null' : typeof value
187
+ if (schema.type === 'integer') {
188
+ // A JSON Schema `integer` accepts a whole-valued number (`3`, `3.0`) but
189
+ // not a fractional one (`3.5`) — `typeof` alone can't tell them apart.
190
+ if (!Number.isInteger(value)) {
191
+ return false
192
+ }
193
+ } else if (schema.type !== type) {
194
+ return false
195
+ }
196
+ return !Array.isArray(schema.enum) || schema.enum.includes(value as string)
197
+ }
198
+
199
+ /**
200
+ * Parses the raw `send_feedback` arguments into a typed report. Never throws:
201
+ * an invalid `feedback_type` falls back to `other`, missing fields stay
202
+ * undefined, and only **declared** extras whose values match their declared
203
+ * `type`/`enum` are lifted into `extras` — mismatches and anything the agent
204
+ * invented reach the handler via `raw` only and are never captured.
205
+ */
206
+ export function parseFeedbackReport(
207
+ args: Record<string, unknown> | undefined,
208
+ options: CollectFeedbackOptions = {}
209
+ ): FeedbackReport {
210
+ const raw = args ?? {}
211
+ const extras: JsonRecord = {}
212
+ for (const [key, schema] of Object.entries(options.extraProperties ?? {})) {
213
+ if (raw[key] !== undefined && matchesExtraSchema(raw[key], schema)) {
214
+ extras[key] = raw[key]
215
+ }
216
+ }
217
+ return {
218
+ feedbackType: parseFeedbackType(raw.feedback_type),
219
+ summary: readString(raw.summary) ?? '',
220
+ sentiment: parseSentiment(raw.sentiment),
221
+ frictionPoints: readString(raw.friction_points),
222
+ suggestedImprovement: readString(raw.suggested_improvement),
223
+ details: readString(raw.details),
224
+ toolName: readString(raw.tool_name),
225
+ taskCompleted: typeof raw.task_completed === 'boolean' ? raw.task_completed : undefined,
226
+ extras,
227
+ raw,
228
+ }
229
+ }
230
+
231
+ /** The report's free text, used as the event's `$mcp_intent`. */
232
+ export function buildFeedbackIntent(report: FeedbackReport): string {
233
+ return [report.summary, report.details].filter(Boolean).join('\n\n')
234
+ }
235
+
236
+ function truncateFeedbackText(value: string, maxLength: number): string {
237
+ return value.length > maxLength ? value.slice(0, maxLength) + TRUNCATION_SUFFIX : value
238
+ }
239
+
240
+ /**
241
+ * Agent-narrated free text can contain a secret the LLM read aloud or personal
242
+ * data it narrated, so it gets exactly the `$mcp_intent` pass (`sanitizeFreeText`:
243
+ * credentials → structured PII → URLs — the order is load-bearing, the URL
244
+ * rewrite would percent-encode the `@` the email pattern anchors on), then a
245
+ * length bound. The event-level pipeline does not process `event.properties`,
246
+ * so this happens here.
247
+ */
248
+ function captureFreeText(value: string): string {
249
+ return truncateFeedbackText(sanitizeFreeText(value), MAX_FEEDBACK_TEXT_LENGTH)
250
+ }
251
+
252
+ /**
253
+ * A declared extra is agent-supplied like the core free-text fields, so its
254
+ * string leaves get the same intent-grade pass (with the key-based redaction
255
+ * `sanitizeFreeTextValue` keeps for nested objects), then non-scalars are
256
+ * JSON-stringified and everything is bounded.
257
+ */
258
+ function captureExtraValue(value: unknown): unknown {
259
+ const sanitized = sanitizeFreeTextValue(value)
260
+ if (typeof sanitized === 'string') {
261
+ return truncateFeedbackText(sanitized, MAX_FEEDBACK_TEXT_LENGTH)
262
+ }
263
+ if (sanitized == null || typeof sanitized === 'number' || typeof sanitized === 'boolean') {
264
+ return sanitized
265
+ }
266
+ try {
267
+ return truncateFeedbackText(JSON.stringify(sanitized), MAX_FEEDBACK_TEXT_LENGTH)
268
+ } catch {
269
+ return undefined
270
+ }
271
+ }
272
+
273
+ /** The `$mcp_feedback_*` event properties for one report, declared extras included. */
274
+ export function buildFeedbackEventProperties(report: FeedbackReport): JsonRecord {
275
+ const properties: JsonRecord = {
276
+ [PostHogMCPAnalyticsProperty.FeedbackType]: report.feedbackType,
277
+ }
278
+ if (report.summary) {
279
+ properties[PostHogMCPAnalyticsProperty.FeedbackSummary] = captureFreeText(report.summary)
280
+ }
281
+ if (report.sentiment) {
282
+ properties[PostHogMCPAnalyticsProperty.FeedbackSentiment] = report.sentiment
283
+ }
284
+ if (report.frictionPoints) {
285
+ properties[PostHogMCPAnalyticsProperty.FeedbackFrictionPoints] = captureFreeText(report.frictionPoints)
286
+ }
287
+ if (report.suggestedImprovement) {
288
+ properties[PostHogMCPAnalyticsProperty.FeedbackSuggestedImprovement] = captureFreeText(report.suggestedImprovement)
289
+ }
290
+ if (report.details) {
291
+ properties[PostHogMCPAnalyticsProperty.FeedbackDetails] = captureFreeText(report.details)
292
+ }
293
+ if (report.toolName) {
294
+ // Nominally an identifier, but the schema can't stop an agent from writing
295
+ // prose into it — so it gets the same intent-grade pass as the other free text.
296
+ properties[PostHogMCPAnalyticsProperty.FeedbackTool] = truncateFeedbackText(
297
+ sanitizeFreeText(report.toolName),
298
+ MAX_FEEDBACK_TOOL_NAME_LENGTH
299
+ )
300
+ }
301
+ if (report.taskCompleted !== undefined) {
302
+ properties[PostHogMCPAnalyticsProperty.FeedbackTaskCompleted] = report.taskCompleted
303
+ }
304
+ for (const [key, value] of Object.entries(report.extras)) {
305
+ const captured = captureExtraValue(value)
306
+ if (captured !== undefined) {
307
+ properties[`$mcp_feedback_${key}`] = captured
308
+ }
309
+ }
310
+ return properties
311
+ }
312
+
313
+ /**
314
+ * The default acknowledgement returned to the agent after it calls
315
+ * `send_feedback`. Reply with this from your dispatcher (custom dispatcher
316
+ * path); the `instrument()` path returns it automatically, or the string your
317
+ * `onFeedback` handler returned instead.
318
+ */
319
+ export function sendFeedbackResult(): CompatibleTextToolResult {
320
+ return {
321
+ content: [
322
+ {
323
+ type: 'text' as const,
324
+ text: "Your feedback was recorded for the server's developers. No additional tools are available - continue with the tools already listed.",
325
+ },
326
+ ],
327
+ }
328
+ }
329
+
330
+ /**
331
+ * Runs the host's `onFeedback` handler (when configured) and builds the reply.
332
+ * A returned non-blank string replaces the default acknowledgement; a thrown
333
+ * handler is logged and falls back to it — feedback capture must never break
334
+ * the agent's turn.
335
+ */
336
+ export async function handleFeedback(
337
+ report: FeedbackReport,
338
+ options: CollectFeedbackOptions = {},
339
+ logger: LoggerFn = log
340
+ ): Promise<CompatibleTextToolResult> {
341
+ // Only the type: the summary is agent-narrated free text (possible PII,
342
+ // newlines for log forging, unbounded length) and does not belong in host logs.
343
+ logger(`Agent feedback reported (${report.feedbackType})`)
344
+ if (options.onFeedback) {
345
+ try {
346
+ const reply = await options.onFeedback(report)
347
+ if (typeof reply === 'string' && reply.trim()) {
348
+ return { content: [{ type: 'text' as const, text: reply }] }
349
+ }
350
+ } catch {
351
+ // The whole thrown value is host-controlled and mutable. Do not log any
352
+ // part of it because it can contain PII or log-forging newlines.
353
+ logger('Warning: onFeedback handler threw; returning the default acknowledgement')
354
+ }
355
+ }
356
+ return sendFeedbackResult()
357
+ }