mcp-use 0.1.4 → 0.1.6
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 +10 -3
- package/dist/src/logging.d.ts +19 -2
- package/dist/src/logging.d.ts.map +1 -1
- package/dist/src/logging.js +136 -11
- package/dist/src/telemetry/telemetry.d.ts.map +1 -1
- package/dist/src/telemetry/telemetry.js +49 -3
- package/dist/src/telemetry/utils.d.ts.map +1 -1
- package/dist/src/telemetry/utils.js +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
@@ -188,6 +188,13 @@ const agent = new MCPAgent({
|
|
188
188
|
|
189
189
|
<table>
|
190
190
|
<tr>
|
191
|
+
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
|
192
|
+
<a href=https://github.com/pietrozullo>
|
193
|
+
<img src=https://avatars.githubusercontent.com/u/62951181?v=4 width="100;" style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Pietro Zullo/>
|
194
|
+
<br />
|
195
|
+
<sub style="font-size:14px"><b>Pietro Zullo</b></sub>
|
196
|
+
</a>
|
197
|
+
</td>
|
191
198
|
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
|
192
199
|
<a href=https://github.com/zandko>
|
193
200
|
<img src=https://avatars.githubusercontent.com/u/37948383?v=4 width="100;" style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Zane/>
|
@@ -196,10 +203,10 @@ const agent = new MCPAgent({
|
|
196
203
|
</a>
|
197
204
|
</td>
|
198
205
|
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
|
199
|
-
<a href=https://github.com/
|
200
|
-
<img src=https://avatars.githubusercontent.com/u/
|
206
|
+
<a href=https://github.com/Pederzh>
|
207
|
+
<img src=https://avatars.githubusercontent.com/u/11487621?v=4 width="100;" style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Luigi Pederzani/>
|
201
208
|
<br />
|
202
|
-
<sub style="font-size:14px"><b>
|
209
|
+
<sub style="font-size:14px"><b>Luigi Pederzani</b></sub>
|
203
210
|
</a>
|
204
211
|
</td>
|
205
212
|
</tr>
|
package/dist/src/logging.d.ts
CHANGED
@@ -6,15 +6,32 @@ interface LoggerOptions {
|
|
6
6
|
file?: string;
|
7
7
|
format?: 'minimal' | 'detailed' | 'emoji';
|
8
8
|
}
|
9
|
+
declare class SimpleConsoleLogger {
|
10
|
+
private _level;
|
11
|
+
private name;
|
12
|
+
constructor(name?: string, level?: LogLevel);
|
13
|
+
private shouldLog;
|
14
|
+
private formatMessage;
|
15
|
+
error(message: string): void;
|
16
|
+
warn(message: string): void;
|
17
|
+
info(message: string): void;
|
18
|
+
debug(message: string): void;
|
19
|
+
http(message: string): void;
|
20
|
+
verbose(message: string): void;
|
21
|
+
silly(message: string): void;
|
22
|
+
get level(): LogLevel;
|
23
|
+
set level(newLevel: LogLevel);
|
24
|
+
}
|
9
25
|
export declare class Logger {
|
10
26
|
private static instances;
|
27
|
+
private static simpleInstances;
|
11
28
|
private static currentFormat;
|
12
|
-
static get(name?: string): WinstonLogger;
|
29
|
+
static get(name?: string): WinstonLogger | SimpleConsoleLogger;
|
13
30
|
private static getFormatter;
|
14
31
|
static configure(options?: LoggerOptions): void;
|
15
32
|
static setDebug(enabled: boolean | 0 | 1 | 2): void;
|
16
33
|
static setFormat(format: 'minimal' | 'detailed' | 'emoji'): void;
|
17
34
|
}
|
18
|
-
export declare const logger: WinstonLogger;
|
35
|
+
export declare const logger: SimpleConsoleLogger | WinstonLogger;
|
19
36
|
export {};
|
20
37
|
//# sourceMappingURL=logging.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/logging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,SAAS,CAAA;AAOtD,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAA;AAEzF,UAAU,aAAa;IACrB,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,OAAO,CAAA;CAC1C;
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/logging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,SAAS,CAAA;AAOtD,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAA;AAEzF,UAAU,aAAa;IACrB,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,OAAO,CAAA;CAC1C;AAsCD,cAAM,mBAAmB;IACvB,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,IAAI,CAAQ;gBAER,IAAI,GAAE,MAA4B,EAAE,KAAK,GAAE,QAAiB;IAKxE,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,aAAa;IAKrB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM5B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM3B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM3B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM5B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM3B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM9B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAO5B,IAAI,KAAK,IAAI,QAAQ,CAEpB;IAED,IAAI,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAE3B;CACF;AA4BD,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAC,SAAS,CAA0D;IAClF,OAAO,CAAC,MAAM,CAAC,eAAe,CAA0C;IACxE,OAAO,CAAC,MAAM,CAAC,aAAa,CAA8C;WAE5D,GAAG,CAAC,IAAI,GAAE,MAA4B,GAAG,aAAa,GAAG,mBAAmB;IA4B1F,OAAO,CAAC,MAAM,CAAC,YAAY;WAab,SAAS,CAAC,OAAO,GAAE,aAAkB,GAAG,IAAI;WAiD5C,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI;WAyB5C,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,IAAI;CAIxE;AAWD,eAAO,MAAM,MAAM,qCAAe,CAAA"}
|
package/dist/src/logging.js
CHANGED
@@ -3,8 +3,95 @@ import path from 'node:path';
|
|
3
3
|
import { createLogger, format, transports } from 'winston';
|
4
4
|
const { combine, timestamp, label, printf, colorize, splat } = format;
|
5
5
|
const DEFAULT_LOGGER_NAME = 'mcp-use';
|
6
|
+
// Environment detection function (similar to telemetry)
|
7
|
+
function isNodeJSEnvironment() {
|
8
|
+
try {
|
9
|
+
// Check for Cloudflare Workers specifically
|
10
|
+
if (typeof navigator !== 'undefined' && navigator.userAgent?.includes('Cloudflare-Workers')) {
|
11
|
+
return false;
|
12
|
+
}
|
13
|
+
// Check for other edge runtime indicators
|
14
|
+
if (typeof globalThis.EdgeRuntime !== 'undefined' || typeof globalThis.Deno !== 'undefined') {
|
15
|
+
return false;
|
16
|
+
}
|
17
|
+
// Check for Node.js specific globals that are not available in edge environments
|
18
|
+
const hasNodeGlobals = (typeof process !== 'undefined'
|
19
|
+
&& typeof process.platform !== 'undefined'
|
20
|
+
&& typeof __dirname !== 'undefined');
|
21
|
+
// Check for Node.js modules
|
22
|
+
const hasNodeModules = (typeof fs !== 'undefined'
|
23
|
+
&& typeof createLogger === 'function');
|
24
|
+
return hasNodeGlobals && hasNodeModules;
|
25
|
+
}
|
26
|
+
catch {
|
27
|
+
return false;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
// Simple console logger for non-Node.js environments
|
31
|
+
class SimpleConsoleLogger {
|
32
|
+
_level;
|
33
|
+
name;
|
34
|
+
constructor(name = DEFAULT_LOGGER_NAME, level = 'info') {
|
35
|
+
this.name = name;
|
36
|
+
this._level = level;
|
37
|
+
}
|
38
|
+
shouldLog(level) {
|
39
|
+
const levels = ['error', 'warn', 'info', 'http', 'verbose', 'debug', 'silly'];
|
40
|
+
const currentIndex = levels.indexOf(this._level);
|
41
|
+
const messageIndex = levels.indexOf(level);
|
42
|
+
return messageIndex <= currentIndex;
|
43
|
+
}
|
44
|
+
formatMessage(level, message) {
|
45
|
+
const timestamp = new Date().toLocaleTimeString('en-US', { hour12: false });
|
46
|
+
return `${timestamp} [${this.name}] ${level}: ${message}`;
|
47
|
+
}
|
48
|
+
error(message) {
|
49
|
+
if (this.shouldLog('error')) {
|
50
|
+
console.error(this.formatMessage('error', message));
|
51
|
+
}
|
52
|
+
}
|
53
|
+
warn(message) {
|
54
|
+
if (this.shouldLog('warn')) {
|
55
|
+
console.warn(this.formatMessage('warn', message));
|
56
|
+
}
|
57
|
+
}
|
58
|
+
info(message) {
|
59
|
+
if (this.shouldLog('info')) {
|
60
|
+
console.info(this.formatMessage('info', message)); // eslint-disable-line no-console
|
61
|
+
}
|
62
|
+
}
|
63
|
+
debug(message) {
|
64
|
+
if (this.shouldLog('debug')) {
|
65
|
+
console.debug(this.formatMessage('debug', message)); // eslint-disable-line no-console
|
66
|
+
}
|
67
|
+
}
|
68
|
+
http(message) {
|
69
|
+
if (this.shouldLog('http')) {
|
70
|
+
console.log(this.formatMessage('http', message)); // eslint-disable-line no-console
|
71
|
+
}
|
72
|
+
}
|
73
|
+
verbose(message) {
|
74
|
+
if (this.shouldLog('verbose')) {
|
75
|
+
console.log(this.formatMessage('verbose', message)); // eslint-disable-line no-console
|
76
|
+
}
|
77
|
+
}
|
78
|
+
silly(message) {
|
79
|
+
if (this.shouldLog('silly')) {
|
80
|
+
console.log(this.formatMessage('silly', message)); // eslint-disable-line no-console
|
81
|
+
}
|
82
|
+
}
|
83
|
+
// Make it compatible with Winston interface
|
84
|
+
get level() {
|
85
|
+
return this._level;
|
86
|
+
}
|
87
|
+
set level(newLevel) {
|
88
|
+
this._level = newLevel;
|
89
|
+
}
|
90
|
+
}
|
6
91
|
function resolveLevel(env) {
|
7
|
-
|
92
|
+
// Safely access environment variables
|
93
|
+
const envValue = (typeof process !== 'undefined' && process.env) ? env : undefined;
|
94
|
+
switch (envValue?.trim()) {
|
8
95
|
case '2':
|
9
96
|
return 'debug';
|
10
97
|
case '1':
|
@@ -24,8 +111,18 @@ const emojiFormatter = printf(({ level, message, label, timestamp }) => {
|
|
24
111
|
});
|
25
112
|
export class Logger {
|
26
113
|
static instances = {};
|
114
|
+
static simpleInstances = {};
|
27
115
|
static currentFormat = 'minimal';
|
28
116
|
static get(name = DEFAULT_LOGGER_NAME) {
|
117
|
+
// Use simple console logger in non-Node.js environments
|
118
|
+
if (!isNodeJSEnvironment()) {
|
119
|
+
if (!this.simpleInstances[name]) {
|
120
|
+
const debugEnv = (typeof process !== 'undefined' && process.env?.DEBUG) || undefined;
|
121
|
+
this.simpleInstances[name] = new SimpleConsoleLogger(name, resolveLevel(debugEnv));
|
122
|
+
}
|
123
|
+
return this.simpleInstances[name];
|
124
|
+
}
|
125
|
+
// Use Winston logger in Node.js environments
|
29
126
|
if (!this.instances[name]) {
|
30
127
|
this.instances[name] = createLogger({
|
31
128
|
level: resolveLevel(process.env.DEBUG),
|
@@ -49,25 +146,37 @@ export class Logger {
|
|
49
146
|
}
|
50
147
|
static configure(options = {}) {
|
51
148
|
const { level, console = true, file, format = 'minimal' } = options;
|
52
|
-
const
|
149
|
+
const debugEnv = (typeof process !== 'undefined' && process.env?.DEBUG) || undefined;
|
150
|
+
const resolvedLevel = level ?? resolveLevel(debugEnv);
|
53
151
|
this.currentFormat = format;
|
54
152
|
const root = this.get();
|
55
153
|
root.level = resolvedLevel;
|
56
|
-
|
154
|
+
// For non-Node.js environments, just update the level
|
155
|
+
if (!isNodeJSEnvironment()) {
|
156
|
+
Object.values(this.simpleInstances).forEach((logger) => {
|
157
|
+
logger.level = resolvedLevel;
|
158
|
+
});
|
159
|
+
return;
|
160
|
+
}
|
161
|
+
// Winston-specific configuration for Node.js environments
|
162
|
+
const winstonRoot = root;
|
163
|
+
winstonRoot.clear();
|
57
164
|
if (console) {
|
58
|
-
|
165
|
+
winstonRoot.add(new transports.Console());
|
59
166
|
}
|
60
167
|
if (file) {
|
61
168
|
const dir = path.dirname(path.resolve(file));
|
62
169
|
if (!fs.existsSync(dir)) {
|
63
170
|
fs.mkdirSync(dir, { recursive: true });
|
64
171
|
}
|
65
|
-
|
172
|
+
winstonRoot.add(new transports.File({ filename: file }));
|
66
173
|
}
|
67
|
-
// Update all existing loggers with new format
|
174
|
+
// Update all existing Winston loggers with new format
|
68
175
|
Object.values(this.instances).forEach((logger) => {
|
69
|
-
logger
|
70
|
-
|
176
|
+
if (logger && 'format' in logger) {
|
177
|
+
logger.level = resolvedLevel;
|
178
|
+
logger.format = combine(colorize(), splat(), label({ label: DEFAULT_LOGGER_NAME }), timestamp({ format: 'HH:mm:ss' }), this.getFormatter());
|
179
|
+
}
|
71
180
|
});
|
72
181
|
}
|
73
182
|
static setDebug(enabled) {
|
@@ -78,15 +187,31 @@ export class Logger {
|
|
78
187
|
level = 'info';
|
79
188
|
else
|
80
189
|
level = 'info';
|
81
|
-
|
190
|
+
// Update both simple and Winston loggers
|
191
|
+
Object.values(this.simpleInstances).forEach((logger) => {
|
82
192
|
logger.level = level;
|
83
193
|
});
|
84
|
-
|
194
|
+
Object.values(this.instances).forEach((logger) => {
|
195
|
+
if (logger) {
|
196
|
+
logger.level = level;
|
197
|
+
}
|
198
|
+
});
|
199
|
+
// Safely set environment variable
|
200
|
+
if (typeof process !== 'undefined' && process.env) {
|
201
|
+
process.env.DEBUG = enabled ? (enabled === true ? '2' : String(enabled)) : '0';
|
202
|
+
}
|
85
203
|
}
|
86
204
|
static setFormat(format) {
|
87
205
|
this.currentFormat = format;
|
88
206
|
this.configure({ format });
|
89
207
|
}
|
90
208
|
}
|
91
|
-
|
209
|
+
// Only configure Winston features if in Node.js environment
|
210
|
+
if (isNodeJSEnvironment()) {
|
211
|
+
Logger.configure();
|
212
|
+
}
|
213
|
+
else {
|
214
|
+
// For non-Node.js environments, just initialize with defaults
|
215
|
+
Logger.configure({ console: true });
|
216
|
+
}
|
92
217
|
export const logger = Logger.get();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../src/telemetry/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../src/telemetry/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AAiHjF,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAyB;IAEhD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA8D;IAC3F,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAA2D;IACjG,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAoD;IACpF,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6B;IAClD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA8C;IAChF,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAoB;IAEpD,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,YAAY,CAAgC;IACpD,OAAO,CAAC,OAAO,CAAuB;IAEtC,OAAO;IAiDP,MAAM,CAAC,WAAW,IAAI,SAAS;IAO/B;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK/B;;OAEG;IACH,SAAS,IAAI,MAAM;IAInB,IAAI,MAAM,IAAI,MAAM,CAsCnB;IAEK,OAAO,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IA4CjD,oBAAoB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IA0DrE,mBAAmB,CAAC,IAAI,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1E,KAAK,IAAI,IAAI;IAkBb,QAAQ,IAAI,IAAI;CAiBjB"}
|
@@ -6,6 +6,31 @@ import { v4 as uuidv4 } from 'uuid';
|
|
6
6
|
import { logger } from '../logging.js';
|
7
7
|
import { MCPAgentExecutionEvent } from './events.js';
|
8
8
|
import { getPackageVersion } from './utils.js';
|
9
|
+
// Environment detection function
|
10
|
+
function isNodeJSEnvironment() {
|
11
|
+
try {
|
12
|
+
// Check for Cloudflare Workers specifically
|
13
|
+
if (typeof navigator !== 'undefined' && navigator.userAgent?.includes('Cloudflare-Workers')) {
|
14
|
+
return false;
|
15
|
+
}
|
16
|
+
// Check for other edge runtime indicators
|
17
|
+
if (typeof globalThis.EdgeRuntime !== 'undefined' || typeof globalThis.Deno !== 'undefined') {
|
18
|
+
return false;
|
19
|
+
}
|
20
|
+
// Check for Node.js specific globals that are not available in edge environments
|
21
|
+
const hasNodeGlobals = (typeof process !== 'undefined'
|
22
|
+
&& typeof process.platform !== 'undefined'
|
23
|
+
&& typeof __dirname !== 'undefined');
|
24
|
+
// Check for Node.js modules
|
25
|
+
const hasNodeModules = (typeof fs !== 'undefined'
|
26
|
+
&& typeof os !== 'undefined'
|
27
|
+
&& typeof fs.existsSync === 'function');
|
28
|
+
return hasNodeGlobals && hasNodeModules;
|
29
|
+
}
|
30
|
+
catch {
|
31
|
+
return false;
|
32
|
+
}
|
33
|
+
}
|
9
34
|
// Simple Scarf event logger implementation
|
10
35
|
class ScarfEventLogger {
|
11
36
|
endpoint;
|
@@ -38,6 +63,10 @@ class ScarfEventLogger {
|
|
38
63
|
}
|
39
64
|
}
|
40
65
|
function getCacheHome() {
|
66
|
+
// Return a safe fallback for non-Node.js environments
|
67
|
+
if (!isNodeJSEnvironment()) {
|
68
|
+
return '/tmp/mcp_use_cache';
|
69
|
+
}
|
41
70
|
// XDG_CACHE_HOME for Linux and manually set envs
|
42
71
|
const envVar = process.env.XDG_CACHE_HOME;
|
43
72
|
if (envVar && path.isAbsolute(envVar)) {
|
@@ -74,13 +103,21 @@ export class Telemetry {
|
|
74
103
|
_scarfClient = null;
|
75
104
|
_source = 'typescript';
|
76
105
|
constructor() {
|
77
|
-
|
106
|
+
// Check if we're in a Node.js environment first
|
107
|
+
const isNodeJS = isNodeJSEnvironment();
|
108
|
+
// Safely access environment variables
|
109
|
+
const telemetryDisabled = (typeof process !== 'undefined' && process.env?.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase() === 'false') || false;
|
78
110
|
// Check for source from environment variable, default to 'typescript'
|
79
|
-
this._source = process.env
|
111
|
+
this._source = (typeof process !== 'undefined' && process.env?.MCP_USE_TELEMETRY_SOURCE) || 'typescript';
|
80
112
|
if (telemetryDisabled) {
|
81
113
|
this._posthogClient = null;
|
82
114
|
this._scarfClient = null;
|
83
|
-
logger.debug('Telemetry disabled');
|
115
|
+
logger.debug('Telemetry disabled via environment variable');
|
116
|
+
}
|
117
|
+
else if (!isNodeJS) {
|
118
|
+
this._posthogClient = null;
|
119
|
+
this._scarfClient = null;
|
120
|
+
logger.debug('Telemetry disabled - non-Node.js environment detected (e.g., Cloudflare Workers)');
|
84
121
|
}
|
85
122
|
else {
|
86
123
|
logger.info('Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable.');
|
@@ -130,6 +167,11 @@ export class Telemetry {
|
|
130
167
|
if (this._currUserId) {
|
131
168
|
return this._currUserId;
|
132
169
|
}
|
170
|
+
// If we're not in a Node.js environment, just return a static user ID
|
171
|
+
if (!isNodeJSEnvironment()) {
|
172
|
+
this._currUserId = this.UNKNOWN_USER_ID;
|
173
|
+
return this._currUserId;
|
174
|
+
}
|
133
175
|
try {
|
134
176
|
const isFirstTime = !fs.existsSync(this.USER_ID_PATH);
|
135
177
|
if (isFirstTime) {
|
@@ -198,6 +240,10 @@ export class Telemetry {
|
|
198
240
|
if (!this._scarfClient) {
|
199
241
|
return;
|
200
242
|
}
|
243
|
+
// Skip tracking in non-Node.js environments
|
244
|
+
if (!isNodeJSEnvironment()) {
|
245
|
+
return;
|
246
|
+
}
|
201
247
|
try {
|
202
248
|
const currentVersion = getPackageVersion();
|
203
249
|
let shouldTrack = false;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/telemetry/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAI7E,wBAAgB,iBAAiB,IAAI,MAAM,
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/telemetry/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAI7E,wBAAgB,iBAAiB,IAAI,MAAM,CAc1C;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAG/D;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAgB3D;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAEzE"}
|
@@ -2,6 +2,10 @@ import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
3
3
|
export function getPackageVersion() {
|
4
4
|
try {
|
5
|
+
// Check if we're in a Node.js environment with file system access
|
6
|
+
if (typeof __dirname === 'undefined' || typeof fs === 'undefined') {
|
7
|
+
return 'unknown';
|
8
|
+
}
|
5
9
|
const packagePath = path.join(__dirname, '../../package.json');
|
6
10
|
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8'));
|
7
11
|
return packageJson.version || 'unknown';
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "mcp-use",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.1.
|
4
|
+
"version": "0.1.6",
|
5
5
|
"packageManager": "pnpm@10.6.1",
|
6
6
|
"description": "A utility library for integrating Model Context Protocol (MCP) with LangChain, Zod, and related tools. Provides helpers for schema conversion, event streaming, and SDK usage.",
|
7
7
|
"author": "Zane",
|