mcp-use 1.11.0-canary.9 → 1.11.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.
Files changed (51) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/{chunk-N3DO4P2L.js → chunk-A4QJRN7Z.js} +2 -2
  3. package/dist/{chunk-UCPSHMNO.js → chunk-B7AGEK7F.js} +1 -1
  4. package/dist/{chunk-HU2DGJ5J.js → chunk-GN5HOAV3.js} +491 -5
  5. package/dist/{chunk-D3CNYAYE.js → chunk-QPIDKGV4.js} +199 -8
  6. package/dist/{chunk-ZFZPZ4GE.js → chunk-V77WS6CS.js} +9 -0
  7. package/dist/{chunk-5QFJZ7H3.js → chunk-VRHAF2WT.js} +10 -4
  8. package/dist/{chunk-F3BZFJCD.js → chunk-Y2HHHJQB.js} +10 -5
  9. package/dist/{chunk-Q5LZL6BH.js → chunk-ZLZOOXMJ.js} +96 -43
  10. package/dist/index.cjs +122 -47
  11. package/dist/index.js +15 -19
  12. package/dist/src/agents/index.cjs +108 -44
  13. package/dist/src/agents/index.d.ts +1 -1
  14. package/dist/src/agents/index.d.ts.map +1 -1
  15. package/dist/src/agents/index.js +7 -11
  16. package/dist/src/agents/mcp_agent.d.ts.map +1 -1
  17. package/dist/src/{client/prompts.d.ts → agents/prompts/index.d.ts} +3 -3
  18. package/dist/src/agents/prompts/index.d.ts.map +1 -0
  19. package/dist/src/browser.cjs +115 -45
  20. package/dist/src/browser.js +10 -13
  21. package/dist/src/client/browser.d.ts.map +1 -1
  22. package/dist/src/client.cjs +108 -43
  23. package/dist/src/client.d.ts +2 -0
  24. package/dist/src/client.d.ts.map +1 -1
  25. package/dist/src/client.js +6 -5
  26. package/dist/src/config.d.ts.map +1 -1
  27. package/dist/src/connectors/http.d.ts +2 -0
  28. package/dist/src/connectors/http.d.ts.map +1 -1
  29. package/dist/src/react/index.cjs +119 -46
  30. package/dist/src/react/index.js +7 -8
  31. package/dist/src/react/useMcp.d.ts.map +1 -1
  32. package/dist/src/server/index.cjs +178 -113
  33. package/dist/src/server/index.js +92 -80
  34. package/dist/src/server/types/widget.d.ts +2 -2
  35. package/dist/src/server/types/widget.d.ts.map +1 -1
  36. package/dist/src/server/widgets/mount-widgets-dev.d.ts.map +1 -1
  37. package/dist/src/server/widgets/ui-resource-registration.d.ts.map +1 -1
  38. package/dist/src/telemetry/telemetry.d.ts +1 -0
  39. package/dist/src/telemetry/telemetry.d.ts.map +1 -1
  40. package/dist/src/version.d.ts +1 -1
  41. package/dist/src/version.d.ts.map +1 -1
  42. package/dist/{tool-execution-helpers-MXVN6YNU.js → tool-execution-helpers-ZUA5D5IO.js} +2 -2
  43. package/package.json +49 -52
  44. package/dist/chunk-ESMOFYJ6.js +0 -2638
  45. package/dist/chunk-M7WATKYM.js +0 -204
  46. package/dist/chunk-OWPXM4QQ.js +0 -12
  47. package/dist/chunk-WW3A2EKQ.js +0 -1055
  48. package/dist/chunk-XEFWIBQF.js +0 -491
  49. package/dist/src/client/prompts.cjs +0 -407
  50. package/dist/src/client/prompts.d.ts.map +0 -1
  51. package/dist/src/client/prompts.js +0 -11
