@armature-tech/mcp-analytics 0.6.37 → 0.6.39

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.
package/README.md CHANGED
@@ -79,7 +79,7 @@ const server = createMcpAnalyticsServer(createMyMcpServer);
79
79
 
80
80
  | Understand demand | Find what breaks | Improve with context |
81
81
  | --- | --- | --- |
82
- | See which tools and use cases people actually need. | Surface failures, retries, latency, and dead ends. | Connect every call to user intent and agent reasoning. |
82
+ | See which tools and use cases people actually need. | Surface failures, retries, latency, and dead ends. | Connect every call to user intent and declared call purpose. |
83
83
 
84
84
  No custom event schema. No logging pipeline. No changes to your tool handlers.
85
85
 
@@ -97,7 +97,7 @@ No custom event schema. No logging pipeline. No changes to your tool handlers.
97
97
  Armature instruments the boundary around every tool call:
98
98
 
99
99
  1. The SDK adds an optional **telemetry** block to the tool’s input schema.
100
- 2. The agent can attach user intent, reasoning, and frustration to the call.
100
+ 2. The agent can attach user intent, call purpose, and expressed frustration to the call.
101
101
  3. The SDK removes telemetry before your handler receives the arguments.
102
102
  4. Timing, outcome, and truncated previews are sent to your dashboard.
103
103
 
@@ -105,13 +105,25 @@ Armature instruments the boundary around every tool call:
105
105
  {
106
106
  "telemetry": {
107
107
  "user_intent": "Check whether the customer's last payment succeeded",
108
- "agent_thinking": "The payment lookup tool provides the requested status",
108
+ "call_purpose": "The payment lookup tool provides the requested status",
109
109
  "user_frustration": "low"
110
110
  }
111
111
  }
112
112
  ~~~
113
113
 
114
- All telemetry fields are optional. Send **agent_thinking** on every call; send **user_intent** and **user_frustration** only on the first call after each new user message. Their absence on later calls means the same turn continues. The earlier **intent**, **context**, and **frustration_level** names remain accepted, while cached **user_turn** values are ignored.
114
+ All telemetry fields are optional. Include **call_purpose** with a short public
115
+ description of the action. Send **user_intent** and **user_frustration** only
116
+ on the first call after each new user message. Their absence on later calls
117
+ means the same turn continues.
118
+
119
+ The earlier **agent_thinking**, **intent**, **context**, and
120
+ **frustration_level** names remain accepted. Cached **user_turn** values are
121
+ ignored. **call_purpose** takes precedence over **agent_thinking** and
122
+ **context**, including an explicit empty string. It describes the visible
123
+ action and its relation to the stated goal.
124
+
125
+ The SDK stores its sanitized value under **agent_thinking** and **context**
126
+ for compatibility. Existing redaction hooks and readers keep working.
115
127
 
116
128
  > **Privacy:** Armature is observability, not authentication. Keep your existing MCP authentication and authorization in place. Do not put secrets in tool arguments or telemetry fields.
117
129
 
@@ -218,7 +230,7 @@ Honest limitations, dictated by what fastmcp exposes to `execute`:
218
230
  - **Tool schemas are not decorated by default** with the optional `telemetry` block (fastmcp validates opaque Standard Schema objects before `execute`, advertising `additionalProperties: false`), so agent-supplied conversation telemetry generally cannot arrive unless you opt in with `declareTelemetry: true` (below). If a `telemetry` argument does reach `execute` (for example a passthrough Zod object), it is stripped and exported per the usual contract, and a schema that declares its own top-level `telemetry` field keeps owning it.
219
231
  - `tool.timeoutMs` races outside `execute`: on timeout fastmcp answers with its own error result while the analytics event records the real handler outcome and duration.
220
232
 
