@armature-tech/mcp-analytics 0.6.32 → 0.6.33

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.
@@ -6,6 +6,7 @@ const node_path_1 = require("node:path");
6
6
  const index_js_1 = require("@modelcontextprotocol/sdk/client/index.js");
7
7
  const stdio_js_1 = require("@modelcontextprotocol/sdk/client/stdio.js");
8
8
  const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
9
+ const emit_js_1 = require("./emit.js");
9
10
  const request_capability_js_1 = require("./request-capability.js");
10
11
  const DEFAULT_INGEST_URL = "https://app.armature.tech/api/mcp-analytics/ingest";
11
12
  const DEFAULT_TIMEOUT_MS = 10_000;
@@ -295,8 +296,9 @@ const verifyIngest = async (endpoint, apiKey, timeoutMs) => {
295
296
  headers: {
296
297
  "content-type": "application/json",
297
298
  authorization: `Bearer ${apiKey}`,
299
+ "user-agent": emit_js_1.SDK_USER_AGENT,
298
300
  },
299
- body: JSON.stringify({ schema_version: 1, events: [] }),
301
+ body: JSON.stringify({ schema_version: 1, events: [], sdk: emit_js_1.SDK_IDENTITY }),
300
302
  signal: controller.signal,
301
303
  });
302
304
  // Read the body so undici can release its pooled connection promptly (the
