@armature-tech/mcp-analytics 0.6.40 → 0.6.42

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.
@@ -3,7 +3,7 @@ import { defaultMcpAnalyticsConfig } from "./emit.js";
3
3
  import { planToolTelemetry, TELEMETRY_PROPERTY_DESCRIPTION, USER_INTENT_DESCRIPTION, } from "./schema.js";
4
4
  import { isJsonObjectSchema, isRecord } from "./utils.js";
5
5
  import { getClientInfoForSessionId, installClientInfoCapture, } from "./client-info-cache.js";
6
- import { handleRequestCapability, isRequestCapabilityEnabled, isRequestCapabilityExplicit, REQUEST_CAPABILITY_DESCRIPTION, REQUEST_CAPABILITY_INPUT_SCHEMA, REQUEST_CAPABILITY_TOOL_NAME, REQUEST_CAPABILITY_ZOD_SHAPE, } from "./request-capability.js";
6
+ import { handleRequestCapability, isRequestCapabilityEnabled, isRequestCapabilityExplicit, REQUEST_CAPABILITY_ANNOTATIONS, REQUEST_CAPABILITY_DESCRIPTION, REQUEST_CAPABILITY_INPUT_SCHEMA, REQUEST_CAPABILITY_TOOL_NAME, REQUEST_CAPABILITY_ZOD_SHAPE, } from "./request-capability.js";
7
7
  import { createAnalyticsRecorderCore } from "./recorder-core.js";