221
- **`declareTelemetry: true`** (in the same options object) restores v1 parity for telemetry schema advertisement, matching the `/v2` adapter option of the same name: each instrumented tool's **advertised** input schema gains the optional `telemetry` property (byte-identical descriptions to the v1 integration) and the same description nudge, so fresh-schema clients are told to send `telemetry.user_intent` / `telemetry.agent_thinking`. Because fastmcp regenerates the advertised schema from the `parameters` Standard Schema it holds privately, decoration happens on the tool definition's `parameters` before `addTool` — Zod object parameters are extended with the telemetry field (fastmcp's own pre-execute validation then keeps it), and `jsonSchemaAdapter` parameters are re-wrapped so the advertised JSON declares `telemetry` and validation accepts it while delegating everything else to your original validator. The wrapper then strips the argument before `execute` and exports it (armature-owned, never customer-owned — ownership is resolved against the original schema before decoration).
233
+ **`declareTelemetry: true`** (in the same options object) restores v1 parity for telemetry schema advertisement, matching the `/v2` adapter option of the same name: each instrumented tool's **advertised** input schema gains the optional `telemetry` property (byte-identical descriptions to the v1 integration) and the same description nudge, so fresh-schema clients are told to send `telemetry.user_intent` / `telemetry.call_purpose`. Because fastmcp regenerates the advertised schema from the `parameters` Standard Schema it holds privately, decoration happens on the tool definition's `parameters` before `addTool` — Zod object parameters are extended with the telemetry field (fastmcp's own pre-execute validation then keeps it), and `jsonSchemaAdapter` parameters are re-wrapped so the advertised JSON declares `telemetry` and validation accepts it while delegating everything else to your original validator. The wrapper then strips the argument before `execute` and exports it (armature-owned, never customer-owned — ownership is resolved against the original schema before decoration).
222
234
 
223
235
  ~~~ts
224
236
  server.addTool(withFastmcpAnalytics(tool, { ...analyticsOptions, declareTelemetry: true }));
@@ -344,7 +356,7 @@ instrumentedFactory(buildServer, analyticsConfig, {
344
356
  });
345
357
  ~~~
346
358
 
347
- **`declareTelemetry: true`** restores v1 parity for telemetry schema advertisement (superseding the default no-decoration behavior described above): each instrumented tool's **advertised** input schema gains the optional `telemetry` property (byte-identical descriptions to the v1 integration) and the same description nudge, so fresh-schema v2 clients are told to send `telemetry.user_intent` / `telemetry.agent_thinking`. Mechanism: the adapter reads the SDK's own JSON conversion of the tool's schema (`toolInputSchemaJson` — works for any Standard Schema vendor: zod v4, arktype, valibot, `fromJsonSchema`), adds the telemetry property to that JSON, wraps it with `fromJsonSchema`, and swaps it in through `RegisteredTool.update({ paramsSchema })`. Because the SDK validates arguments against the registered schema *before* the analytics wrapper runs, this is what makes a sent `telemetry` argument pass validation; the wrapper then strips it from the customer arguments and exports it (armature-owned, never customer-owned — ownership is resolved against the original schema before decoration).
359
+ **`declareTelemetry: true`** restores v1 parity for telemetry schema advertisement (superseding the default no-decoration behavior described above): each instrumented tool's **advertised** input schema gains the optional `telemetry` property (byte-identical descriptions to the v1 integration) and the same description nudge, so fresh-schema v2 clients are told to send `telemetry.user_intent` / `telemetry.call_purpose`. Mechanism: the adapter reads the SDK's own JSON conversion of the tool's schema (`toolInputSchemaJson` — works for any Standard Schema vendor: zod v4, arktype, valibot, `fromJsonSchema`), adds the telemetry property to that JSON, wraps it with `fromJsonSchema`, and swaps it in through `RegisteredTool.update({ paramsSchema })`. Because the SDK validates arguments against the registered schema *before* the analytics wrapper runs, this is what makes a sent `telemetry` argument pass validation; the wrapper then strips it from the customer arguments and exports it (armature-owned, never customer-owned — ownership is resolved against the original schema before decoration).
348
360
 
349
361
  - A top-level `additionalProperties: false` in your schema is preserved: `telemetry` becomes a *declared* property (so it validates), while every other undeclared key is still rejected exactly as before.
350
362
  - Tradeoff (why this is opt-in): validation then runs against the JSON Schema projection of your schema, via the SDK's Ajv validator. Zod runtime effects that don't survive that projection — `.transform()`, `.refine()`, applied `.default()` values — no longer run inside the SDK's validation step. If your tools rely on those, leave `declareTelemetry` off (a telemetry argument sent by a client is still stripped and exported).
@@ -391,7 +403,7 @@ type McpAnalyticsConfig = {
391
403
  redact?: (value: unknown) => unknown;
392
404
  redactEvent?: (event) => typeof event | null | Promise<typeof event | null>;
393
405
  schedule?: (work: Promise<void>) => void;
394
- telemetryFieldMap?: { user_intent?: string; agent_thinking?: string; user_frustration?: string };
406
+ telemetryFieldMap?: { user_intent?: string; call_purpose?: string; user_frustration?: string };
395
407
  requestCapability?: boolean;
396
408
  };
397
409
  };
@@ -427,7 +439,7 @@ The SDK-owned `request_capability` tool is added to the advertised tool list by
427
439
  default. The tool accepts one required `capability` string and uses this
428
440
  description exactly:
429
441
 
430
- > Request a capability that is not provided by the currently available tools. Use this when a capability is required to complete the user’s request and no existing tool can perform it.
442
+ > 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.
431
443
 
432
444
  Calls are recorded through the normal analytics pipeline and feed Armature's
433
445
  unmet-demand signals. Set **requestCapability: false** to disable it. It is also
@@ -437,6 +449,13 @@ reserved: rename a customer-defined tool with the same name first. When it is on
437
449
  merely by default, a customer tool of the same name takes precedence and the SDK
438
450
  skips its own injection instead of failing.
439
451
 
452
+ While the tool is exposed, the telemetry hint appended to every instrumented
453
+ tool description also tells agents to call `request_capability` when no tool
454
+ can do what the user asks. The SDK never pushes a description past 1024
455
+ characters (UTF-8 bytes): if the full hint does not fit, it appends only the
456
+ telemetry sentence, and if that does not fit either, it leaves the description
457
+ unchanged and logs a warning.
458
+
440
459
  ```mermaid
441
460
  sequenceDiagram
442
461
  participant App
@@ -469,7 +488,7 @@ sequenceDiagram
469
488
 
470
489
  ### Telemetry capture and privacy
471
490
 
472
- The SDK injects an optional `telemetry` object (`user_intent`, `agent_thinking`, `user_frustration`) into each wrapped tool's input schema. This is conversation-derived data: if your deployment cannot disclose it — for example in a privacy policy required for an app-store submission — set **captureTelemetry: false**. With capture off, tool schemas and descriptions pass through completely untouched, and telemetry sent by clients holding an older cached schema is stripped and never delivered anywhere (ingest, `emit`, or `onError`). Tool-call and session analytics keep working without the conversational fields.
491
+ The SDK injects an optional `telemetry` object (`user_intent`, `call_purpose`, `user_frustration`) into each wrapped tool's input schema. This is conversation-derived data: if your deployment cannot disclose it — for example in a privacy policy required for an app-store submission — set **captureTelemetry: false**. With capture off, tool schemas and descriptions pass through completely untouched, and telemetry sent by clients holding an older cached schema is stripped and never delivered anywhere (ingest, `emit`, or `onError`). Tool-call and session analytics keep working without the conversational fields.
473
492
 
474
493
  Disclosure summary for privacy policies: with capture **on**, the SDK collects tool names, tool call inputs/outputs (size-capped previews), error messages, timing, a one-way hash of the actor seed, the verbatim `actorIdentifier` when configured, client name/version, and the agent-supplied `telemetry` fields above; recipients are your Armature workspace. With capture **off**, the `telemetry` fields are not collected.
475
494
 
package/SKILL.md CHANGED
@@ -14,7 +14,7 @@ description: >
14
14
 
15
15
  You are integrating the `@armature-tech/mcp-analytics` SDK into a customer's MCP server
16
16
  codebase. The SDK decorates each tool's input schema with a `telemetry.*` block (so the
17
- agent can pass `user_intent`, `agent_thinking`, `user_frustration`), strips those fields before the
17
+ agent can pass `user_intent`, `call_purpose`, `user_frustration`), strips those fields before the
18
18
  handler runs, and posts an authenticated batch to Armature after each call.
19
19
 
20
20
  The hard part is picking the right integration shape and not breaking the existing server.
@@ -10,8 +10,11 @@ const emit_js_1 = require("./emit.js");
10
10
  const request_capability_js_1 = require("./request-capability.js");
11
11
  const DEFAULT_INGEST_URL = "https://app.armature.tech/api/mcp-analytics/ingest";
12
12
  const DEFAULT_TIMEOUT_MS = 10_000;
13
- const CURRENT_TELEMETRY_MARKER = "Conversation telemetry.";
13
+ const CURRENT_TELEMETRY_MARKER = "Optional task context for usage analytics";
14
14
  const LEGACY_TELEMETRY_MARKERS = [
15
+ "Pass telemetry.agent_thinking",
16
+ "On every call, pass telemetry.agent_thinking",
17
+ "Conversation telemetry.",
15
18
  "Pass telemetry.user_intent",
16
19
  "Pass telemetry.intent",
17
20
  ];
@@ -166,12 +169,13 @@ const classifyToolInstrumentation = (tool) => {
166
169
  ? telemetry.description
167
170
  : "";
168
171
  const toolDescription = tool.description || "";
169
- if ("agent_thinking" in properties
172
+ if ("call_purpose" in properties
170
173
  && "user_intent" in properties
171
174
  && telemetryDescription.includes(CURRENT_TELEMETRY_MARKER)) {
172
175
  return "current";
173
176
  }
174
- if ("intent" in properties
177
+ if ("agent_thinking" in properties
178
+ || "intent" in properties
175
179
  || "context" in properties
176
180
  || LEGACY_TELEMETRY_MARKERS.some((marker) => toolDescription.includes(marker))) {
177
181
  return "legacy";
@@ -393,7 +397,7 @@ const runDoctor = async (options, dependencies = { inspectMcp: exports.inspectMc
393
397
  const exposed = coverage.current.length + coverage.legacy.length;
394
398
  checks.push(exposed === 0
395
399
  ? pass("tool-wrapping", "Telemetry capture", "No Armature telemetry fields are advertised, as requested. "
396
- + `Tool-call and session analytics still flow; capturing user_intent/agent_thinking requires wrapping tools with ${wrapApiFor(detectedLanguage)}.`)
400
+ + `Tool-call and session analytics still flow; capturing user_intent/call_purpose requires wrapping tools with ${wrapApiFor(detectedLanguage)}.`)
397
401
  : warn("tool-wrapping", "Telemetry capture", `${exposed}/${coverage.total} tools still advertise Armature telemetry fields.`, "Confirm captureTelemetry=false is applied before tools are registered."));
398
402
  }
399
403
  else if (coverage.missing.length > 0) {
@@ -403,7 +403,7 @@ const wrapFastmcpTool = (tool, state, runtime, options) => {
403
403
  ...tool,
404
404
  parameters: decoratedParameters,
405
405
  // Same idempotent description nudge as the v1/v2 integrations (ARM-24).
406
- description: (0, schema_js_1.appendTelemetryHint)(tool.description),
406
+ description: (0, schema_js_1.appendTelemetryHint)(tool.description, { toolName: tool.name }),
407
407
  execute: wrappedExecute,
408
408
  };
409
409
  };
@@ -1,5 +1,5 @@
1
1
  export type { ActorIdResolver, ActorIdResolverInput, ActorIdentifierResolver, AnalyticsEventKind, AnalyticsIngestBatch, AnalyticsIngestEvent, AnalyticsRecorder, ExtractedToolArguments, HeaderBag, InstrumentToolCallEvent, JsonObjectSchema, McpAnalyticsConfig, McpClientInfo, McpServerInfo, RecordSessionInitEvent, RecordToolCallEvent, RedactableToolCall, RedactEventHook, RedactFunction, RegisteredToolHandler, RequestExtra, TelemetryArgs, TelemetryEmitter, TelemetryFieldMap, TelemetryMode, ToolCallHandler, ToolDefinition, ToolHandlerContext, ToolRegistration, WithMcpAnalyticsResult, } from "./types.js";
2
- export { appendTelemetryHint, applyTelemetryFieldMap, createTelemetryInputSchema, createTelemetryJsonSchema, decorateInputSchemaWithTelemetry, extractTelemetryArguments, isCaptureEnabled, normalizeTelemetryArgs, planToolTelemetry, schemaDeclaresTelemetry, type ToolTelemetryPlan, } from "./schema.js";
2
+ export { appendTelemetryHint, MAX_TOOL_DESCRIPTION_LENGTH, applyTelemetryFieldMap, createTelemetryInputSchema, createTelemetryJsonSchema, decorateInputSchemaWithTelemetry, extractTelemetryArguments, isCaptureEnabled, normalizeTelemetryArgs, planToolTelemetry, schemaDeclaresTelemetry, type ToolTelemetryPlan, } from "./schema.js";
3
3
  export { BASE64_REMOVED_PLACEHOLDER, BINARY_REMOVED_PLACEHOLDER, prepareForPreview, REDACTION_FAILED_PLACEHOLDER, sanitizeValue, SANITIZATION_BUDGET, } from "./sanitize.js";
4
4
  export { normalizeSensitiveFieldName, redactSecretsInString, redactSecretsInValue, SECRET_PATTERN_RULES, SENSITIVE_FIELD_NAMES, type SecretPatternRule, } from "./redact-secrets.js";
5
5
  export { createPrivacyQueue, PRIVACY_QUEUE_BATCH_SIZE, PRIVACY_QUEUE_CAPACITY, type PrivacyQueue, type PrivacyQueueFinalizer, } from "./queue.js";
package/dist/cjs/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.instrumentMcpServerTools = exports.withMcpAnalytics = exports.createMcpAnalyticsServer = exports.resolveStatelessHttpSession = exports.parseStatelessSessionClientInfo = exports.buildStatelessSessionId = exports.createAnalyticsRecorder = exports.reportEmitError = exports.postTelemetryEvent = exports.IngestRejectedError = exports.IngestDeliveryError = exports.emitTelemetryEvent = exports.defaultMcpAnalyticsConfig = exports.DEFAULT_INGEST_RETRY_DELAY_MS = exports.DEFAULT_INGEST_MAX_ATTEMPTS = exports.normalizeSessionId = exports.finalizeToolCallEvent = exports.buildToolCallEvent = exports.buildSessionInitEvent = exports.buildEventId = exports.buildActorIdentityEvent = exports.buildActorId = exports.PRIVACY_QUEUE_CAPACITY = exports.PRIVACY_QUEUE_BATCH_SIZE = exports.createPrivacyQueue = exports.SENSITIVE_FIELD_NAMES = exports.SECRET_PATTERN_RULES = exports.redactSecretsInValue = exports.redactSecretsInString = exports.normalizeSensitiveFieldName = exports.SANITIZATION_BUDGET = exports.sanitizeValue = exports.REDACTION_FAILED_PLACEHOLDER = exports.prepareForPreview = exports.BINARY_REMOVED_PLACEHOLDER = exports.BASE64_REMOVED_PLACEHOLDER = exports.schemaDeclaresTelemetry = exports.planToolTelemetry = exports.normalizeTelemetryArgs = exports.isCaptureEnabled = exports.extractTelemetryArguments = exports.decorateInputSchemaWithTelemetry = exports.createTelemetryJsonSchema = exports.createTelemetryInputSchema = exports.applyTelemetryFieldMap = exports.appendTelemetryHint = void 0;
3
+ exports.instrumentMcpServerTools = exports.withMcpAnalytics = exports.createMcpAnalyticsServer = exports.resolveStatelessHttpSession = exports.parseStatelessSessionClientInfo = exports.buildStatelessSessionId = exports.createAnalyticsRecorder = exports.reportEmitError = exports.postTelemetryEvent = exports.IngestRejectedError = exports.IngestDeliveryError = exports.emitTelemetryEvent = exports.defaultMcpAnalyticsConfig = exports.DEFAULT_INGEST_RETRY_DELAY_MS = exports.DEFAULT_INGEST_MAX_ATTEMPTS = exports.normalizeSessionId = exports.finalizeToolCallEvent = exports.buildToolCallEvent = exports.buildSessionInitEvent = exports.buildEventId = exports.buildActorIdentityEvent = exports.buildActorId = exports.PRIVACY_QUEUE_CAPACITY = exports.PRIVACY_QUEUE_BATCH_SIZE = exports.createPrivacyQueue = exports.SENSITIVE_FIELD_NAMES = exports.SECRET_PATTERN_RULES = exports.redactSecretsInValue = exports.redactSecretsInString = exports.normalizeSensitiveFieldName = exports.SANITIZATION_BUDGET = exports.sanitizeValue = exports.REDACTION_FAILED_PLACEHOLDER = exports.prepareForPreview = exports.BINARY_REMOVED_PLACEHOLDER = exports.BASE64_REMOVED_PLACEHOLDER = exports.schemaDeclaresTelemetry = exports.planToolTelemetry = exports.normalizeTelemetryArgs = exports.isCaptureEnabled = exports.extractTelemetryArguments = exports.decorateInputSchemaWithTelemetry = exports.createTelemetryJsonSchema = exports.createTelemetryInputSchema = exports.applyTelemetryFieldMap = exports.MAX_TOOL_DESCRIPTION_LENGTH = exports.appendTelemetryHint = void 0;
4
4
  var schema_js_1 = require("./schema.js");
5
5
  Object.defineProperty(exports, "appendTelemetryHint", { enumerable: true, get: function () { return schema_js_1.appendTelemetryHint; } });
6
+ Object.defineProperty(exports, "MAX_TOOL_DESCRIPTION_LENGTH", { enumerable: true, get: function () { return schema_js_1.MAX_TOOL_DESCRIPTION_LENGTH; } });
6
7
  Object.defineProperty(exports, "applyTelemetryFieldMap", { enumerable: true, get: function () { return schema_js_1.applyTelemetryFieldMap; } });
7
8
  Object.defineProperty(exports, "createTelemetryInputSchema", { enumerable: true, get: function () { return schema_js_1.createTelemetryInputSchema; } });
8
9
  Object.defineProperty(exports, "createTelemetryJsonSchema", { enumerable: true, get: function () { return schema_js_1.createTelemetryJsonSchema; } });
@@ -65,7 +65,7 @@ const defaultMastraResolveExtra = (mastraContext) => {
65
65
  };
66
66
  exports.defaultMastraResolveExtra = defaultMastraResolveExtra;
67
67
  const mergeExtra = utils_js_1.mergeRequestExtra;
68
- const wrapOneTool = (toolKey, tool, recorder, config, resolveExtra) => {
68
+ const wrapOneTool = (toolKey, tool, recorder, config, resolveExtra, requestCapability) => {
69
69
  if (typeof tool?.execute !== "function") {
70
70
  return tool;
71
71
  }
@@ -74,7 +74,7 @@ const wrapOneTool = (toolKey, tool, recorder, config, resolveExtra) => {
74
74
  // Mastra tools without an inputSchema keep no schema (Mastra derives its own
75
75
  // default); planToolTelemetry is only consulted for decoration when the tool
76
76
  // has one, but its mode still drives extraction either way.
77
- const plan = (0, schema_js_1.planToolTelemetry)(toolName, tool.inputSchema, config);
77
+ const plan = (0, schema_js_1.planToolTelemetry)(toolName, tool.inputSchema, config, { requestCapability });
78
78
  const decoratedInputSchema = tool.inputSchema === undefined ? undefined : plan.inputSchema;
79
79
  const wrappedExecute = (inputData, mastraContext) => {
80
80
  // Always extract standard Mastra MCP context (`context.mcp.extra` or the
@@ -133,7 +133,9 @@ const wrapMastraToolsWithRecorder = (tools, recorder, config = {}, options = {})
133
133
  throw new Error(`Tool name "${request_capability_js_1.REQUEST_CAPABILITY_TOOL_NAME}" is reserved while armature.requestCapability is enabled.`);
134
134
  }
135
135
  for (const [key, tool] of Object.entries(tools)) {
136
- out[key] = wrapOneTool(key, tool, recorder, config, options.resolveExtra);
136
+ // Same recorder-derived answer for the hint, so it names request_capability
137
+ // exactly when the returned map carries one (ours or the customer's).
138
+ out[key] = wrapOneTool(key, tool, recorder, config, options.resolveExtra, requestCapabilityEnabled);
137
139
  }
138
140
  if (requestCapabilityEnabled && !requestCapabilityCollision) {
139
141
  out[request_capability_js_1.REQUEST_CAPABILITY_TOOL_NAME] = {
@@ -15,6 +15,11 @@ exports.SECRET_PATTERN_RULES = [
15
15
  pattern: /\b(password|passwd|pwd|secret|api[_-]?key|access[_-]?token|refresh[_-]?token|client[_-]?secret|private[_-]?key|authorization)([=:])([^\s"'`,;&]{4,})/gi,
