mcp-use 0.1.4 → 0.1.5

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
@@ -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/pietrozullo>
200
- <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/>
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>Pietro Zullo</b></sub>
209
+ <sub style="font-size:14px"><b>Luigi Pederzani</b></sub>
203
210
  </a>
204
211
  </td>
205
212
  </tr>
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../src/telemetry/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAk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hD,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
- const telemetryDisabled = process.env.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase() === 'false';
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.MCP_USE_TELEMETRY_SOURCE || 'typescript';
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,CAS1C;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"}
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",
4
+ "version": "0.1.5",
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",