@kometolabs/mcp-analytics 0.0.0-stage → 0.1.0
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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/OTLP.md +81 -0
- package/README.md +194 -2
- package/dist/analytics.d.ts +172 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +799 -0
- package/dist/analytics.js.map +1 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +72 -0
- package/dist/cli.js.map +1 -0
- package/dist/clients.d.ts +5 -0
- package/dist/clients.d.ts.map +1 -0
- package/dist/clients.js +29 -0
- package/dist/clients.js.map +1 -0
- package/dist/doctor.d.ts +27 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +108 -0
- package/dist/doctor.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp.d.ts +87 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +291 -0
- package/dist/mcp.js.map +1 -0
- package/dist/otlp-protocol.d.ts +10 -0
- package/dist/otlp-protocol.d.ts.map +1 -0
- package/dist/otlp-protocol.js +485 -0
- package/dist/otlp-protocol.js.map +1 -0
- package/dist/otlp.d.ts +24 -0
- package/dist/otlp.d.ts.map +1 -0
- package/dist/otlp.js +174 -0
- package/dist/otlp.js.map +1 -0
- package/package.json +59 -3
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { createAnalytics, debugLine, enabledFlag, instanceInfo } from './analytics.js';
|
|
2
|
+
/**
|
|
3
|
+
* `observe()` for servers built on the MCP TypeScript SDK, v1
|
|
4
|
+
* (`@modelcontextprotocol/sdk`) and v2 (`@modelcontextprotocol/server`). It
|
|
5
|
+
* has no dependency on either: the types below describe only the parts it uses.
|
|
6
|
+
*/
|
|
7
|
+
/** Reserved per-request `_meta` key for the self-reported client (MCP 2026-07-28). */
|
|
8
|
+
export const CLIENT_INFO_META_KEY = 'io.modelcontextprotocol/clientInfo';
|
|
9
|
+
/** Process-wide instances keyed by configuration, so per-request servers share one queue. */
|
|
10
|
+
const shared = new Map();
|
|
11
|
+
const SHARED_LIMIT = 16;
|
|
12
|
+
const observedServers = new WeakSet();
|
|
13
|
+
/** How many servers each instance observes; a single server flushes when it closes. */
|
|
14
|
+
const serverCounts = new WeakMap();
|
|
15
|
+
const wrappedCallbacks = new WeakSet();
|
|
16
|
+
const functionIds = new WeakMap();
|
|
17
|
+
const reported = new Set();
|
|
18
|
+
let nextFunctionId = 0;
|
|
19
|
+
let exitHookInstalled = false;
|
|
20
|
+
function isThenable(value) {
|
|
21
|
+
return value !== null && (typeof value === 'object' || typeof value === 'function')
|
|
22
|
+
&& typeof value.then === 'function';
|
|
23
|
+
}
|
|
24
|
+
/** Each distinct message is printed once per process, so per-request servers cannot flood stderr. */
|
|
25
|
+
function reportOnce(message) {
|
|
26
|
+
if (reported.has(message))
|
|
27
|
+
return;
|
|
28
|
+
reported.add(message);
|
|
29
|
+
try {
|
|
30
|
+
process.stderr.write(`${message}\n`);
|
|
31
|
+
}
|
|
32
|
+
catch { /* output must never affect the server */ }
|
|
33
|
+
}
|
|
34
|
+
function problemOf(error) {
|
|
35
|
+
const message = error instanceof Error ? error.message : 'unexpected error';
|
|
36
|
+
return message.replace(/^Invalid (analytics|OTLP) configuration: /, '');
|
|
37
|
+
}
|
|
38
|
+
/** Configuration plus the relevant environment; functions compare by identity. */
|
|
39
|
+
function fingerprint(config) {
|
|
40
|
+
const source = config.env !== undefined && config.env !== null && typeof config.env === 'object' ? config.env : process.env;
|
|
41
|
+
const environment = Object.keys(source).filter((key) => key.startsWith('MCP_ANALYTICS_') || key === 'NODE_ENV').sort()
|
|
42
|
+
.map((key) => [key, source[key]]);
|
|
43
|
+
return JSON.stringify([environment, config], (_key, value) => {
|
|
44
|
+
if (typeof value !== 'function')
|
|
45
|
+
return value;
|
|
46
|
+
let id = functionIds.get(value);
|
|
47
|
+
if (id === undefined) {
|
|
48
|
+
id = ++nextFunctionId;
|
|
49
|
+
functionIds.set(value, id);
|
|
50
|
+
}
|
|
51
|
+
return `function ${id}`;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function closeShared(options) {
|
|
55
|
+
const instances = [...shared.values()].filter((entry) => !(entry instanceof Error));
|
|
56
|
+
shared.clear();
|
|
57
|
+
return instances.map((analytics) => analytics.close(options).catch(() => { }));
|
|
58
|
+
}
|
|
59
|
+
function sharedAnalytics(config) {
|
|
60
|
+
const key = fingerprint(config);
|
|
61
|
+
const cached = shared.get(key);
|
|
62
|
+
if (cached instanceof Error)
|
|
63
|
+
throw cached;
|
|
64
|
+
if (cached !== undefined)
|
|
65
|
+
return cached;
|
|
66
|
+
let analytics;
|
|
67
|
+
try {
|
|
68
|
+
analytics = createAnalytics(config);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
shared.set(key, error instanceof Error ? error : new TypeError(problemOf(error)));
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
shared.set(key, analytics);
|
|
75
|
+
if (shared.size > SHARED_LIMIT) {
|
|
76
|
+
reportOnce(`MCP analytics: observe() has created more than ${SHARED_LIMIT} analytics instances. Pass the same options to every observe() call and define function options, such as onDiagnostic, once outside per-request code.`);
|
|
77
|
+
}
|
|
78
|
+
if (!exitHookInstalled) {
|
|
79
|
+
exitHookInstalled = true;
|
|
80
|
+
// Best effort when the event loop drains (stdin closed, work done). No
|
|
81
|
+
// signal handlers are installed; closing is bounded by flushTimeoutMs.
|
|
82
|
+
process.on('beforeExit', () => { void closeShared(); });
|
|
83
|
+
}
|
|
84
|
+
return analytics;
|
|
85
|
+
}
|
|
86
|
+
/** Flushes and closes every instance `observe()` created. Instances passed as `analytics` stay open. */
|
|
87
|
+
export async function closeAnalytics(options) {
|
|
88
|
+
await Promise.all(closeShared(options));
|
|
89
|
+
}
|
|
90
|
+
function authInfoOf(ctx) {
|
|
91
|
+
const context = ctx;
|
|
92
|
+
return context?.http?.authInfo ?? context?.authInfo;
|
|
93
|
+
}
|
|
94
|
+
/** The verified OAuth subject; `authInfo` exists only after the MCP SDK verified a bearer token. */
|
|
95
|
+
function verifiedUser(ctx) {
|
|
96
|
+
try {
|
|
97
|
+
const extra = authInfoOf(ctx)?.extra;
|
|
98
|
+
const sub = extra?.sub;
|
|
99
|
+
if (typeof sub !== 'string' || sub.length === 0)
|
|
100
|
+
return undefined;
|
|
101
|
+
const iss = extra?.iss;
|
|
102
|
+
return typeof iss === 'string' && iss.length > 0 ? { issuer: iss, id: sub } : sub;
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// The client label is self-reported and unverified; the SDK still maps it
|
|
109
|
+
// through the client allowlist before it enters telemetry.
|
|
110
|
+
function clientName(server, ctx) {
|
|
111
|
+
try {
|
|
112
|
+
const context = ctx;
|
|
113
|
+
const meta = context?.mcpReq?.envelope ?? context?._meta;
|
|
114
|
+
const info = meta?.[CLIENT_INFO_META_KEY];
|
|
115
|
+
if (typeof info?.name === 'string')
|
|
116
|
+
return info.name;
|
|
117
|
+
const legacy = server.server?.getClientVersion?.()?.name;
|
|
118
|
+
return typeof legacy === 'string' ? legacy : undefined;
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function merge(clientApplication, user, extra) {
|
|
125
|
+
const context = {};
|
|
126
|
+
if (clientApplication !== undefined)
|
|
127
|
+
context.clientApplication = clientApplication;
|
|
128
|
+
if (user !== undefined && user !== null)
|
|
129
|
+
context.subject = user;
|
|
130
|
+
if (extra !== undefined) {
|
|
131
|
+
if (extra === null || typeof extra !== 'object')
|
|
132
|
+
throw new TypeError('Invalid analytics context');
|
|
133
|
+
for (const key of ['subject', 'clientApplication', 'sourceTag', 'operationId']) {
|
|
134
|
+
if (extra[key] !== undefined)
|
|
135
|
+
context[key] = extra[key];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return context;
|
|
139
|
+
}
|
|
140
|
+
function define(target, key, value) {
|
|
141
|
+
Object.defineProperty(target, key, { value, writable: true, configurable: true, enumerable: false });
|
|
142
|
+
}
|
|
143
|
+
function instrument(server, analytics, user, context) {
|
|
144
|
+
const automaticUser = user === undefined && instanceInfo(analytics)?.identity === true;
|
|
145
|
+
const registered = server._registeredTools;
|
|
146
|
+
if (registered !== null && typeof registered === 'object' && Object.keys(registered).length > 0) {
|
|
147
|
+
reportOnce('MCP analytics: observe() was called after tools were registered; those tools are not recorded. Call observe() before registering tools.');
|
|
148
|
+
}
|
|
149
|
+
serverCounts.set(analytics, (serverCounts.get(analytics) ?? 0) + 1);
|
|
150
|
+
const resolve = (ctx) => {
|
|
151
|
+
const client = clientName(server, ctx);
|
|
152
|
+
const subject = typeof user === 'function' ? user(ctx) : automaticUser ? verifiedUser(ctx) : undefined;
|
|
153
|
+
const extra = context?.(ctx);
|
|
154
|
+
if (isThenable(subject) || isThenable(extra)) {
|
|
155
|
+
return Promise.all([subject, extra]).then(([s, e]) => merge(client, s, e));
|
|
156
|
+
}
|
|
157
|
+
return merge(client, subject, extra);
|
|
158
|
+
};
|
|
159
|
+
// Tool names are static code names, never client input. A name outside the
|
|
160
|
+
// alias rule is still observed and recorded as __unknown_tool__.
|
|
161
|
+
const allow = (name) => {
|
|
162
|
+
try {
|
|
163
|
+
if (typeof name === 'string')
|
|
164
|
+
analytics.allowTools([name]);
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
reportOnce('MCP analytics: a tool name is not a valid analytics alias (1-64 letters, digits, underscores, dots, or hyphens); its calls are recorded as __unknown_tool__.');
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
// Both SDK versions pass the request context as the callback's last argument:
|
|
171
|
+
// (args, ctx) with an input schema, otherwise (ctx).
|
|
172
|
+
const wrap = (state, callback) => {
|
|
173
|
+
if (wrappedCallbacks.has(callback))
|
|
174
|
+
return callback;
|
|
175
|
+
const wrapped = function (...args) {
|
|
176
|
+
const ctx = args[args.length - 1];
|
|
177
|
+
return analytics.observeTool(state.name, () => callback.apply(this, args), () => resolve(ctx));
|
|
178
|
+
};
|
|
179
|
+
wrappedCallbacks.add(wrapped);
|
|
180
|
+
return wrapped;
|
|
181
|
+
};
|
|
182
|
+
// RegisteredTool.update can rename a tool or replace its callback.
|
|
183
|
+
const track = (handle, state) => {
|
|
184
|
+
if (handle === null || typeof handle !== 'object')
|
|
185
|
+
return;
|
|
186
|
+
const update = handle.update;
|
|
187
|
+
if (typeof update !== 'function')
|
|
188
|
+
return;
|
|
189
|
+
define(handle, 'update', function (updates) {
|
|
190
|
+
if (updates === null || typeof updates !== 'object')
|
|
191
|
+
return update.call(this, updates);
|
|
192
|
+
const next = { ...updates };
|
|
193
|
+
if (typeof next.name === 'string') {
|
|
194
|
+
allow(next.name);
|
|
195
|
+
state.name = next.name;
|
|
196
|
+
}
|
|
197
|
+
if (typeof next.callback === 'function')
|
|
198
|
+
next.callback = wrap(state, next.callback);
|
|
199
|
+
return update.call(this, next);
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
const registerTool = server.registerTool;
|
|
203
|
+
define(server, 'registerTool', (name, config, callback, ...rest) => {
|
|
204
|
+
if (typeof callback !== 'function')
|
|
205
|
+
return registerTool.call(server, name, config, callback, ...rest);
|
|
206
|
+
const state = { name: String(name) };
|
|
207
|
+
allow(name);
|
|
208
|
+
const handle = registerTool.call(server, name, config, wrap(state, callback), ...rest);
|
|
209
|
+
track(handle, state);
|
|
210
|
+
return handle;
|
|
211
|
+
});
|
|
212
|
+
// SDK v1's tool(name, [description], [schema], [annotations], callback).
|
|
213
|
+
const tool = server.tool;
|
|
214
|
+
if (typeof tool === 'function') {
|
|
215
|
+
define(server, 'tool', (name, ...rest) => {
|
|
216
|
+
const last = rest.length - 1;
|
|
217
|
+
if (typeof rest[last] !== 'function')
|
|
218
|
+
return tool.call(server, name, ...rest);
|
|
219
|
+
const state = { name: String(name) };
|
|
220
|
+
allow(name);
|
|
221
|
+
rest[last] = wrap(state, rest[last]);
|
|
222
|
+
const handle = tool.call(server, name, ...rest);
|
|
223
|
+
track(handle, state);
|
|
224
|
+
return handle;
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
// A single long-lived server (stdio) flushes when it closes. Per-request
|
|
228
|
+
// servers share one instance and keep batching on the regular interval.
|
|
229
|
+
const close = server.close;
|
|
230
|
+
if (typeof close === 'function') {
|
|
231
|
+
define(server, 'close', async () => {
|
|
232
|
+
try {
|
|
233
|
+
return await close.call(server);
|
|
234
|
+
}
|
|
235
|
+
finally {
|
|
236
|
+
if (serverCounts.get(analytics) === 1)
|
|
237
|
+
await analytics.flush().catch(() => { });
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Records every tool registered on this server instance from now on: tool,
|
|
244
|
+
* outcome, duration, client, and a hashed user. It patches `registerTool` (and
|
|
245
|
+
* v1's `tool()`) on the instance only, never the class, and returns the same
|
|
246
|
+
* server. Configuration comes from MCP_ANALYTICS_URL by default.
|
|
247
|
+
*
|
|
248
|
+
* It never throws: invalid or missing configuration disables analytics with
|
|
249
|
+
* one stderr line naming the field, unless `strict` is set.
|
|
250
|
+
*
|
|
251
|
+
* ```ts
|
|
252
|
+
* const server = observe(new McpServer({ name: 'notes', version: '1.0.0' }));
|
|
253
|
+
* server.registerTool('add_note', config, handler);
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
export function observe(server, options = {}) {
|
|
257
|
+
let strict = false;
|
|
258
|
+
try {
|
|
259
|
+
if (options === null || typeof options !== 'object')
|
|
260
|
+
throw new TypeError('Invalid analytics configuration: observe options must be an object');
|
|
261
|
+
const { user, context, strict: strictOption, analytics: explicit, ...config } = options;
|
|
262
|
+
if (strictOption !== undefined && typeof strictOption !== 'boolean')
|
|
263
|
+
throw new TypeError('Invalid analytics configuration: strict must be a boolean');
|
|
264
|
+
const env = config.env !== null && typeof config.env === 'object' ? config.env : process.env;
|
|
265
|
+
strict = strictOption ?? enabledFlag(env.MCP_ANALYTICS_STRICT);
|
|
266
|
+
if (server === null || typeof server !== 'object' || typeof server.registerTool !== 'function') {
|
|
267
|
+
throw new TypeError('Invalid analytics configuration: observe requires an MCP server with registerTool');
|
|
268
|
+
}
|
|
269
|
+
if (observedServers.has(server))
|
|
270
|
+
return server;
|
|
271
|
+
if (user !== undefined && user !== false && typeof user !== 'function')
|
|
272
|
+
throw new TypeError('Invalid analytics configuration: user must be a function or false');
|
|
273
|
+
if (context !== undefined && typeof context !== 'function')
|
|
274
|
+
throw new TypeError('Invalid analytics configuration: context must be a function');
|
|
275
|
+
if (explicit !== undefined && (explicit === null || typeof explicit !== 'object' || typeof explicit.observeTool !== 'function')) {
|
|
276
|
+
throw new TypeError('Invalid analytics configuration: analytics must be an analytics instance');
|
|
277
|
+
}
|
|
278
|
+
const analytics = explicit ?? sharedAnalytics(config);
|
|
279
|
+
instrument(server, analytics, user, context);
|
|
280
|
+
observedServers.add(server);
|
|
281
|
+
if (explicit === undefined && (config.debug ?? enabledFlag(env.MCP_ANALYTICS_DEBUG)))
|
|
282
|
+
reportOnce('mcp-analytics: observing tool calls');
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
if (strict)
|
|
286
|
+
throw error;
|
|
287
|
+
reportOnce(`MCP analytics disabled: ${problemOf(error)}`);
|
|
288
|
+
}
|
|
289
|
+
return server;
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=mcp.js.map
|
package/dist/mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE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AAU;YAAE,MAAM,IAAI,SAAS,CAAC,mEAAmE,CAAC,CAAC;QACjK,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,OAAO,KAAK,UAAU;YAAE,MAAM,IAAI,SAAS,CAAC,6DAA6D,CAAC,CAAC;QAC/I,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,QAAQ,CAAC,WAAW,KAAK,UAAU,CAAC,EAAE,CAAC;YAChI,MAAM,IAAI,SAAS,CAAC,0EAA0E,CAAC,CAAC;QAClG,CAAC;QACD,MAAM,SAAS,GAAG,QAAQ,IAAI,eAAe,CAAC,MAAyB,CAAC,CAAC;QACzE,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7C,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC5B,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,WAAW,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;YAAE,UAAU,CAAC,qCAAqC,CAAC,CAAC;IAC1I,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,MAAM;YAAE,MAAM,KAAK,CAAC;QACxB,UAAU,CAAC,2BAA2B,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AnalyticsEvent } from './analytics.js';
|
|
2
|
+
/** Decode only this metadata-only profile; callers validate canonical events too. */
|
|
3
|
+
export declare function decodeOtlpJson(value: unknown): unknown[];
|
|
4
|
+
/** Encode fixed fields only; never serialize a whole context, result, or Error. */
|
|
5
|
+
export declare function encodeOtlpJson(events: readonly AnalyticsEvent[]): object;
|
|
6
|
+
/** Parse the standard ExportLogsServiceRequest protobuf envelope. */
|
|
7
|
+
export declare function decodeOtlpProtobuf(bytes: Uint8Array): unknown[];
|
|
8
|
+
/** Encode standard protobuf wire fields without introducing a protobuf runtime. */
|
|
9
|
+
export declare function encodeOtlpProtobuf(events: readonly AnalyticsEvent[]): Uint8Array;
|
|
10
|
+
//# sourceMappingURL=otlp-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otlp-protocol.d.ts","sourceRoot":"","sources":["../src/otlp-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAmIrD,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,EAAE,CAiBxD;AAED,mFAAmF;AACnF,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAoBxE;AAsID,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,EAAE,CA0B/D;AAgCD,mFAAmF;AACnF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,UAAU,CAiBhF"}
|