@@ -1,407 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
-
31
- // src/client/prompts.ts
32
- var prompts_exports = {};
33
- __export(prompts_exports, {
34
- PROMPTS: () => PROMPTS
35
- });
36
- module.exports = __toCommonJS(prompts_exports);
37
-
38
- // src/connectors/base.ts
39
- var import_types = require("@mcp-use/modelcontextprotocol-sdk/types.js");
40
-
41
- // src/logging.ts
42
- async function getNodeModules() {
43
- if (typeof process !== "undefined" && process.platform) {
44
- try {
45
- const fs = await import("fs");
46
- const path = await import("path");
47
- return { fs: fs.default, path: path.default };
48
- } catch {
49
- return { fs: null, path: null };
50
- }
51
- }
52
- return { fs: null, path: null };
53
- }
54
- __name(getNodeModules, "getNodeModules");
55
- var winston = null;
56
- function loadWinstonSync() {
57
- if (typeof require !== "undefined") {
58
- try {
59
- winston = require("winston");
60
- } catch {
61
- }
62
- }
63
- }
64
- __name(loadWinstonSync, "loadWinstonSync");
65
- async function getWinston() {
66
- if (!winston) {
67
- winston = await import("winston");
68
- }
69
- return winston;
70
- }
71
- __name(getWinston, "getWinston");
72
- var DEFAULT_LOGGER_NAME = "mcp-use";
73
- function isNodeJSEnvironment() {
74
- try {
75
- if (typeof navigator !== "undefined" && navigator.userAgent?.includes("Cloudflare-Workers")) {
76
- return false;
77
- }
78
- if (typeof globalThis.EdgeRuntime !== "undefined" || typeof globalThis.Deno !== "undefined") {
79
- return false;
80
- }
81
- const hasNodeGlobals = typeof process !== "undefined" && typeof process.platform !== "undefined" && typeof __dirname !== "undefined";
82
- return hasNodeGlobals;
83
- } catch {
84
- return false;
85
- }
86
- }
87
- __name(isNodeJSEnvironment, "isNodeJSEnvironment");
88
- var SimpleConsoleLogger = class {
89
- static {
90
- __name(this, "SimpleConsoleLogger");
91
- }
92
- _level;
93
- name;
94
- constructor(name = DEFAULT_LOGGER_NAME, level = "info") {
95
- this.name = name;
96
- this._level = level;
97
- }
98
- shouldLog(level) {
99
- const levels = [
100
- "error",
101
- "warn",
102
- "info",
103
- "http",
104
- "verbose",
105
- "debug",
106
- "silly"
107
- ];
108
- const currentIndex = levels.indexOf(this._level);
109
- const messageIndex = levels.indexOf(level);
110
- return messageIndex <= currentIndex;
111
- }
112
- formatMessage(level, message) {
113
- const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: false });
114
- return `${timestamp} [${this.name}] ${level}: ${message}`;
115
- }
116
- error(message) {
117
- if (this.shouldLog("error")) {
118
- console.error(this.formatMessage("error", message));
119
- }
120
- }
121
- warn(message) {
122
- if (this.shouldLog("warn")) {
123
- console.warn(this.formatMessage("warn", message));
124
- }
125
- }
126
- info(message) {
127
- if (this.shouldLog("info")) {
128
- console.info(this.formatMessage("info", message));
129
- }
130
- }
131
- debug(message) {
132
- if (this.shouldLog("debug")) {
133
- console.debug(this.formatMessage("debug", message));
134
- }
135
- }
136
- http(message) {
137
- if (this.shouldLog("http")) {
138
- console.log(this.formatMessage("http", message));
139
- }
140
- }
141
- verbose(message) {
142
- if (this.shouldLog("verbose")) {
143
- console.log(this.formatMessage("verbose", message));
144
- }
145
- }
146
- silly(message) {
147
- if (this.shouldLog("silly")) {
148
- console.log(this.formatMessage("silly", message));
149
- }
150
- }
151
- // Make it compatible with Winston interface
152
- get level() {
153
- return this._level;
154
- }
155
- set level(newLevel) {
156
- this._level = newLevel;
157
- }
158
- };
159
- function resolveLevel(env) {
160
- const envValue = typeof process !== "undefined" && process.env ? env : void 0;
161
- switch (envValue?.trim()) {
162
- case "2":
163
- return "debug";
164
- case "1":
165
- return "info";
166
- default:
167
- return "info";
168
- }
169
- }
170
- __name(resolveLevel, "resolveLevel");
171
- var Logger = class {
172
- static {
173
- __name(this, "Logger");
174
- }
175
- static instances = {};
176
- static simpleInstances = {};
177
- static currentFormat = "minimal";
178
- static get(name = DEFAULT_LOGGER_NAME) {
179
- if (!isNodeJSEnvironment()) {
180
- if (!this.simpleInstances[name]) {
181
- const debugEnv = typeof process !== "undefined" && process.env?.DEBUG || void 0;
182
- this.simpleInstances[name] = new SimpleConsoleLogger(
183
- name,
184
- resolveLevel(debugEnv)
185
- );
186
- }
187
- return this.simpleInstances[name];
188
- }
189
- if (!this.instances[name]) {
190
- if (!winston) {
191
- throw new Error("Winston not loaded - call Logger.configure() first");
192
- }
193
- const { createLogger, format } = winston;
194
- const { combine, timestamp, label, colorize, splat } = format;
195
- this.instances[name] = createLogger({
196
- level: resolveLevel(process.env.DEBUG),
197
- format: combine(
198
- colorize(),
199
- splat(),
200
- label({ label: name }),
201
- timestamp({ format: "HH:mm:ss" }),
202
- this.getFormatter()
203
- ),
204
- transports: [new winston.transports.Console()]
205
- });
206
- }
207
- return this.instances[name];
208
- }
209
- static getFormatter() {
210
- if (!winston) {
211
- throw new Error("Winston not loaded");
212
- }
213
- const { format } = winston;
214
- const { printf } = format;
215
- const minimalFormatter = printf(({ level, message, label, timestamp }) => {
216
- return `${timestamp} [${label}] ${level}: ${message}`;
217
- });
218
- const detailedFormatter = printf(({ level, message, label, timestamp }) => {
219
- return `${timestamp} [${label}] ${level.toUpperCase()}: ${message}`;
220
- });
221
- const emojiFormatter = printf(({ level, message, label, timestamp }) => {
222
- return `${timestamp} [${label}] ${level.toUpperCase()}: ${message}`;
223
- });
224
- switch (this.currentFormat) {
225
- case "minimal":
226
- return minimalFormatter;
227
- case "detailed":
228
- return detailedFormatter;
229
- case "emoji":
230
- return emojiFormatter;
231
- default:
232
- return minimalFormatter;
233
- }
234
- }
235
- static async configure(options = {}) {
236
- const { level, console: console2 = true, file, format = "minimal" } = options;
237
- const debugEnv = typeof process !== "undefined" && process.env?.DEBUG || void 0;
238
- const resolvedLevel = level ?? resolveLevel(debugEnv);
239
- this.currentFormat = format;
240
- if (!isNodeJSEnvironment()) {
241
- Object.values(this.simpleInstances).forEach((logger2) => {
242
- logger2.level = resolvedLevel;
243
- });
244
- return;
245
- }
246
- await getWinston();
247
- if (!winston) {
248
- throw new Error("Failed to load winston");
249
- }
250
- const root = this.get();
251
- root.level = resolvedLevel;
252
- const winstonRoot = root;
253
- winstonRoot.clear();
254
- if (console2) {
255
- winstonRoot.add(new winston.transports.Console());
256
- }
257
- if (file) {
258
- const { fs: nodeFs, path: nodePath } = await getNodeModules();
259
- if (nodeFs && nodePath) {
260
- const dir = nodePath.dirname(nodePath.resolve(file));
261
- if (!nodeFs.existsSync(dir)) {
262
- nodeFs.mkdirSync(dir, { recursive: true });
263
- }
264
- winstonRoot.add(new winston.transports.File({ filename: file }));
265
- }
266
- }
267
- const { format: winstonFormat } = winston;
268
- const { combine, timestamp, label, colorize, splat } = winstonFormat;
269
- Object.values(this.instances).forEach((logger2) => {
270
- if (logger2 && "format" in logger2) {
271
- logger2.level = resolvedLevel;
272
- logger2.format = combine(
273
- colorize(),
274
- splat(),
275
- label({ label: DEFAULT_LOGGER_NAME }),
276
- timestamp({ format: "HH:mm:ss" }),
277
- this.getFormatter()
278
- );
279
- }
280
- });
281
- }
282
- static setDebug(enabled) {
283
- let level;
284
- if (enabled === 2 || enabled === true) level = "debug";
285
- else if (enabled === 1) level = "info";
286
- else level = "info";
287
- Object.values(this.simpleInstances).forEach((logger2) => {
288
- logger2.level = level;
289
- });
290
- Object.values(this.instances).forEach((logger2) => {
291
- if (logger2) {
292
- logger2.level = level;
293
- }
294
- });
295
- if (typeof process !== "undefined" && process.env) {
296
- process.env.DEBUG = enabled ? enabled === true ? "2" : String(enabled) : "0";
297
- }
298
- }
299
- static setFormat(format) {
300
- this.currentFormat = format;
301
- this.configure({ format });
302
- }
303
- };
304
- if (isNodeJSEnvironment()) {
305
- loadWinstonSync();
306
- if (winston) {
307
- Logger.configure();
308
- }
309
- }
310
- var logger = Logger.get();
311
-
312
- // src/server/utils/runtime.ts
313
- var isDeno = typeof globalThis.Deno !== "undefined";
314
-
315
- // src/client/connectors/codeMode.ts
316
- var CODE_MODE_AGENT_PROMPT = `
317
- ## MCP Code Mode Tool Usage Guide
318
-
319
- You have access to an MCP Code Mode Client that allows you to execute JavaScript/TypeScript code with access to registered tools. Follow this workflow:
320
-
321
- ### 1. Tool Discovery Phase
322
- **Always start by discovering available tools:**
323
- - Tools are organized by server namespace (e.g., \`server_name.tool_name\`)
324
- - Use the \`search_tools(query, detail_level)\` function to find available tools
325
- - You can access \`__tool_namespaces\` to see all available server namespaces
326
-
327
- \`\`\`javascript
328
- // Find all GitHub-related tools
329
- const tools = await search_tools("github");
330
- for (const tool of tools) {
331
- console.log(\`\${tool.server}.\${tool.name}: \${tool.description}\`);
332
- }
333
-
334
- // Get only tool names for quick overview
335
- const tools = await search_tools("", "names");
336
- \`\`\`
337
-
338
- ### 2. Interface Introspection
339
- **Understand tool contracts before using them:**
340
- - Use \`search_tools\` to get tool descriptions and input schemas
341
- - Look for "Access as: server.tool(args)" patterns in descriptions
342
-
343
- ### 3. Code Execution Guidelines
344
- **When writing code:**
345
- - Use \`await server.tool({ param: value })\` syntax for all tool calls
346
- - Tools are async functions that return promises
347
- - You have access to standard JavaScript globals: \`console\`, \`JSON\`, \`Math\`, \`Date\`, etc.
348
- - All console output (\`console.log\`, \`console.error\`, etc.) is automatically captured and returned
349
- - Build properly structured input objects based on interface definitions
350
- - Handle errors appropriately with try/catch blocks
351
- - Chain tool calls by using results from previous calls
352
-
353
- ### 4. Best Practices
354
- - **Discover first, code second**: Always explore available tools before writing execution code
355
- - **Respect namespaces**: Use full \`server.tool\` names to avoid conflicts
356
- - **Minimize Context**: Process large data in code, return only essential results
357
- - **Error handling**: Wrap tool calls in try/catch for robustness
358
- - **Data flow**: Chain tools by passing outputs as inputs to subsequent tools
359
-
360
- ### 5. Available Runtime Context
361
- - \`search_tools(query, detail_level)\`: Function to discover tools
362
- - \`__tool_namespaces\`: Array of available server namespaces
363
- - All registered tools as \`server.tool\` functions
364
- - Standard JavaScript built-ins for data processing
365
-
366
- ### Example Workflow
367
-
368
- \`\`\`javascript
369
- // 1. Discover available tools
370
- const github_tools = await search_tools("github pull request");
371
- console.log(\`Available GitHub PR tools: \${github_tools.map(t => t.name)}\`);
372
-
373
- // 2. Call tools with proper parameters
374
- const pr = await github.get_pull_request({
375
- owner: "facebook",
376
- repo: "react",
377
- number: 12345
378
- });
379
-
380
- // 3. Process results
381
- let result;
382
- if (pr.state === 'open' && pr.labels.some(l => l.name === 'bug')) {
383
- // 4. Chain with other tools
384
- await slack.post_message({
385
- channel: "#bugs",
386
- text: \`\u{1F41B} Bug PR needs review: \${pr.title}\`
387
- });
388
- result = "Notification sent";
389
- } else {
390
- result = "No action needed";
391
- }
392
-
393
- // 5. Return structured results
394
- return {
395
- pr_number: pr.number,
396
- pr_title: pr.title,
397
- action_taken: result
398
- };
399
- \`\`\`
400
-
401
- Remember: Always discover and understand available tools before attempting to use them in code execution.
402
- `;
403
-
404
- // src/client/prompts.ts
405
- var PROMPTS = {
406
- CODE_MODE: CODE_MODE_AGENT_PROMPT
407
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/client/prompts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,eAAO,MAAM,OAAO;;CAEV,CAAC"}
@@ -1,11 +0,0 @@
1
- import {
2
- PROMPTS
3
- } from "../../chunk-OWPXM4QQ.js";
4
- import "../../chunk-M7WATKYM.js";
5
- import "../../chunk-XEFWIBQF.js";
6
- import "../../chunk-Q5LZL6BH.js";
7
- import "../../chunk-FRUZDWXH.js";
8
- import "../../chunk-3GQAWCBQ.js";
9
- export {
10
- PROMPTS
11
- };