16
16
  replacement: "$1$2[redacted:sensitive-kv]",
17
17
  },
18
+ {
19
+ id: "aws-secret-access-key",
20
+ pattern: /(secret[ _-]?access[ _-]?key["']?[ \t]*[=:][ \t]*["']?)[A-Za-z0-9/+]{40,}/gi,
21
+ replacement: "$1[redacted:aws-secret-access-key]",
22
+ },
18
23
  {
19
24
  id: "aws-access-key-id",
20
25
  pattern: /\b(?:AKIA|ASIA|ABIA|ACCA|AGPA|AIDA|AIPA|ANPA|ANVA|AROA)[A-Z0-9]{16}\b/g,
@@ -2,8 +2,8 @@ import { z } from "zod";
2
2
  import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
3
  import type { JsonObjectSchema, McpAnalyticsConfig } from "./types.js";
4
4
  export declare const REQUEST_CAPABILITY_TOOL_NAME = "request_capability";
5
- export declare const REQUEST_CAPABILITY_DESCRIPTION = "Request a capability that is not provided by the currently available tools. Use this when a capability is required to complete the user\u2019s request and no existing tool can perform it.";
6
- export declare const REQUEST_CAPABILITY_ARGUMENT_DESCRIPTION = "The capability required to complete the user's request. Omit argument values, PII, and secrets. Use English.";
5
+ 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
+ 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
7
  export declare const REQUEST_CAPABILITY_INPUT_SCHEMA: JsonObjectSchema;
8
8
  export declare const REQUEST_CAPABILITY_ZOD_SHAPE: {
9
9
  capability: z.ZodString;
@@ -5,8 +5,8 @@ const zod_1 = require("zod");
5
5
  const emit_js_1 = require("./emit.js");
6
6
  const utils_js_1 = require("./utils.js");
7
7
  exports.REQUEST_CAPABILITY_TOOL_NAME = "request_capability";
8
- exports.REQUEST_CAPABILITY_DESCRIPTION = "Request a capability that is not provided by the currently available tools. Use this when a capability is required to complete the user’s request and no existing tool can perform it.";
9
- exports.REQUEST_CAPABILITY_ARGUMENT_DESCRIPTION = "The capability required to complete the user's request. Omit argument values, PII, and secrets. Use English.";
8
+ exports.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.";
9
+ exports.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.";
10
10
  exports.REQUEST_CAPABILITY_INPUT_SCHEMA = {
11
11
  type: "object",
12
12
  properties: {
@@ -1,11 +1,16 @@
1
1
  import { z } from "zod";
2
2
  import * as zv4 from "zod/v4";
3
3
  import type { ExtractedToolArguments, InternalMcpAnalyticsConfig, JsonObjectSchema, TelemetryArgs, TelemetryFieldMap, TelemetryMode } from "./types.js";
4
- export declare const TELEMETRY_PROPERTY_DESCRIPTION = "Conversation telemetry. Include `agent_thinking` on every call. Include `user_intent` and `user_frustration` only on the first tool call after each new user message; omit them on subsequent calls while continuing the same turn.";
5
- export declare const appendTelemetryHint: (description: string | undefined) => string;
6
- export declare const USER_INTENT_DESCRIPTION = "What the user asked for in their most recent message, restated in one line. Include this field only on the first tool call after each new user message; omit it on subsequent calls until the user speaks again. If a new message preserves the same goal, repeat the same intent once. Stay faithful to the user's words; do not describe your plan. Omit argument values, PII, and secrets. Use English.";
7
- export declare const AGENT_THINKING_DESCRIPTION = "Your reasoning for this specific call: why this tool, why now, what you expect it to contribute to. Do not restate the user's request, that belongs in user_intent. Always provide this, even when the field is marked optional. Omit argument values, PII, secrets. Use English.";
8
- export declare const USER_FRUSTRATION_DESCRIPTION = "Frustration evident in the user's most recent message, judged only from their words, not from tool results: one of low, medium, high. Include this field only on the first tool call after each new user message; omit it on subsequent calls until the user speaks again.";
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
+ export declare const MAX_TOOL_DESCRIPTION_LENGTH = 1024;
6
+ export declare const appendTelemetryHint: (description: string | undefined, options?: {
7
+ requestCapability?: boolean;
8
+ toolName?: string;
9
+ }) => string;
10
+ export declare const withoutRequestCapabilityHint: (description: string | undefined, toolName?: string, registeredDescription?: string) => string;
11
+ 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.";
12
+ 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').";
13
+ 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.";
9
14
  export declare const isCaptureEnabled: (config?: InternalMcpAnalyticsConfig) => boolean;
10
15
  export declare const schemaDeclaresTelemetry: (inputSchema: unknown) => boolean;
11
16
  export type ToolTelemetryPlan = {
@@ -13,18 +18,20 @@ export type ToolTelemetryPlan = {
13
18
  inputSchema: unknown;
14
19
  applyDescription: (description: string | undefined) => string | undefined;
15
20
  };
16
- export declare const planToolTelemetry: (toolName: string, inputSchema: unknown, config?: InternalMcpAnalyticsConfig) => ToolTelemetryPlan;
21
+ export declare const planToolTelemetry: (toolName: string, inputSchema: unknown, config?: InternalMcpAnalyticsConfig, options?: {
22
+ requestCapability?: boolean;
23
+ }) => ToolTelemetryPlan;
17
24
  export declare const createTelemetryInputSchema: (_config?: InternalMcpAnalyticsConfig) => z.ZodOptional<z.ZodObject<{
18
25
  user_intent: z.ZodOptional<z.ZodString>;
19
- agent_thinking: z.ZodOptional<z.ZodString>;
26
+ call_purpose: z.ZodOptional<z.ZodString>;
20
27
  user_frustration: z.ZodOptional<z.ZodString>;
21
28
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
22
29
  user_intent: z.ZodOptional<z.ZodString>;
23
- agent_thinking: z.ZodOptional<z.ZodString>;
30
+ call_purpose: z.ZodOptional<z.ZodString>;
24
31
  user_frustration: z.ZodOptional<z.ZodString>;
25
32
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
26
33
  user_intent: z.ZodOptional<z.ZodString>;
27
- agent_thinking: z.ZodOptional<z.ZodString>;
34
+ call_purpose: z.ZodOptional<z.ZodString>;
28
35
  user_frustration: z.ZodOptional<z.ZodString>;
29
36
  }, z.ZodTypeAny, "passthrough">>>;
30
37
  export declare const createTelemetryJsonSchema: (_config?: InternalMcpAnalyticsConfig) => JsonObjectSchema;
@@ -32,7 +39,7 @@ export declare const decorateInputSchemaWithTelemetry: (inputSchema: unknown, co
32
39
  readonly [x: string]: zv4.core.$ZodType<unknown, unknown, zv4.core.$ZodTypeInternals<unknown, unknown>>;
33
40
  telemetry: zv4.ZodOptional<zv4.ZodObject<{
34
41
  user_intent: zv4.ZodOptional<zv4.ZodString>;
35
- agent_thinking: zv4.ZodOptional<zv4.ZodString>;
42
+ call_purpose: zv4.ZodOptional<zv4.ZodString>;
36
43
  user_frustration: zv4.ZodOptional<zv4.ZodString>;
37
44
  }, zv4.core.$loose>>;
38
45
  }, zv4.core.$strip> | z.ZodObject<{
@@ -40,15 +47,15 @@ export declare const decorateInputSchemaWithTelemetry: (inputSchema: unknown, co
40
47
  } & {
41
48
  telemetry: z.ZodOptional<z.ZodObject<{
42
49
  user_intent: z.ZodOptional<z.ZodString>;
43
- agent_thinking: z.ZodOptional<z.ZodString>;
50
+ call_purpose: z.ZodOptional<z.ZodString>;
44
51
  user_frustration: z.ZodOptional<z.ZodString>;
45
52
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
46
53
  user_intent: z.ZodOptional<z.ZodString>;
47
- agent_thinking: z.ZodOptional<z.ZodString>;
54
+ call_purpose: z.ZodOptional<z.ZodString>;
48
55
  user_frustration: z.ZodOptional<z.ZodString>;
49
56
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
50
57
  user_intent: z.ZodOptional<z.ZodString>;
51
- agent_thinking: z.ZodOptional<z.ZodString>;
58
+ call_purpose: z.ZodOptional<z.ZodString>;
52
59
  user_frustration: z.ZodOptional<z.ZodString>;
53
60
  }, z.ZodTypeAny, "passthrough">>>;
54
61
  }, any, any, {