@armature-tech/mcp-analytics 0.6.31 → 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.
- package/dist/cjs/doctor.d.ts +1 -1
- package/dist/cjs/doctor.js +25 -2
- package/dist/cjs/emit.d.ts +3 -1
- package/dist/cjs/emit.js +12 -2
- package/dist/cjs/types.d.ts +5 -0
- package/dist/cjs/version.d.ts +1 -0
- package/dist/cjs/version.js +3 -0
- package/dist/esm/doctor.d.ts +1 -1
- package/dist/esm/doctor.js +25 -2
- package/dist/esm/emit.d.ts +3 -1
- package/dist/esm/emit.js +11 -1
- package/dist/esm/types.d.ts +5 -0
- package/dist/esm/version.d.ts +1 -0
- package/dist/esm/version.js +1 -0
- package/package.json +3 -2
package/dist/cjs/doctor.d.ts
CHANGED
package/dist/cjs/doctor.js
CHANGED
|
@@ -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;
|
|
@@ -256,6 +257,25 @@ const detectLocalSdks = async (cwd) => {
|
|
|
256
257
|
?.match(/github\.com\/armature-tech\/mcp-analytics-go(?:\/[^\s]+)?\s+v[^\s)]+/)?.[0];
|
|
257
258
|
if (goDeclaration)
|
|
258
259
|
found.push({ language: "go", declaration: goDeclaration });
|
|
260
|
+
const composerJson = await readIfPresent((0, node_path_1.resolve)(cwd, "composer.json"));
|
|
261
|
+
if (composerJson) {
|
|
262
|
+
try {
|
|
263
|
+
const parsed = JSON.parse(composerJson);
|
|
264
|
+
const sections = [parsed.require, parsed["require-dev"]];
|
|
265
|
+
for (const section of sections) {
|
|
266
|
+
if (isRecord(section) && typeof section["armature/mcp-analytics"] === "string") {
|
|
267
|
+
found.push({
|
|
268
|
+
language: "php",
|
|
269
|
+
declaration: `armature/mcp-analytics ${section["armature/mcp-analytics"]}`,
|
|
270
|
+
});
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
// A malformed composer.json will be reported by Composer.
|
|
277
|
+
}
|
|
278
|
+
}
|
|
259
279
|
return found;
|
|
260
280
|
};
|
|
261
281
|
exports.detectLocalSdks = detectLocalSdks;
|
|
@@ -276,8 +296,9 @@ const verifyIngest = async (endpoint, apiKey, timeoutMs) => {
|
|
|
276
296
|
headers: {
|
|
277
297
|
"content-type": "application/json",
|
|
278
298
|
authorization: `Bearer ${apiKey}`,
|
|
299
|
+
"user-agent": emit_js_1.SDK_USER_AGENT,
|
|
279
300
|
},
|
|
280
|
-
body: JSON.stringify({ schema_version: 1, events: [] }),
|
|
301
|
+
body: JSON.stringify({ schema_version: 1, events: [], sdk: emit_js_1.SDK_IDENTITY }),
|
|
281
302
|
signal: controller.signal,
|
|
282
303
|
});
|
|
283
304
|
// Read the body so undici can release its pooled connection promptly (the
|
|
@@ -325,8 +346,10 @@ const wrapApiFor = (language) => {
|
|
|
325
346
|
return "instrument_fastmcp (or an Armature recorder)";
|
|
326
347
|
case "typescript":
|
|
327
348
|
return "withMcpAnalytics (or an Armature recorder)";
|
|
349
|
+
case "php":
|
|
350
|
+
return "Analytics::instrument (or an Armature Recorder)";
|
|
328
351
|
default:
|
|
329
|
-
return "the SDK's tool instrumentation (InstrumentTool / withMcpAnalytics / instrument_fastmcp)";
|
|
352
|
+
return "the SDK's tool instrumentation (InstrumentTool / withMcpAnalytics / instrument_fastmcp / Analytics::instrument)";
|
|
330
353
|
}
|
|
331
354
|
};
|
|
332
355
|
const pass = (id, label, detail) => ({
|
package/dist/cjs/emit.d.ts
CHANGED
|
@@ -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
|
-
|
|
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,
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -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;
|
package/dist/esm/doctor.d.ts
CHANGED
package/dist/esm/doctor.js
CHANGED
|
@@ -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;
|
|
@@ -247,6 +248,25 @@ export const detectLocalSdks = async (cwd) => {
|
|
|
247
248
|
?.match(/github\.com\/armature-tech\/mcp-analytics-go(?:\/[^\s]+)?\s+v[^\s)]+/)?.[0];
|
|
248
249
|
if (goDeclaration)
|
|
249
250
|
found.push({ language: "go", declaration: goDeclaration });
|
|
251
|
+
const composerJson = await readIfPresent(resolve(cwd, "composer.json"));
|
|
252
|
+
if (composerJson) {
|
|
253
|
+
try {
|
|
254
|
+
const parsed = JSON.parse(composerJson);
|
|
255
|
+
const sections = [parsed.require, parsed["require-dev"]];
|
|
256
|
+
for (const section of sections) {
|
|
257
|
+
if (isRecord(section) && typeof section["armature/mcp-analytics"] === "string") {
|
|
258
|
+
found.push({
|
|
259
|
+
language: "php",
|
|
260
|
+
declaration: `armature/mcp-analytics ${section["armature/mcp-analytics"]}`,
|
|
261
|
+
});
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
// A malformed composer.json will be reported by Composer.
|
|
268
|
+
}
|
|
269
|
+
}
|
|
250
270
|
return found;
|
|
251
271
|
};
|
|
252
272
|
export const verifyIngest = async (endpoint, apiKey, timeoutMs) => {
|
|
@@ -266,8 +286,9 @@ export const verifyIngest = async (endpoint, apiKey, timeoutMs) => {
|
|
|
266
286
|
headers: {
|
|
267
287
|
"content-type": "application/json",
|
|
268
288
|
authorization: `Bearer ${apiKey}`,
|
|
289
|
+
"user-agent": SDK_USER_AGENT,
|
|
269
290
|
},
|
|
270
|
-
body: JSON.stringify({ schema_version: 1, events: [] }),
|
|
291
|
+
body: JSON.stringify({ schema_version: 1, events: [], sdk: SDK_IDENTITY }),
|
|
271
292
|
signal: controller.signal,
|
|
272
293
|
});
|
|
273
294
|
// Read the body so undici can release its pooled connection promptly (the
|
|
@@ -314,8 +335,10 @@ const wrapApiFor = (language) => {
|
|
|
314
335
|
return "instrument_fastmcp (or an Armature recorder)";
|
|
315
336
|
case "typescript":
|
|
316
337
|
return "withMcpAnalytics (or an Armature recorder)";
|
|
338
|
+
case "php":
|
|
339
|
+
return "Analytics::instrument (or an Armature Recorder)";
|
|
317
340
|
default:
|
|
318
|
-
return "the SDK's tool instrumentation (InstrumentTool / withMcpAnalytics / instrument_fastmcp)";
|
|
341
|
+
return "the SDK's tool instrumentation (InstrumentTool / withMcpAnalytics / instrument_fastmcp / Analytics::instrument)";
|
|
319
342
|
}
|
|
320
343
|
};
|
|
321
344
|
const pass = (id, label, detail) => ({
|
package/dist/esm/emit.d.ts
CHANGED
|
@@ -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
|
-
|
|
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,
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -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.
|
|
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": "
|
|
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": {
|