8
8
  const nudgeTelemetryDescriptions = (schema) => {
9
9
  if (!isJsonObjectSchema(schema))
@@ -103,10 +103,8 @@ export const createAnalyticsRecorder = (config = defaultMcpAnalyticsConfig) => {
103
103
  // positional juggling below keys on what we actually registered, which for
104
104
  // owned/scrub tools is the caller's original (possibly absent) schema.
105
105
  const registeredHasInputSchema = plan.inputSchema !== undefined;
106
- // Same nudge `decorateDefinitions` applies in the registry path — the
107
- // caller-owned McpServer path must also tell agents to pass
108
- // telemetry.user_intent, or sessions arrive with no intent (ARM-24).
109
- // Owned/scrub tools keep their original description untouched.
106
+ // Same description handling as `decorateDefinitions`: no added text, only
107
+ // earlier SDK hint suffixes removed. Owned/scrub tools keep theirs as is.
110
108
  const description = plan.applyDescription(registration.description);
111
109
  server.registerTool(registration.name, {
112
110
  ...(registration.title !== undefined ? { title: registration.title } : {}),
@@ -140,7 +138,7 @@ export const createAnalyticsRecorder = (config = defaultMcpAnalyticsConfig) => {
140
138
  // Reserved only when the caller explicitly opted in. When the tool is on
141
139
  // merely by default, a customer tool of the same name takes precedence:
142
140
  // fall through so this registration overwrites the SDK-owned entry.
143
- throw new Error(`Tool name "${REQUEST_CAPABILITY_TOOL_NAME}" is reserved while armature.requestCapability is enabled.`);
141
+ throw new Error(`Tool name "${REQUEST_CAPABILITY_TOOL_NAME}" is reserved while armature.sendFeedback is enabled.`);
144
142
  }
145
143
  registeredTools.set(registration.name, {
146
144
  registration,
@@ -174,6 +172,7 @@ export const createAnalyticsRecorder = (config = defaultMcpAnalyticsConfig) => {
174
172
  name: REQUEST_CAPABILITY_TOOL_NAME,
175
173
  description: REQUEST_CAPABILITY_DESCRIPTION,
176
174
  inputSchema: REQUEST_CAPABILITY_INPUT_SCHEMA,
175
+ annotations: REQUEST_CAPABILITY_ANNOTATIONS,
177
176
  });
178
177
  continue;
179
178
  }
@@ -203,6 +202,7 @@ export const createAnalyticsRecorder = (config = defaultMcpAnalyticsConfig) => {
203
202
  name: REQUEST_CAPABILITY_TOOL_NAME,
204
203
  description: REQUEST_CAPABILITY_DESCRIPTION,
205
204
  inputSchema: REQUEST_CAPABILITY_ZOD_SHAPE,
205
+ annotations: REQUEST_CAPABILITY_ANNOTATIONS,
206
206
  },
207
207
  handler: handleRequestCapability,
208
208
  telemetryMode: "scrub",
@@ -1,10 +1,19 @@
1
1
  import { z } from "zod";
2
2
  import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
3
  import type { JsonObjectSchema, McpAnalyticsConfig } from "./types.js";
4
- export declare const REQUEST_CAPABILITY_TOOL_NAME = "request_capability";
4
+ export declare const SEND_FEEDBACK_TOOL_NAME = "send_feedback";
5
+ export declare const LEGACY_REQUEST_CAPABILITY_TOOL_NAME = "request_capability";
6
+ export declare const REQUEST_CAPABILITY_TOOL_NAME = "send_feedback";
5
7
  export declare const REQUEST_CAPABILITY_DESCRIPTION = "Records that the user asked for something these tools cannot do, so the developers of this server can add it. It changes no data and contacts no one. Call it whenever you cannot do what the user asked with these tools, including when you send them to an app, a website or a manual step instead. Then answer them as usual.";
6
8
  export declare const REQUEST_CAPABILITY_ARGUMENT_DESCRIPTION = "One English sentence describing the missing capability needed for the user's task. Translate the summary into English even when the user writes in another language. Describe generic actions and roles. Omit names, contacts, IDs, credentials and all tool argument values.";
7
9
  export declare const REQUEST_CAPABILITY_INPUT_SCHEMA: JsonObjectSchema;
10
+ export declare const REQUEST_CAPABILITY_ANNOTATIONS: {
11
+ title: string;
12
+ readOnlyHint: boolean;
13
+ destructiveHint: boolean;
14
+ idempotentHint: boolean;
15
+ openWorldHint: boolean;
16
+ };
8
17
  export declare const REQUEST_CAPABILITY_ZOD_SHAPE: {
9
18
  capability: z.ZodString;
10
19
  };
@@ -1,7 +1,13 @@
1
1
  import { z } from "zod";
2
2
  import { resolveApiKey } from "./emit.js";
3
3
  import { isRecord } from "./utils.js";
4
- export const REQUEST_CAPABILITY_TOOL_NAME = "request_capability";
4
+ // The SDK-owned feedback tool. Named send_feedback, like PostHog's; releases
5
+ // before the connector-directory change named it request_capability, a name
6
+ // ingest and the doctor still recognize. The REQUEST_CAPABILITY_* identifiers
7
+ // keep their names so existing imports compile.
8
+ export const SEND_FEEDBACK_TOOL_NAME = "send_feedback";
9
+ export const LEGACY_REQUEST_CAPABILITY_TOOL_NAME = "request_capability";
10
+ export const REQUEST_CAPABILITY_TOOL_NAME = SEND_FEEDBACK_TOOL_NAME;
5
11
  export const REQUEST_CAPABILITY_DESCRIPTION = "Records that the user asked for something these tools cannot do, so the developers of this server can add it. It changes no data and contacts no one. Call it whenever you cannot do what the user asked with these tools, including when you send them to an app, a website or a manual step instead. Then answer them as usual.";
6
12
  export const REQUEST_CAPABILITY_ARGUMENT_DESCRIPTION = "One English sentence describing the missing capability needed for the user's task. Translate the summary into English even when the user writes in another language. Describe generic actions and roles. Omit names, contacts, IDs, credentials and all tool argument values.";
7
13
  export const REQUEST_CAPABILITY_INPUT_SCHEMA = {
@@ -17,6 +23,17 @@ export const REQUEST_CAPABILITY_INPUT_SCHEMA = {
17
23
  required: ["capability"],
18
24
  additionalProperties: false,
19
25
  };
26
+ // Directories such as ChatGPT's reject tools without explicit readOnlyHint,
27
+ // destructiveHint and openWorldHint. The tool records an analytics event (not
28
+ // read-only), changes no user data and reaches no one outside the server.
29
+ // Matches the hosted Armature MCP (lib/mcp/index.js).
30
+ export const REQUEST_CAPABILITY_ANNOTATIONS = {
31
+ title: "Send feedback",
32
+ readOnlyHint: false,
33
+ destructiveHint: false,
34
+ idempotentHint: false,
35
+ openWorldHint: false,
36
+ };
20
37
  // McpServer.registerTool accepts a Zod raw shape, while custom dispatchers
21
38
  // consume the JSON Schema above from recorder.toolDefinitions().
22
39
  export const REQUEST_CAPABILITY_ZOD_SHAPE = {
@@ -26,16 +43,19 @@ export const REQUEST_CAPABILITY_ZOD_SHAPE = {
26
43
  .max(1000)
27
44
  .describe(REQUEST_CAPABILITY_ARGUMENT_DESCRIPTION),
28
45
  };
29
- export const isRequestCapabilityEnabled = (config) => config.armature?.requestCapability !== false
46
+ // armature.sendFeedback, or the earlier armature.requestCapability; the new
47
+ // key wins when both are set. Undefined means the default.
48
+ const sendFeedbackSetting = (config) => config.armature?.sendFeedback ?? config.armature?.requestCapability;
49
+ // On by default when a delivery path is configured; `sendFeedback: false`
50
+ // disables it. No other tool description mentions it.
51
+ export const isRequestCapabilityEnabled = (config) => sendFeedbackSetting(config) !== false
30
52
  && config.armature?.enabled !== false
31
53
  && (typeof config.armature?.emit === "function" || Boolean(resolveApiKey(config)));
32
- // True only when the caller explicitly opted in (requestCapability: true).
33
- // Injection is governed by isRequestCapabilityEnabled (on unless explicitly
34
- // disabled); the reserved-name and server-shape guards key off this stricter
35
- // check instead, so a server that is only on-by-default skips injection
36
- // quietly on a collision or an incompatible factory result rather than
37
- // throwing and breaking an existing integration on upgrade.
38
- export const isRequestCapabilityExplicit = (config) => config.armature?.requestCapability === true;
54
+ // True only when the caller explicitly opted in. The reserved-name and
55
+ // server-shape guards key off this stricter check, so a server that is on
56
+ // merely by default skips injection quietly on a collision or an
57
+ // incompatible factory result instead of breaking on upgrade.
58
+ export const isRequestCapabilityExplicit = (config) => sendFeedbackSetting(config) === true;
39
59
  export const handleRequestCapability = (args) => {
40
60
  if (!isRecord(args)
41
61
  || typeof args.capability !== "string"
@@ -2,16 +2,24 @@ import { z } from "zod";
2
2
  import * as zv4 from "zod/v4";
3
3
  import type { ExtractedToolArguments, InternalMcpAnalyticsConfig, JsonObjectSchema, TelemetryArgs, TelemetryFieldMap, TelemetryMode, DescriptionLengthLogLevel } from "./types.js";
4
4
  export declare const TELEMETRY_PROPERTY_DESCRIPTION = "Optional task context for usage analytics, based on the visible user request and the action performed by this tool.";
5
+ /**
6
+ * Kept for compatibility: the SDK no longer appends anything to tool
7
+ * descriptions, so no description can grow past this because of us.
8
+ */
5
9
  export declare const MAX_TOOL_DESCRIPTION_LENGTH = 1024;
6
- export declare const appendTelemetryHint: (description: string | undefined, options?: {
10
+ export declare const stripSdkDescriptionHint: (description: string | undefined) => string | undefined;
11
+ /**
12
+ * @deprecated Appends nothing. The SDK no longer adds text to tool
13
+ * descriptions; this only removes SDK hint suffixes from earlier releases.
14
+ * The options are accepted and ignored.
15
+ */
16
+ export declare const appendTelemetryHint: (description: string | undefined, _options?: {
7
17
  requestCapability?: boolean;
8
18
  toolName?: string;
9
19
  logLevel?: DescriptionLengthLogLevel;
10
- }) => string;
11
- export declare const withoutRequestCapabilityHint: (description: string | undefined, toolName?: string, registeredDescription?: string, logLevel?: DescriptionLengthLogLevel) => string;
20
+ }) => string | undefined;
12
21
  export declare const USER_INTENT_DESCRIPTION = "Generalized one-sentence summary of the task stated in the user's latest message. Describe actions and generic roles only. Replace all tool argument values with generic terms, including names, contacts, IDs, credentials, document titles, team names and filters. For example, 'List employees in the selected team.' Include only on the first tool call after each new user message; omit on later calls in the same turn. Use English.";
13
22
  export declare const CALL_PURPOSE_DESCRIPTION = "Short public description of the action this tool performs toward the user's stated goal. Base it only on the visible request, the tool's function and its inputs. Use English. Omit names, contact details, identifiers, credentials and argument values. Generalize document titles, team names and filter values (for example, 'the selected team').";
14
- export declare const USER_FRUSTRATION_DESCRIPTION = "Frustration expressed in the user's latest message: low when none is expressed, medium for explicit dissatisfaction, high for strong or repeated dissatisfaction. Use only the user's words. Include on the first tool call after each new user message; omit on later calls in the same turn.";
15
23
  export declare const isCaptureEnabled: (config?: InternalMcpAnalyticsConfig) => boolean;
16
24
  export declare const schemaDeclaresTelemetry: (inputSchema: unknown) => boolean;
17
25
  export type ToolTelemetryPlan = {
@@ -19,21 +27,18 @@ export type ToolTelemetryPlan = {
19
27
  inputSchema: unknown;
20
28
  applyDescription: (description: string | undefined) => string | undefined;
21
29
  };
22
- export declare const planToolTelemetry: (toolName: string, inputSchema: unknown, config?: InternalMcpAnalyticsConfig, options?: {
30
+ export declare const planToolTelemetry: (toolName: string, inputSchema: unknown, config?: InternalMcpAnalyticsConfig, _options?: {
23
31
  requestCapability?: boolean;
24
32
  }) => ToolTelemetryPlan;
25
33
  export declare const createTelemetryInputSchema: (_config?: InternalMcpAnalyticsConfig) => z.ZodOptional<z.ZodObject<{
26
34
  user_intent: z.ZodOptional<z.ZodString>;
27
35
  call_purpose: z.ZodOptional<z.ZodString>;
28
- user_frustration: z.ZodOptional<z.ZodString>;
29
36
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
30
37
  user_intent: z.ZodOptional<z.ZodString>;
31
38
  call_purpose: z.ZodOptional<z.ZodString>;
32
- user_frustration: z.ZodOptional<z.ZodString>;
33
39
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
34
40
  user_intent: z.ZodOptional<z.ZodString>;
35
41
  call_purpose: z.ZodOptional<z.ZodString>;
36
- user_frustration: z.ZodOptional<z.ZodString>;
37
42
  }, z.ZodTypeAny, "passthrough">>>;
38
43
  export declare const createTelemetryJsonSchema: (_config?: InternalMcpAnalyticsConfig) => JsonObjectSchema;
39
44
  export declare const decorateInputSchemaWithTelemetry: (inputSchema: unknown, config?: InternalMcpAnalyticsConfig) => JsonObjectSchema | zv4.ZodObject<{
@@ -41,7 +46,6 @@ export declare const decorateInputSchemaWithTelemetry: (inputSchema: unknown, co
41
46
  telemetry: zv4.ZodOptional<zv4.ZodObject<{
42
47
  user_intent: zv4.ZodOptional<zv4.ZodString>;
43
48
  call_purpose: zv4.ZodOptional<zv4.ZodString>;
44
- user_frustration: zv4.ZodOptional<zv4.ZodString>;
45
49
  }, zv4.core.$loose>>;
46
50
  }, zv4.core.$strip> | z.ZodObject<{
47
51
  [x: string]: any;
@@ -49,15 +53,12 @@ export declare const decorateInputSchemaWithTelemetry: (inputSchema: unknown, co
49
53
  telemetry: z.ZodOptional<z.ZodObject<{
50
54
  user_intent: z.ZodOptional<z.ZodString>;
51
55
  call_purpose: z.ZodOptional<z.ZodString>;
52
- user_frustration: z.ZodOptional<z.ZodString>;
53
56
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
54
57
  user_intent: z.ZodOptional<z.ZodString>;
55
58
  call_purpose: z.ZodOptional<z.ZodString>;
56
- user_frustration: z.ZodOptional<z.ZodString>;
57
59
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
58
60
  user_intent: z.ZodOptional<z.ZodString>;
59
61
  call_purpose: z.ZodOptional<z.ZodString>;
60
- user_frustration: z.ZodOptional<z.ZodString>;
61
62
  }, z.ZodTypeAny, "passthrough">>>;
62
63
  }, any, any, {
63
64
  [x: string]: any;
@@ -1,16 +1,20 @@
1
1
  import { z } from "zod";
2
2
  import * as zv4 from "zod/v4";
3
- import { isRequestCapabilityEnabled } from "./request-capability.js";
4
3
  import { isJsonObjectSchema, isRawShape, isRecord } from "./utils.js";
5
4
  // Public task context is identical across all four SDKs. Legacy field names
6
5
  // remain accepted on input and in storage, but are never advertised.
7
6
  export const TELEMETRY_PROPERTY_DESCRIPTION = "Optional task context for usage analytics, based on the visible user request and the action performed by this tool.";
8
- const TELEMETRY_DESCRIPTION_HINT = "\n\nInclude telemetry.call_purpose with a short description of this action. Include telemetry.user_intent and telemetry.user_frustration only on the first tool call after each new user message.";
9
- const TELEMETRY_SENTENCE = TELEMETRY_DESCRIPTION_HINT.trimStart();
7
+ // Earlier releases appended these sentences to every tool description. The SDK
8
+ // no longer adds text to a tool description (TELEMETRY-CONTRACT.md, "Tool
9
+ // descriptions"): what the agent is asked for lives in the injected
10
+ // parameters' own descriptions, as in the PostHog and AgentCat SDKs.
11
+ // Anthropic's connector directory review asked for exactly this. Exact SDK
12
+ // suffixes from those releases are still removed, so a description registered
13
+ // through an older wrapper or a cached factory comes out clean.
14
+ const TELEMETRY_SENTENCE = "Include telemetry.call_purpose with a short description of this action. Include telemetry.user_intent and telemetry.user_frustration only on the first tool call after each new user message.";
10
15
  const REQUEST_CAPABILITY_SENTENCE = "Call request_capability before you tell the user something can't be done here or has to be done elsewhere.";
11
- const TELEMETRY_DESCRIPTION_HINT_WITH_REQUEST_CAPABILITY = `${TELEMETRY_DESCRIPTION_HINT} ${REQUEST_CAPABILITY_SENTENCE}`;
12
- const TELEMETRY_SENTENCE_HINT = TELEMETRY_DESCRIPTION_HINT;
13
- // Only exact SDK suffixes are replaced. A mention within customer prose stays.
16
+ // Only exact SDK suffixes are removed. A mention within customer prose stays.
17
+ // Longer markers precede their shorter prefixes.
14
18
  const RECOGNIZED_HINT_MARKERS = [
15
19
  `${TELEMETRY_SENTENCE} ${REQUEST_CAPABILITY_SENTENCE}`,
16
20
  `${TELEMETRY_SENTENCE} If no tool can do what the user asks, call request_capability.`,
@@ -22,158 +26,49 @@ const RECOGNIZED_HINT_MARKERS = [
22
26
  "Pass telemetry.user_intent with a one-line restatement of the user's most recent request.",
23
27
  "Pass telemetry.intent with a one-line user intent for analytics.",
24
28
  ];
25
- // Some providers reject the whole request when any tool description exceeds
26
- // 1024 characters (Azure OpenAI, some OpenAI-compatible gateways), and Claude
27
- // Code cuts descriptions at 2048, which would drop the hint first. Measured in
28
- // UTF-8 bytes, which never undercounts characters and matches the Python, Go,
29
- // and PHP SDKs exactly.
29
+ /**
30
+ * Kept for compatibility: the SDK no longer appends anything to tool
31
+ * descriptions, so no description can grow past this because of us.
32
+ */
30
33
  export const MAX_TOOL_DESCRIPTION_LENGTH = 1024;
31
- const utf8 = new TextEncoder();
32
- const fits = (text) => utf8.encode(text).length <= MAX_TOOL_DESCRIPTION_LENGTH;
33
- const warnedLongDescriptions = new Set();
34
- const warnDescriptionTooLong = (toolName, message, level = "warning") => {
35
- if (level === "none" || warnedLongDescriptions.has(toolName))
36
- return;
37
- warnedLongDescriptions.add(toolName);
38
- const text = `[mcp-analytics] Tool "${toolName}" description is too long ${message}`;
39
- // Node's console.debug and console.info write to stdout, which carries
40
- // JSON-RPC for stdio servers. Where the runtime has a stderr stream, every
41
- // level goes there; elsewhere (Workers, browsers) the console method
42
- // carries the level.
43
- const stderr = typeof process !== "undefined" ? process.stderr : undefined;
44
- // eslint-disable-next-line no-console
45
- if (level === "warning")
46
- console.warn(text);
47
- else if (typeof stderr?.write === "function")
48
- stderr.write(`${text}\n`);
49
- // eslint-disable-next-line no-console
50
- else if (level === "debug")
51
- console.debug(text);
52
- // eslint-disable-next-line no-console
53
- else
54
- console.info(text);
55
- };
56
- // Appends the current telemetry hint and upgrades exact SDK hint suffixes.
57
- // Every integration shape must run tool descriptions through this
58
- // so calling agents know to pass telemetry (ARM-24). With `requestCapability`,
59
- // the hint also points agents to request_capability.
60
- //
61
- // The result never exceeds MAX_TOOL_DESCRIPTION_LENGTH because of us: when the
62
- // full hint does not fit, only the telemetry sentence is appended (it matters
63
- // per tool; request_capability is a list-wide instruction other tools carry);
64
- // when that does not fit either, the description is left unchanged. Sentences
65
- // are never cut, and the telemetry field is still advertised either way.
66
- export const appendTelemetryHint = (description, options = {}) => {
67
- const requestCapability = options.requestCapability === true;
68
- if (description === undefined) {
69
- return (requestCapability
70
- ? TELEMETRY_DESCRIPTION_HINT_WITH_REQUEST_CAPABILITY
71
- : TELEMETRY_DESCRIPTION_HINT).trimStart();
72
- }
73
- // Upgrade cached SDK suffixes before checking the size budget. Remove a
74
- // full hint before its shorter forms, including stacked older wrappers.
34
+ // Removes the SDK's own trailing hint paragraph(s), stacked older wrappers
35
+ // included. A description that was only an SDK hint becomes empty; a tool with
36
+ // no description keeps none.
37
+ export const stripSdkDescriptionHint = (description) => {
38
+ if (description === undefined)
39
+ return undefined;
75
40
  let base = description;
76
41
  for (;;) {
77
42
  const trimmed = base.trimEnd();
78
43
  const marker = RECOGNIZED_HINT_MARKERS.find((candidate) => trimmed === candidate || trimmed.endsWith(`\n\n${candidate}`));
79
44
  if (marker === undefined)
80
- break;
45
+ return base;
81
46
  base = trimmed === marker ? "" : trimmed.slice(0, -marker.length - 2);
82
47
  }
83
- description = base;
84
- if (description.length === 0) {
85
- return (requestCapability
86
- ? TELEMETRY_DESCRIPTION_HINT_WITH_REQUEST_CAPABILITY
87
- : TELEMETRY_DESCRIPTION_HINT).trimStart();
88
- }
89
- // A customer who already wrote the request_capability sentence gets only the
90
- // telemetry one, so the instruction is not repeated.
91
- const hint = !requestCapability
92
- ? TELEMETRY_DESCRIPTION_HINT
93
- : description.includes(REQUEST_CAPABILITY_SENTENCE)
94
- ? TELEMETRY_SENTENCE_HINT
95
- : TELEMETRY_DESCRIPTION_HINT_WITH_REQUEST_CAPABILITY;
96
- if (fits(`${description}${hint}`)) {
97
- return `${description}${hint}`;
98
- }
99
- if (fits(`${description}${TELEMETRY_SENTENCE_HINT}`)) {
100
- if (options.toolName !== undefined) {
101
- warnDescriptionTooLong(options.toolName, `for the full Armature telemetry hint within ${MAX_TOOL_DESCRIPTION_LENGTH} characters; appended only the telemetry sentence.`, options.logLevel);
102
- }
103
- return `${description}${TELEMETRY_SENTENCE_HINT}`;
104
- }
105
- if (options.toolName !== undefined) {
106
- warnDescriptionTooLong(options.toolName, `to append the Armature telemetry hint without exceeding ${MAX_TOOL_DESCRIPTION_LENGTH} characters; leaving it unchanged. Telemetry is still collected.`, options.logLevel);
107
- }
108
- return description;
109
- };
110
- // The factory can append customer text after the SDK's registered hint. Update
111
- // that exact block in place when its server does not expose request_capability.
112
- export const withoutRequestCapabilityHint = (description, toolName, registeredDescription, logLevel) => {
113
- if (description !== undefined) {
114
- // The last paragraph is the SDK suffix, even when an earlier customer
115
- // paragraph quotes the same instruction. If the factory kept the registered
116
- // description, anchor to its suffix so later customer quotes also survive.
117
- const registeredIndex = registeredDescription === undefined
118
- ? -1
119
- : description.indexOf(registeredDescription);
120
- const registeredMarker = registeredDescription === undefined
121
- ? undefined
122
- : RECOGNIZED_HINT_MARKERS.find((marker) => registeredDescription === marker || registeredDescription.endsWith(`\n\n${marker}`));
123
- let match;
124
- if (registeredIndex >= 0 && registeredDescription !== undefined) {
125
- if (registeredMarker !== undefined) {
126
- match = {
127
- marker: registeredMarker,
128
- index: registeredIndex + registeredDescription.length - registeredMarker.length,
129
- };
130
- }
131
- }
132
- else {
133
- for (const marker of RECOGNIZED_HINT_MARKERS) {
134
- const paragraph = description.lastIndexOf(`\n\n${marker}`);
135
- const index = paragraph >= 0 ? paragraph + 2 : description.startsWith(marker) ? 0 : -1;
136
- // Longer markers precede their shorter prefixes in the list.
137
- if (index >= 0 && (match === undefined || index > match.index))
138
- match = { marker, index };
139
- }
140
- }
141
- if (match !== undefined) {
142
- const { marker, index } = match;
143
- const updated = description.slice(0, index) + TELEMETRY_SENTENCE + description.slice(index + marker.length);
144
- if (fits(updated))
145
- return updated;
146
- if (toolName !== undefined) {
147
- warnDescriptionTooLong(toolName, `to keep the Armature telemetry hint within ${MAX_TOOL_DESCRIPTION_LENGTH} characters; removed it. Telemetry is still collected.`, logLevel);
148
- }
149
- return index === 0
150
- ? description.slice(marker.length).trimStart()
151
- : description.slice(0, index - 2) + description.slice(index + marker.length);
152
- }
153
- }
154
- return appendTelemetryHint(description, toolName === undefined ? { logLevel } : { toolName, logLevel });
155
48
  };
49
+ /**
50
+ * @deprecated Appends nothing. The SDK no longer adds text to tool
51
+ * descriptions; this only removes SDK hint suffixes from earlier releases.
52
+ * The options are accepted and ignored.
53
+ */
54
+ export const appendTelemetryHint = (description, _options = {}) => stripSdkDescriptionHint(description);
156
55
  export const USER_INTENT_DESCRIPTION = "Generalized one-sentence summary of the task stated in the user's latest message. Describe actions and generic roles only. Replace all tool argument values with generic terms, including names, contacts, IDs, credentials, document titles, team names and filters. For example, 'List employees in the selected team.' Include only on the first tool call after each new user message; omit on later calls in the same turn. Use English.";
157
56
  export const CALL_PURPOSE_DESCRIPTION = "Short public description of the action this tool performs toward the user's stated goal. Base it only on the visible request, the tool's function and its inputs. Use English. Omit names, contact details, identifiers, credentials and argument values. Generalize document titles, team names and filter values (for example, 'the selected team').";
158
- export const USER_FRUSTRATION_DESCRIPTION = "Frustration expressed in the user's latest message: low when none is expressed, medium for explicit dissatisfaction, high for strong or repeated dissatisfaction. Use only the user's words. Include on the first tool call after each new user message; omit on later calls in the same turn.";
159
57
  // Each telemetry object schema carries the object-level description via
160
58
  // `.describe(...)` so it survives zod→JSON-schema conversion in every
161
59
  // integration shape — including caller-owned McpServer registration, where no
162
60
  // post-hoc JSON-schema nudge runs (ARM-24).
163
61
  //
164
- // `.passthrough()` keeps unknown keys: a client that cached the pre-V1 tool
165
- // schema may still send `intent`/`context`/`frustration_level`, and stripping
166
- // them here would silently drop its telemetry before normalizeTelemetryArgs
167
- // can translate the legacy spelling.
62
+ // `.passthrough()` keeps unknown keys: a client that cached an older tool
63
+ // schema may still send `intent`/`context`, and stripping them here would
64
+ // silently drop its telemetry before normalizeTelemetryArgs can translate the
65
+ // legacy spelling. A cached `user_frustration`/`frustration_level` passes
66
+ // validation too and is then dropped.
168
67
  //
169
68
  const looseTelemetryInputSchema = z
170
69
  .object({
171
70
  user_intent: z.string().describe(USER_INTENT_DESCRIPTION).optional(),
172
71
  call_purpose: z.string().describe(CALL_PURPOSE_DESCRIPTION).optional(),
173
- user_frustration: z
174
- .string()
175
- .describe(USER_FRUSTRATION_DESCRIPTION)
176
- .optional(),
177
72
  })
178
73
  .passthrough()
179
74
  .describe(TELEMETRY_PROPERTY_DESCRIPTION);
@@ -184,10 +79,6 @@ const looseTelemetryInputSchemaV4 = zv4
184
79
  .string()
185
80
  .describe(CALL_PURPOSE_DESCRIPTION)
186
81
  .optional(),
187
- user_frustration: zv4
188
- .string()
189
- .describe(USER_FRUSTRATION_DESCRIPTION)
190
- .optional(),
191
82
  })
192
83
  .describe(TELEMETRY_PROPERTY_DESCRIPTION);
193
84
  // v4 Zod schemas carry a `_zod` brand on every type; v3 only has `_def`.
@@ -254,10 +145,9 @@ const warnTelemetryCollision = (toolName) => {
254
145
  // prototype patch, Mastra adapter, custom dispatchers) must register and
255
146
  // extract with the same plan, so the advertised schema always matches runtime
256
147
  // behavior.
257
- // `requestCapability` overrides the config-derived answer to "does this
258
- // server list request_capability?" for adapters whose recorder, not the
259
- // wrap-time config, is the source of truth (Mastra).
260
- export const planToolTelemetry = (toolName, inputSchema, config = {}, options = {}) => {
148
+ // `_options` is accepted for adapters built against earlier releases; no
149
+ // description mentions request_capability any more.
150
+ export const planToolTelemetry = (toolName, inputSchema, config = {}, _options = {}) => {
261
151
  if (schemaDeclaresTelemetry(inputSchema)) {
262
152
  warnTelemetryCollision(toolName);
263
153
  return {
@@ -276,11 +166,7 @@ export const planToolTelemetry = (toolName, inputSchema, config = {}, options =
276
166
  return {
277
167
  mode: "injected",
278
168
  inputSchema: decorateInputSchemaWithTelemetry(inputSchema, config),
279
- applyDescription: (description) => appendTelemetryHint(description, {
280
- requestCapability: options.requestCapability ?? isRequestCapabilityEnabled(config),
281
- toolName,
282
- logLevel: config.armature?.descriptionLengthLogLevel,
283
- }),
169
+ applyDescription: stripSdkDescriptionHint,
284
170
  };
285
171
  };
286
172
  // The telemetry object and every field stay optional. In particular,
@@ -304,10 +190,6 @@ export const createTelemetryJsonSchema = (_config = {}) => {
304
190
  type: "string",
305
191
  description: CALL_PURPOSE_DESCRIPTION,
306
192
  },
307
- user_frustration: {
308
- type: "string",
309
- description: USER_FRUSTRATION_DESCRIPTION,
310
- },
311
193
  },
312
194
  };
313
195
  };
@@ -349,11 +231,6 @@ export const decorateInputSchemaWithTelemetry = (inputSchema, config = {}) => {
349
231
  }
350
232
  throw new Error("MCP analytics can only decorate undefined, Zod object, JSON object, or raw-shape input schemas.");
351
233
  };
352
- const asFrustration = (value) => {
353
- return value === "low" || value === "medium" || value === "high"
354
- ? value
355
- : undefined;
356
- };
357
234
  // First value that is actually a string — mirrors Python's _first_str so both
358
235
  // SDKs resolve mixed V1/legacy inputs identically (a non-string V1 value never
359
236
  // shadows a usable legacy string).
@@ -382,10 +259,8 @@ export const normalizeTelemetryArgs = (telemetry) => {
382
259
  const agentThinking = firstString(telemetry.call_purpose, telemetry.agent_thinking, telemetry.context);
383
260
  if (agentThinking !== undefined)
384
261
  normalized.agent_thinking = agentThinking;
385
- const userFrustration = asFrustration(telemetry.user_frustration)
386
- ?? asFrustration(telemetry.frustration_level);
387
- if (userFrustration !== undefined)
388
- normalized.user_frustration = userFrustration;
262
+ // `user_frustration`/`frustration_level` from cached schemas are dropped:
263
+ // the SDK no longer asks agents to rate the user.
389
264
  return normalized;
390
265
  };
391
266
  // Opt-in export of customer-owned argument fields (gap #11): reads — never
@@ -413,13 +288,7 @@ export const applyTelemetryFieldMap = (telemetry, args, fieldMap) => {
413
288
  if (value !== undefined)
414
289
  merged.call_purpose = value;
415
290
  }
416
- if (merged.user_frustration === undefined
417
- && merged.frustration_level === undefined
418
- && fieldMap.user_frustration !== undefined) {
419
- const value = asFrustration(args[fieldMap.user_frustration]);
420
- if (value !== undefined)
421
- merged.user_frustration = value;
422
- }
291
+ // A `user_frustration` mapping is accepted and ignored.
423
292
  return Object.keys(merged).length > 0 ? merged : telemetry;
424
293
  };
425
294
  // Mode semantics (TELEMETRY-CONTRACT.md): "injected" strips and exports;
@@ -2,26 +2,12 @@ import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
4
  import { createAnalyticsRecorder } from "./recorder.js";
5
- import { appendTelemetryHint, planToolTelemetry, withoutRequestCapabilityHint, } from "./schema.js";
5
+ import { planToolTelemetry } from "./schema.js";
6
6
  import { defaultMcpAnalyticsConfig } from "./emit.js";
7
7
  import { deriveToolResultError, isRecord } from "./utils.js";
8
8
  import { isRequestCapabilityEnabled, isRequestCapabilityExplicit, REQUEST_CAPABILITY_TOOL_NAME, } from "./request-capability.js";
9
9
  const withAnalyticsStorage = new AsyncLocalStorage();
10
10
  let prototypePatchInstalled = false;
11
- // Servers a tool named request_capability was registered on: the SDK-owned
12
- // one the recorder attaches, or a customer's own. Only the fallback for an
13
- // SDK build without the tool registry below.
14
- const serversListingRequestCapability = new WeakSet();
15
- // Whether tools/list on `server` currently carries request_capability. Reads
16
- // the SDK's registry (the same map and `enabled` filter tools/list uses), so
17
- // a tool removed or disabled after registration no longer counts.
18
- const listsRequestCapability = (server) => {
19
- const registry = server._registeredTools;
20
- if (registry !== null && typeof registry === "object") {
21
- return registry[REQUEST_CAPABILITY_TOOL_NAME]?.enabled === true;
22
- }
23
- return serversListingRequestCapability.has(server);
24
- };
25
11
  // Mirrors the SDK's `isZodTypeLike`/`isZodRawShapeCompat` checks closely enough
26
12
  // to disambiguate the overloads of `server.tool(...)`: a raw shape is a plain
27
13
  // object whose values include at least one Zod schema, while a Zod schema
@@ -128,16 +114,11 @@ const installPrototypePatchOnce = () => {
128
114
  prototype.registerTool = function patchedRegisterTool(name, toolConfig, cb) {
129
115
  const ctx = withAnalyticsStorage.getStore();
130
116
  if (!ctx) {
131
- const registered = originalRegisterTool.call(this, name, toolConfig, cb);
132
- if (name === REQUEST_CAPABILITY_TOOL_NAME)
133
- serversListingRequestCapability.add(this);
134
- return registered;
117
+ return originalRegisterTool.call(this, name, toolConfig, cb);
135
118
  }
136
119
  const { config } = ctx;
137
120
  const originalHasInputSchema = toolConfig.inputSchema !== undefined;
138
- const plan = planToolTelemetry(name, toolConfig.inputSchema, config, ctx.resolved
139
- ? { requestCapability: listsRequestCapability(this) }
140
- : {});
121
+ const plan = planToolTelemetry(name, toolConfig.inputSchema, config);
141
122
  const registeredHasInputSchema = plan.inputSchema !== undefined;
142
123
  const description = plan.applyDescription(toolConfig.description);
143
124
  const instrumentedConfig = {
@@ -146,23 +127,7 @@ const installPrototypePatchOnce = () => {
146
127
  ...(registeredHasInputSchema ? { inputSchema: plan.inputSchema } : {}),
147
128
  };
148
129
  const wrappedCallback = wrapCallbackWithAnalytics(name, cb, originalHasInputSchema, registeredHasInputSchema, plan.mode, ctx);
149
- const registered = originalRegisterTool.call(this, name, instrumentedConfig, wrappedCallback);
150
- if (name === REQUEST_CAPABILITY_TOOL_NAME)
151
- serversListingRequestCapability.add(this);
152
- if (!ctx.resolved && plan.mode === "injected" && isRequestCapabilityEnabled(config)) {
153
- ctx.requestCapabilityHints.push({
154
- server: this,
155
- tool: registered,
156
- toolName: name,
157
- hintedDescription: description,
158
- fallbackDescription: appendTelemetryHint(toolConfig.description, {
159
- toolName: name,
160
- logLevel: config.armature?.descriptionLengthLogLevel,
161
- }),
162
- logLevel: config.armature?.descriptionLengthLogLevel,
163
- });
164
- }
165
- return registered;
130
+ return originalRegisterTool.call(this, name, instrumentedConfig, wrappedCallback);
166
131
  };
167
132
  // PRIA and other older codebases still use the deprecated `server.tool(...)`
168
133
  // overloads. Patch them too — we normalise into our patched `registerTool`
@@ -189,8 +154,6 @@ export const withMcpAnalytics = (config, createServer) => {
189
154
  const ctx = {
190
155
  config,
191
156
  recorder,
192
- resolved: false,
193
- requestCapabilityHints: [],
194
157
  };
195
158
  const result = withAnalyticsStorage.run(ctx, createServer);
196
159
  // Customer tools registered inside the factory are handled by the
@@ -200,10 +163,10 @@ export const withMcpAnalytics = (config, createServer) => {
200
163
  // description.
201
164
  if (isRequestCapabilityEnabled(config) && !(result instanceof McpServer)) {
202
165
  // Only a hard error when the caller explicitly opted in. A server that is
203
- // request_capability-on merely by default and doesn't return an McpServer
204
- // silently skips injection instead of breaking on upgrade.
166
+ // on merely by default and doesn't return an McpServer silently skips
167
+ // injection instead of breaking on upgrade.
205
168
  if (isRequestCapabilityExplicit(config)) {
206
- throw new Error("armature.requestCapability requires the server factory to return an McpServer instance.");
169
+ throw new Error("armature.sendFeedback requires the server factory to return an McpServer instance.");
207
170
  }
208
171
  }
209
172
  if (isRequestCapabilityEnabled(config) && result instanceof McpServer) {
@@ -213,31 +176,14 @@ export const withMcpAnalytics = (config, createServer) => {
213
176
  catch (error) {
214
177
  const collision = error instanceof Error && /already registered/i.test(error.message);
215
178
  // A pre-existing tool of the same name is reserved only when the caller
216
- // explicitly opted in; on-by-default yields to the customer's tool.
179
+ // explicitly opted in; on by default yields to the customer's tool.
217
180
  if (collision && isRequestCapabilityExplicit(config)) {
218
- throw new Error('Tool name "request_capability" is reserved while armature.requestCapability is enabled.', { cause: error });
181
+ throw new Error(`Tool name "${REQUEST_CAPABILITY_TOOL_NAME}" is reserved while armature.sendFeedback is enabled.`, { cause: error });
219
182
  }
220
183
  if (!collision)
221
184
  throw error;
222
185
  }
223
186
  }
224
- // Tools registered on a server that does not list request_capability (the
225
- // factory returned something else, or registered on another server) must
226
- // not point agents at it.
227
- ctx.resolved = true;
228
- for (const hint of ctx.requestCapabilityHints) {
229
- if (!listsRequestCapability(hint.server)
230
- && hint.tool !== null
231
- && typeof hint.tool === "object") {
232
- const tool = hint.tool;
233
- // Keep a description the factory updated after registration; only its
234
- // hint changes.
235
- tool.description = tool.description === hint.hintedDescription
236
- ? hint.fallbackDescription
237
- : withoutRequestCapabilityHint(tool.description, hint.toolName, hint.hintedDescription, hint.logLevel);
238
- }
239
- }
240
- ctx.requestCapabilityHints.length = 0;
241
187
  return { result, recorder };
242
188
  };
243
189
  export const createMcpAnalyticsServer = (createServer, config = defaultMcpAnalyticsConfig) => {