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,204 +0,0 @@
1
- import {
2
- BaseConnector
3
- } from "./chunk-XEFWIBQF.js";
4
- import {
5
- __name
6
- } from "./chunk-3GQAWCBQ.js";
7
-
8
- // src/client/connectors/codeMode.ts
9
- var CODE_MODE_AGENT_PROMPT = `
10
- ## MCP Code Mode Tool Usage Guide
11
-
12
- 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:
13
-
14
- ### 1. Tool Discovery Phase
15
- **Always start by discovering available tools:**
16
- - Tools are organized by server namespace (e.g., \`server_name.tool_name\`)
17
- - Use the \`search_tools(query, detail_level)\` function to find available tools
18
- - You can access \`__tool_namespaces\` to see all available server namespaces
19
-
20
- \`\`\`javascript
21
- // Find all GitHub-related tools
22
- const tools = await search_tools("github");
23
- for (const tool of tools) {
24
- console.log(\`\${tool.server}.\${tool.name}: \${tool.description}\`);
25
- }
26
-
27
- // Get only tool names for quick overview
28
- const tools = await search_tools("", "names");
29
- \`\`\`
30
-
31
- ### 2. Interface Introspection
32
- **Understand tool contracts before using them:**
33
- - Use \`search_tools\` to get tool descriptions and input schemas
34
- - Look for "Access as: server.tool(args)" patterns in descriptions
35
-
36
- ### 3. Code Execution Guidelines
37
- **When writing code:**
38
- - Use \`await server.tool({ param: value })\` syntax for all tool calls
39
- - Tools are async functions that return promises
40
- - You have access to standard JavaScript globals: \`console\`, \`JSON\`, \`Math\`, \`Date\`, etc.
41
- - All console output (\`console.log\`, \`console.error\`, etc.) is automatically captured and returned
42
- - Build properly structured input objects based on interface definitions
43
- - Handle errors appropriately with try/catch blocks
44
- - Chain tool calls by using results from previous calls
45
-
46
- ### 4. Best Practices
47
- - **Discover first, code second**: Always explore available tools before writing execution code
48
- - **Respect namespaces**: Use full \`server.tool\` names to avoid conflicts
49
- - **Minimize Context**: Process large data in code, return only essential results
50
- - **Error handling**: Wrap tool calls in try/catch for robustness
51
- - **Data flow**: Chain tools by passing outputs as inputs to subsequent tools
52
-
53
- ### 5. Available Runtime Context
54
- - \`search_tools(query, detail_level)\`: Function to discover tools
55
- - \`__tool_namespaces\`: Array of available server namespaces
56
- - All registered tools as \`server.tool\` functions
57
- - Standard JavaScript built-ins for data processing
58
-
59
- ### Example Workflow
60
-
61
- \`\`\`javascript
62
- // 1. Discover available tools
63
- const github_tools = await search_tools("github pull request");
64
- console.log(\`Available GitHub PR tools: \${github_tools.map(t => t.name)}\`);
65
-
66
- // 2. Call tools with proper parameters
67
- const pr = await github.get_pull_request({
68
- owner: "facebook",
69
- repo: "react",
70
- number: 12345
71
- });
72
-
73
- // 3. Process results
74
- let result;
75
- if (pr.state === 'open' && pr.labels.some(l => l.name === 'bug')) {
76
- // 4. Chain with other tools
77
- await slack.post_message({
78
- channel: "#bugs",
79
- text: \`\u{1F41B} Bug PR needs review: \${pr.title}\`
80
- });
81
- result = "Notification sent";
82
- } else {
83
- result = "No action needed";
84
- }
85
-
86
- // 5. Return structured results
87
- return {
88
- pr_number: pr.number,
89
- pr_title: pr.title,
90
- action_taken: result
91
- };
92
- \`\`\`
93
-
94
- Remember: Always discover and understand available tools before attempting to use them in code execution.
95
- `;
96
- var CodeModeConnector = class extends BaseConnector {
97
- static {
98
- __name(this, "CodeModeConnector");
99
- }
100
- mcpClient;
101
- _tools;
102
- constructor(client) {
103
- super();
104
- this.mcpClient = client;
105
- this.connected = true;
106
- this._tools = this._createToolsList();
107
- }
108
- async connect() {
109
- this.connected = true;
110
- }
111
- async disconnect() {
112
- this.connected = false;
113
- }
114
- get publicIdentifier() {
115
- return { name: "code_mode", version: "1.0.0" };
116
- }
117
- _createToolsList() {
118
- return [
119
- {
120
- name: "execute_code",
121
- description: "Execute JavaScript/TypeScript code with access to MCP tools. This is the PRIMARY way to interact with MCP servers in code mode. Write code that discovers tools using search_tools(), calls tools as async functions (e.g., await github.get_pull_request(...)), processes data efficiently, and returns results. Use 'await' for async operations and 'return' to return values. Available in code: search_tools(), __tool_namespaces, and server.tool_name() functions.",
122
- inputSchema: {
123
- type: "object",
124
- properties: {
125
- code: {
126
- type: "string",
127
- description: "JavaScript/TypeScript code to execute. Use 'await' for async operations. Use 'return' to return a value. Available: search_tools(), server.tool_name(), __tool_namespaces"
128
- },
129
- timeout: {
130
- type: "number",
131
- description: "Execution timeout in milliseconds",
132
- default: 3e4
133
- }
134
- },
135
- required: ["code"]
136
- }
137
- },
138
- {
139
- name: "search_tools",
140
- description: "Search and discover available MCP tools across all servers. Use this to find out what tools are available before writing code. Returns tool information including names, descriptions, and schemas. Can filter by query and control detail level.",
141
- inputSchema: {
142
- type: "object",
143
- properties: {
144
- query: {
145
- type: "string",
146
- description: "Search query to filter tools by name or description",
147
- default: ""
148
- },
149
- detail_level: {
150
- type: "string",
151
- description: "Detail level: 'names', 'descriptions', or 'full'",
152
- enum: ["names", "descriptions", "full"],
153
- default: "full"
154
- }
155
- }
156
- }
157
- }
158
- ];
159
- }
160
- // Override tools getter to return static list immediately
161
- get tools() {
162
- return this._tools;
163
- }
164
- async initialize() {
165
- this.toolsCache = this._tools;
166
- return { capabilities: {}, version: "1.0.0" };
167
- }
168
- async callTool(name, args) {
169
- if (name === "execute_code") {
170
- const code = args.code;
171
- const timeout = args.timeout || 3e4;
172
- const result = await this.mcpClient.executeCode(code, timeout);
173
- return {
174
- content: [
175
- {
176
- type: "text",
177
- text: JSON.stringify(result)
178
- }
179
- ]
180
- };
181
- } else if (name === "search_tools") {
182
- const query = args.query || "";
183
- const detailLevel = args.detail_level;
184
- const result = await this.mcpClient.searchTools(
185
- query,
186
- detailLevel && detailLevel in ["names", "descriptions", "full"] ? detailLevel : "full"
187
- );
188
- return {
189
- content: [
190
- {
191
- type: "text",
192
- text: JSON.stringify(result)
193
- }
194
- ]
195
- };
196
- }
197
- throw new Error(`Unknown tool: ${name}`);
198
- }
199
- };
200
-
201
- export {
202
- CODE_MODE_AGENT_PROMPT,
203
- CodeModeConnector
204
- };
@@ -1,12 +0,0 @@
1
- import {
2
- CODE_MODE_AGENT_PROMPT
3
- } from "./chunk-M7WATKYM.js";
4
-
5
- // src/client/prompts.ts
6
- var PROMPTS = {
7
- CODE_MODE: CODE_MODE_AGENT_PROMPT
8
- };
9
-
10
- export {
11
- PROMPTS
12
- };