@@ -1,4 +1,6 @@
1
- import type { ActorIdResolverInput, AnalyticsIngestBatch, McpAnalyticsConfig } from "./types.js";
1
+ import type { ActorIdResolverInput, AnalyticsBatchSdk, AnalyticsIngestBatch, McpAnalyticsConfig } from "./types.js";
2
+ export declare const SDK_IDENTITY: AnalyticsBatchSdk;
3
+ export declare const SDK_USER_AGENT: string;
2
4
  export declare const defaultMcpAnalyticsConfig: {
3
5
  armature: {
4
6
  endpointUrl: string;
package/dist/cjs/emit.js CHANGED
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createFlushableEmitter = exports.emitTelemetryEvent = exports.reportEmitError = exports.postAndCheck = exports.postTelemetryEvent = exports.describeIngestRejection = exports.IngestRejectedError = exports.resolveActorIdentifier = exports.resolveActorSeed = exports.resolveApiKey = exports.resolveEndpointUrl = exports.IngestDeliveryError = exports.DEFAULT_INGEST_RETRY_DELAY_MS = exports.DEFAULT_INGEST_MAX_ATTEMPTS = exports.defaultMcpAnalyticsConfig = void 0;
3
+ exports.createFlushableEmitter = exports.emitTelemetryEvent = exports.reportEmitError = exports.postAndCheck = exports.postTelemetryEvent = exports.describeIngestRejection = exports.IngestRejectedError = exports.resolveActorIdentifier = exports.resolveActorSeed = exports.resolveApiKey = exports.resolveEndpointUrl = exports.IngestDeliveryError = exports.DEFAULT_INGEST_RETRY_DELAY_MS = exports.DEFAULT_INGEST_MAX_ATTEMPTS = exports.defaultMcpAnalyticsConfig = exports.SDK_USER_AGENT = exports.SDK_IDENTITY = void 0;
4
4
  const utils_js_1 = require("./utils.js");
5
+ const version_js_1 = require("./version.js");
6
+ exports.SDK_IDENTITY = {
7
+ language: "typescript",
8
+ version: version_js_1.SDK_VERSION,
9
+ };
10
+ exports.SDK_USER_AGENT = `armature-mcp-analytics-typescript/${version_js_1.SDK_VERSION}`;
5
11
  exports.defaultMcpAnalyticsConfig = {
6
12
  armature: {
7
13
  endpointUrl: "https://app.armature.tech/api/mcp-analytics/ingest",
@@ -129,7 +135,10 @@ const postTelemetryEvent = async (batch, config = exports.defaultMcpAnalyticsCon
129
135
  if (!apiKey) {
130
136
  return { skipped: true, reason: "ingest_config_missing" };
131
137
  }
132
- const body = JSON.stringify(batch);
138
+ // Stamp the SDK identity at the delivery boundary so every batch that
139
+ // reaches Armature ingest carries it, regardless of which path built the
140
+ // batch (privacy queue, flushable emitter, one-shot emit).
141
+ const body = JSON.stringify(batch.sdk ? batch : { ...batch, sdk: exports.SDK_IDENTITY });
133
142
  const timeoutMs = config.armature?.timeoutMs ?? exports.defaultMcpAnalyticsConfig.armature.timeoutMs;
134
143
  for (let attempt = 1; attempt <= exports.DEFAULT_INGEST_MAX_ATTEMPTS; attempt += 1) {
135
144
  const controller = new AbortController();
@@ -140,6 +149,7 @@ const postTelemetryEvent = async (batch, config = exports.defaultMcpAnalyticsCon
140
149
  headers: {
141
150
  "Content-Type": "application/json",
142
151
  Authorization: `Bearer ${apiKey}`,
152
+ "User-Agent": exports.SDK_USER_AGENT,
143
153
  },
144
154
  body,
145
155
  signal: controller.signal,
@@ -226,9 +226,14 @@ export type AnalyticsIngestEvent = {
226
226
  is_workflow?: boolean;
227
227
  workflow_run_id?: string;
228
228
  };
229
+ export type AnalyticsBatchSdk = {
230
+ language: string;
231
+ version: string;
232
+ };
229
233
  export type AnalyticsIngestBatch = {
230
234
  schema_version: 1;
231
235
  events: AnalyticsIngestEvent[];
236
+ sdk?: AnalyticsBatchSdk;
232
237
  };
233
238
  export type TelemetryEmitter = (batch: AnalyticsIngestBatch) => void | Promise<void>;
234
239
  export type WithMcpAnalyticsResult<ServerFactoryResult> = {
@@ -0,0 +1 @@
1
+ export declare const SDK_VERSION: string;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SDK_VERSION = "0.0.0-development";
@@ -3,6 +3,7 @@ import { resolve } from "node:path";
3
3
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
4
4
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
5
5
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
6
+ import { SDK_IDENTITY, SDK_USER_AGENT } from "./emit.js";
6
7
  import { REQUEST_CAPABILITY_DESCRIPTION, REQUEST_CAPABILITY_TOOL_NAME, } from "./request-capability.js";
7
8
  const DEFAULT_INGEST_URL = "https://app.armature.tech/api/mcp-analytics/ingest";
8
9
  const DEFAULT_TIMEOUT_MS = 10_000;
@@ -285,8 +286,9 @@ export const verifyIngest = async (endpoint, apiKey, timeoutMs) => {
285
286
  headers: {
286
287
  "content-type": "application/json",
287
288
  authorization: `Bearer ${apiKey}`,
289
+ "user-agent": SDK_USER_AGENT,
288
290
  },
289
- body: JSON.stringify({ schema_version: 1, events: [] }),
291
+ body: JSON.stringify({ schema_version: 1, events: [], sdk: SDK_IDENTITY }),
290
292
  signal: controller.signal,
291
293
  });
292
294
  // Read the body so undici can release its pooled connection promptly (the
@@ -1,4 +1,6 @@
1
- import type { ActorIdResolverInput, AnalyticsIngestBatch, McpAnalyticsConfig } from "./types.js";
1
+ import type { ActorIdResolverInput, AnalyticsBatchSdk, AnalyticsIngestBatch, McpAnalyticsConfig } from "./types.js";
2
+ export declare const SDK_IDENTITY: AnalyticsBatchSdk;
3
+ export declare const SDK_USER_AGENT: string;
2
4
  export declare const defaultMcpAnalyticsConfig: {
3
5
  armature: {
4
6
  endpointUrl: string;
package/dist/esm/emit.js CHANGED
@@ -1,4 +1,10 @@
1
1
  import { headerValue, readEnv } from "./utils.js";
2
+ import { SDK_VERSION } from "./version.js";
3
+ export const SDK_IDENTITY = {
4
+ language: "typescript",
5
+ version: SDK_VERSION,
6
+ };
7
+ export const SDK_USER_AGENT = `armature-mcp-analytics-typescript/${SDK_VERSION}`;
2
8
  export const defaultMcpAnalyticsConfig = {
3
9
  armature: {
4
10
  endpointUrl: "https://app.armature.tech/api/mcp-analytics/ingest",
@@ -119,7 +125,10 @@ export const postTelemetryEvent = async (batch, config = defaultMcpAnalyticsConf
119
125
  if (!apiKey) {
120
126
  return { skipped: true, reason: "ingest_config_missing" };
121
127
  }
122
- const body = JSON.stringify(batch);
128
+ // Stamp the SDK identity at the delivery boundary so every batch that
129
+ // reaches Armature ingest carries it, regardless of which path built the
130
+ // batch (privacy queue, flushable emitter, one-shot emit).
131
+ const body = JSON.stringify(batch.sdk ? batch : { ...batch, sdk: SDK_IDENTITY });
123
132
  const timeoutMs = config.armature?.timeoutMs ?? defaultMcpAnalyticsConfig.armature.timeoutMs;
124
133
  for (let attempt = 1; attempt <= DEFAULT_INGEST_MAX_ATTEMPTS; attempt += 1) {
125
134
  const controller = new AbortController();
@@ -130,6 +139,7 @@ export const postTelemetryEvent = async (batch, config = defaultMcpAnalyticsConf
130
139
  headers: {
131
140
  "Content-Type": "application/json",
132
141
  Authorization: `Bearer ${apiKey}`,
142
+ "User-Agent": SDK_USER_AGENT,
133
143
  },
134
144
  body,
135
145
  signal: controller.signal,
@@ -226,9 +226,14 @@ export type AnalyticsIngestEvent = {
226
226
  is_workflow?: boolean;
227
227
  workflow_run_id?: string;
228
228
  };
229
+ export type AnalyticsBatchSdk = {
230
+ language: string;
231
+ version: string;
232
+ };
229
233
  export type AnalyticsIngestBatch = {
230
234
  schema_version: 1;
231
235
  events: AnalyticsIngestEvent[];
236
+ sdk?: AnalyticsBatchSdk;
232
237
  };
233
238
  export type TelemetryEmitter = (batch: AnalyticsIngestBatch) => void | Promise<void>;
234
239
  export type WithMcpAnalyticsResult<ServerFactoryResult> = {
@@ -0,0 +1 @@
1
+ export declare const SDK_VERSION: string;
@@ -0,0 +1 @@
1
+ export const SDK_VERSION = "0.0.0-development";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@armature-tech/mcp-analytics",
3
- "version": "0.6.32",
3
+ "version": "0.6.33",
4
4
  "type": "module",
5
5
  "description": "MCP analytics wrapper SDK that instruments MCP tool declarations with telemetry.",
6
6
  "license": "Apache-2.0",
@@ -75,7 +75,8 @@
75
75
  "build:esm": "tsc -p tsconfig.esm.json",
76
76
  "build:cjs": "tsc -p tsconfig.cjs.json",
77
77
  "build:markers": "node -e \"require('fs').writeFileSync('dist/esm/package.json', '{\\\"type\\\":\\\"module\\\"}\\n'); require('fs').writeFileSync('dist/cjs/package.json', '{\\\"type\\\":\\\"commonjs\\\"}\\n')\"",
78
- "build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:markers",
78
+ "build:version": "node scripts/stamp-version.mjs",
79
+ "build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:markers && npm run build:version",
79
80
  "prepublishOnly": "npm run check && npm run build"
80
81
  },
81
82
  "publishConfig": {