mcp-use 1.11.0-canary.12 → 1.11.0-canary.14
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/dist/.tsbuildinfo +1 -1
- package/dist/{chunk-3O4V246Q.js → chunk-2IMIUODV.js} +482 -5
- package/dist/{chunk-4NBH6YUZ.js → chunk-7TS5EJ4T.js} +1 -1
- package/dist/{chunk-UUHY7DWI.js → chunk-AEHNVFZG.js} +1 -1
- package/dist/{chunk-G5MS2TH6.js → chunk-JYFYHDYK.js} +4 -4
- package/dist/{chunk-3IK76ZAN.js → chunk-MIKDMUFS.js} +2 -2
- package/dist/{chunk-6M5L4OSE.js → chunk-PO6UGK4I.js} +2 -2
- package/dist/{chunk-ZFZPZ4GE.js → chunk-SBMQ4QZJ.js} +9 -0
- package/dist/{chunk-NI65CTDQ.js → chunk-U7JXQZVH.js} +197 -8
- package/dist/index.cjs +2 -2
- package/dist/index.js +26 -30
- package/dist/src/agents/index.cjs +2 -2
- package/dist/src/agents/index.d.ts +1 -1
- package/dist/src/agents/index.d.ts.map +1 -1
- package/dist/src/agents/index.js +7 -11
- package/dist/src/{client/prompts.d.ts → agents/prompts/index.d.ts} +3 -3
- package/dist/src/agents/prompts/index.d.ts.map +1 -0
- package/dist/src/browser.cjs +1 -1
- package/dist/src/browser.js +13 -16
- package/dist/src/client.cjs +1 -1
- package/dist/src/client.js +3 -5
- package/dist/src/react/index.cjs +1 -1
- package/dist/src/react/index.js +7 -8
- package/dist/src/server/index.cjs +1 -1
- package/dist/src/server/index.js +10 -10
- package/dist/src/version.d.ts +1 -1
- package/dist/{tool-execution-helpers-5CRPAL52.js → tool-execution-helpers-RRECKMIN.js} +2 -2
- package/package.json +31 -31
- package/dist/chunk-GECOPE3S.js +0 -491
- package/dist/chunk-QGEH5MZS.js +0 -204
- package/dist/chunk-SF2V4IJ7.js +0 -12
- package/dist/src/client/prompts.cjs +0 -407
- package/dist/src/client/prompts.d.ts.map +0 -1
- package/dist/src/client/prompts.js +0 -11
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BaseConnector,
|
|
2
3
|
BaseMCPClient,
|
|
3
4
|
ConnectionManager,
|
|
4
5
|
HttpConnector,
|
|
5
6
|
MCPSession
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
CodeModeConnector
|
|
9
|
-
} from "./chunk-QGEH5MZS.js";
|
|
10
|
-
import {
|
|
11
|
-
BaseConnector
|
|
12
|
-
} from "./chunk-GECOPE3S.js";
|
|
7
|
+
} from "./chunk-2IMIUODV.js";
|
|
13
8
|
import {
|
|
14
9
|
Tel,
|
|
15
10
|
getPackageVersion
|
|
16
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-7TS5EJ4T.js";
|
|
17
12
|
import {
|
|
18
13
|
logger
|
|
19
14
|
} from "./chunk-FRUZDWXH.js";
|
|
@@ -659,6 +654,199 @@ var VMCodeExecutor = class extends BaseCodeExecutor {
|
|
|
659
654
|
}
|
|
660
655
|
};
|
|
661
656
|
|
|
657
|
+
// src/client/connectors/codeMode.ts
|
|
658
|
+
var CODE_MODE_AGENT_PROMPT = `
|
|
659
|
+
## MCP Code Mode Tool Usage Guide
|
|
660
|
+
|
|
661
|
+
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:
|
|
662
|
+
|
|
663
|
+
### 1. Tool Discovery Phase
|
|
664
|
+
**Always start by discovering available tools:**
|
|
665
|
+
- Tools are organized by server namespace (e.g., \`server_name.tool_name\`)
|
|
666
|
+
- Use the \`search_tools(query, detail_level)\` function to find available tools
|
|
667
|
+
- You can access \`__tool_namespaces\` to see all available server namespaces
|
|
668
|
+
|
|
669
|
+
\`\`\`javascript
|
|
670
|
+
// Find all GitHub-related tools
|
|
671
|
+
const tools = await search_tools("github");
|
|
672
|
+
for (const tool of tools) {
|
|
673
|
+
console.log(\`\${tool.server}.\${tool.name}: \${tool.description}\`);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// Get only tool names for quick overview
|
|
677
|
+
const tools = await search_tools("", "names");
|
|
678
|
+
\`\`\`
|
|
679
|
+
|
|
680
|
+
### 2. Interface Introspection
|
|
681
|
+
**Understand tool contracts before using them:**
|
|
682
|
+
- Use \`search_tools\` to get tool descriptions and input schemas
|
|
683
|
+
- Look for "Access as: server.tool(args)" patterns in descriptions
|
|
684
|
+
|
|
685
|
+
### 3. Code Execution Guidelines
|
|
686
|
+
**When writing code:**
|
|
687
|
+
- Use \`await server.tool({ param: value })\` syntax for all tool calls
|
|
688
|
+
- Tools are async functions that return promises
|
|
689
|
+
- You have access to standard JavaScript globals: \`console\`, \`JSON\`, \`Math\`, \`Date\`, etc.
|
|
690
|
+
- All console output (\`console.log\`, \`console.error\`, etc.) is automatically captured and returned
|
|
691
|
+
- Build properly structured input objects based on interface definitions
|
|
692
|
+
- Handle errors appropriately with try/catch blocks
|
|
693
|
+
- Chain tool calls by using results from previous calls
|
|
694
|
+
|
|
695
|
+
### 4. Best Practices
|
|
696
|
+
- **Discover first, code second**: Always explore available tools before writing execution code
|
|
697
|
+
- **Respect namespaces**: Use full \`server.tool\` names to avoid conflicts
|
|
698
|
+
- **Minimize Context**: Process large data in code, return only essential results
|
|
699
|
+
- **Error handling**: Wrap tool calls in try/catch for robustness
|
|
700
|
+
- **Data flow**: Chain tools by passing outputs as inputs to subsequent tools
|
|
701
|
+
|
|
702
|
+
### 5. Available Runtime Context
|
|
703
|
+
- \`search_tools(query, detail_level)\`: Function to discover tools
|
|
704
|
+
- \`__tool_namespaces\`: Array of available server namespaces
|
|
705
|
+
- All registered tools as \`server.tool\` functions
|
|
706
|
+
- Standard JavaScript built-ins for data processing
|
|
707
|
+
|
|
708
|
+
### Example Workflow
|
|
709
|
+
|
|
710
|
+
\`\`\`javascript
|
|
711
|
+
// 1. Discover available tools
|
|
712
|
+
const github_tools = await search_tools("github pull request");
|
|
713
|
+
console.log(\`Available GitHub PR tools: \${github_tools.map(t => t.name)}\`);
|
|
714
|
+
|
|
715
|
+
// 2. Call tools with proper parameters
|
|
716
|
+
const pr = await github.get_pull_request({
|
|
717
|
+
owner: "facebook",
|
|
718
|
+
repo: "react",
|
|
719
|
+
number: 12345
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
// 3. Process results
|
|
723
|
+
let result;
|
|
724
|
+
if (pr.state === 'open' && pr.labels.some(l => l.name === 'bug')) {
|
|
725
|
+
// 4. Chain with other tools
|
|
726
|
+
await slack.post_message({
|
|
727
|
+
channel: "#bugs",
|
|
728
|
+
text: \`\u{1F41B} Bug PR needs review: \${pr.title}\`
|
|
729
|
+
});
|
|
730
|
+
result = "Notification sent";
|
|
731
|
+
} else {
|
|
732
|
+
result = "No action needed";
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
// 5. Return structured results
|
|
736
|
+
return {
|
|
737
|
+
pr_number: pr.number,
|
|
738
|
+
pr_title: pr.title,
|
|
739
|
+
action_taken: result
|
|
740
|
+
};
|
|
741
|
+
\`\`\`
|
|
742
|
+
|
|
743
|
+
Remember: Always discover and understand available tools before attempting to use them in code execution.
|
|
744
|
+
`;
|
|
745
|
+
var CodeModeConnector = class extends BaseConnector {
|
|
746
|
+
static {
|
|
747
|
+
__name(this, "CodeModeConnector");
|
|
748
|
+
}
|
|
749
|
+
mcpClient;
|
|
750
|
+
_tools;
|
|
751
|
+
constructor(client) {
|
|
752
|
+
super();
|
|
753
|
+
this.mcpClient = client;
|
|
754
|
+
this.connected = true;
|
|
755
|
+
this._tools = this._createToolsList();
|
|
756
|
+
}
|
|
757
|
+
async connect() {
|
|
758
|
+
this.connected = true;
|
|
759
|
+
}
|
|
760
|
+
async disconnect() {
|
|
761
|
+
this.connected = false;
|
|
762
|
+
}
|
|
763
|
+
get publicIdentifier() {
|
|
764
|
+
return { name: "code_mode", version: "1.0.0" };
|
|
765
|
+
}
|
|
766
|
+
_createToolsList() {
|
|
767
|
+
return [
|
|
768
|
+
{
|
|
769
|
+
name: "execute_code",
|
|
770
|
+
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.",
|
|
771
|
+
inputSchema: {
|
|
772
|
+
type: "object",
|
|
773
|
+
properties: {
|
|
774
|
+
code: {
|
|
775
|
+
type: "string",
|
|
776
|
+
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"
|
|
777
|
+
},
|
|
778
|
+
timeout: {
|
|
779
|
+
type: "number",
|
|
780
|
+
description: "Execution timeout in milliseconds",
|
|
781
|
+
default: 3e4
|
|
782
|
+
}
|
|
783
|
+
},
|
|
784
|
+
required: ["code"]
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
name: "search_tools",
|
|
789
|
+
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.",
|
|
790
|
+
inputSchema: {
|
|
791
|
+
type: "object",
|
|
792
|
+
properties: {
|
|
793
|
+
query: {
|
|
794
|
+
type: "string",
|
|
795
|
+
description: "Search query to filter tools by name or description",
|
|
796
|
+
default: ""
|
|
797
|
+
},
|
|
798
|
+
detail_level: {
|
|
799
|
+
type: "string",
|
|
800
|
+
description: "Detail level: 'names', 'descriptions', or 'full'",
|
|
801
|
+
enum: ["names", "descriptions", "full"],
|
|
802
|
+
default: "full"
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
];
|
|
808
|
+
}
|
|
809
|
+
// Override tools getter to return static list immediately
|
|
810
|
+
get tools() {
|
|
811
|
+
return this._tools;
|
|
812
|
+
}
|
|
813
|
+
async initialize() {
|
|
814
|
+
this.toolsCache = this._tools;
|
|
815
|
+
return { capabilities: {}, version: "1.0.0" };
|
|
816
|
+
}
|
|
817
|
+
async callTool(name, args) {
|
|
818
|
+
if (name === "execute_code") {
|
|
819
|
+
const code = args.code;
|
|
820
|
+
const timeout = args.timeout || 3e4;
|
|
821
|
+
const result = await this.mcpClient.executeCode(code, timeout);
|
|
822
|
+
return {
|
|
823
|
+
content: [
|
|
824
|
+
{
|
|
825
|
+
type: "text",
|
|
826
|
+
text: JSON.stringify(result)
|
|
827
|
+
}
|
|
828
|
+
]
|
|
829
|
+
};
|
|
830
|
+
} else if (name === "search_tools") {
|
|
831
|
+
const query = args.query || "";
|
|
832
|
+
const detailLevel = args.detail_level;
|
|
833
|
+
const result = await this.mcpClient.searchTools(
|
|
834
|
+
query,
|
|
835
|
+
detailLevel && detailLevel in ["names", "descriptions", "full"] ? detailLevel : "full"
|
|
836
|
+
);
|
|
837
|
+
return {
|
|
838
|
+
content: [
|
|
839
|
+
{
|
|
840
|
+
type: "text",
|
|
841
|
+
text: JSON.stringify(result)
|
|
842
|
+
}
|
|
843
|
+
]
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
847
|
+
}
|
|
848
|
+
};
|
|
849
|
+
|
|
662
850
|
// src/config.ts
|
|
663
851
|
import { readFileSync } from "fs";
|
|
664
852
|
|
|
@@ -1049,6 +1237,7 @@ export {
|
|
|
1049
1237
|
E2BCodeExecutor,
|
|
1050
1238
|
isVMAvailable,
|
|
1051
1239
|
VMCodeExecutor,
|
|
1240
|
+
CODE_MODE_AGENT_PROMPT,
|
|
1052
1241
|
StdioConnector,
|
|
1053
1242
|
loadConfigFile,
|
|
1054
1243
|
MCPClient
|
package/dist/index.cjs
CHANGED
|
@@ -2790,7 +2790,7 @@ __name(generateUUID, "generateUUID");
|
|
|
2790
2790
|
init_logging();
|
|
2791
2791
|
|
|
2792
2792
|
// src/version.ts
|
|
2793
|
-
var VERSION = "1.11.0-canary.
|
|
2793
|
+
var VERSION = "1.11.0-canary.14";
|
|
2794
2794
|
function getPackageVersion() {
|
|
2795
2795
|
return VERSION;
|
|
2796
2796
|
}
|
|
@@ -11183,7 +11183,7 @@ function McpUseProvider({
|
|
|
11183
11183
|
}
|
|
11184
11184
|
__name(McpUseProvider, "McpUseProvider");
|
|
11185
11185
|
|
|
11186
|
-
// src/
|
|
11186
|
+
// src/agents/prompts/index.ts
|
|
11187
11187
|
var PROMPTS = {
|
|
11188
11188
|
CODE_MODE: CODE_MODE_AGENT_PROMPT
|
|
11189
11189
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ErrorBoundary,
|
|
3
|
-
Image,
|
|
4
|
-
McpUseProvider,
|
|
5
|
-
ThemeProvider,
|
|
6
|
-
WidgetControls,
|
|
7
|
-
useMcp,
|
|
8
|
-
useWidget,
|
|
9
|
-
useWidgetProps,
|
|
10
|
-
useWidgetState,
|
|
11
|
-
useWidgetTheme
|
|
12
|
-
} from "./chunk-G5MS2TH6.js";
|
|
13
1
|
import {
|
|
14
2
|
ElicitationDeclinedError,
|
|
15
3
|
ElicitationTimeoutError,
|
|
@@ -20,9 +8,10 @@ import {
|
|
|
20
8
|
streamEventsToAISDK,
|
|
21
9
|
streamEventsToAISDKWithTools
|
|
22
10
|
} from "./chunk-LGDFGYRL.js";
|
|
23
|
-
import "./chunk-6M5L4OSE.js";
|
|
24
11
|
import "./chunk-GXNAXUDI.js";
|
|
25
|
-
import
|
|
12
|
+
import {
|
|
13
|
+
PROMPTS
|
|
14
|
+
} from "./chunk-SBMQ4QZJ.js";
|
|
26
15
|
import {
|
|
27
16
|
AcquireActiveMCPServerTool,
|
|
28
17
|
AddMCPServerFromConfigTool,
|
|
@@ -37,7 +26,7 @@ import {
|
|
|
37
26
|
getSupportedProviders,
|
|
38
27
|
isValidLLMString,
|
|
39
28
|
parseLLMString
|
|
40
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-MIKDMUFS.js";
|
|
41
30
|
import "./chunk-JRGQRPTN.js";
|
|
42
31
|
import {
|
|
43
32
|
BaseCodeExecutor,
|
|
@@ -47,37 +36,44 @@ import {
|
|
|
47
36
|
VMCodeExecutor,
|
|
48
37
|
isVMAvailable,
|
|
49
38
|
loadConfigFile
|
|
50
|
-
} from "./chunk-
|
|
51
|
-
import {
|
|
52
|
-
HttpConnector,
|
|
53
|
-
MCPSession
|
|
54
|
-
} from "./chunk-3O4V246Q.js";
|
|
39
|
+
} from "./chunk-U7JXQZVH.js";
|
|
55
40
|
import {
|
|
56
41
|
BaseAdapter
|
|
57
42
|
} from "./chunk-MFSO5PUW.js";
|
|
58
43
|
import "./chunk-JQKKMUCT.js";
|
|
59
44
|
import {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
ErrorBoundary,
|
|
46
|
+
Image,
|
|
47
|
+
McpUseProvider,
|
|
48
|
+
ThemeProvider,
|
|
49
|
+
WidgetControls,
|
|
50
|
+
useMcp,
|
|
51
|
+
useWidget,
|
|
52
|
+
useWidgetProps,
|
|
53
|
+
useWidgetState,
|
|
54
|
+
useWidgetTheme
|
|
55
|
+
} from "./chunk-JYFYHDYK.js";
|
|
56
|
+
import "./chunk-PO6UGK4I.js";
|
|
67
57
|
import {
|
|
68
|
-
BaseConnector
|
|
69
|
-
|
|
58
|
+
BaseConnector,
|
|
59
|
+
HttpConnector,
|
|
60
|
+
MCPSession
|
|
61
|
+
} from "./chunk-2IMIUODV.js";
|
|
70
62
|
import {
|
|
71
63
|
Tel,
|
|
72
64
|
Telemetry,
|
|
73
65
|
VERSION,
|
|
74
66
|
getPackageVersion,
|
|
75
67
|
setTelemetrySource
|
|
76
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-7TS5EJ4T.js";
|
|
77
69
|
import {
|
|
78
70
|
Logger,
|
|
79
71
|
logger
|
|
80
72
|
} from "./chunk-FRUZDWXH.js";
|
|
73
|
+
import {
|
|
74
|
+
BrowserOAuthClientProvider,
|
|
75
|
+
onMcpAuthorization
|
|
76
|
+
} from "./chunk-J75I2C26.js";
|
|
81
77
|
import {
|
|
82
78
|
__name
|
|
83
79
|
} from "./chunk-3GQAWCBQ.js";
|
|
@@ -1417,7 +1417,7 @@ __name(generateUUID, "generateUUID");
|
|
|
1417
1417
|
init_logging();
|
|
1418
1418
|
|
|
1419
1419
|
// src/version.ts
|
|
1420
|
-
var VERSION = "1.11.0-canary.
|
|
1420
|
+
var VERSION = "1.11.0-canary.14";
|
|
1421
1421
|
function getPackageVersion() {
|
|
1422
1422
|
return VERSION;
|
|
1423
1423
|
}
|
|
@@ -2752,7 +2752,7 @@ var CodeModeConnector = class extends BaseConnector {
|
|
|
2752
2752
|
}
|
|
2753
2753
|
};
|
|
2754
2754
|
|
|
2755
|
-
// src/
|
|
2755
|
+
// src/agents/prompts/index.ts
|
|
2756
2756
|
var PROMPTS = {
|
|
2757
2757
|
CODE_MODE: CODE_MODE_AGENT_PROMPT
|
|
2758
2758
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,eAAe,EACf,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/src/agents/index.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
BaseAgent
|
|
3
|
-
|
|
2
|
+
BaseAgent,
|
|
3
|
+
PROMPTS
|
|
4
|
+
} from "../../chunk-SBMQ4QZJ.js";
|
|
4
5
|
import {
|
|
5
6
|
MCPAgent,
|
|
6
7
|
RemoteAgent
|
|
7
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-MIKDMUFS.js";
|
|
8
9
|
import "../../chunk-JRGQRPTN.js";
|
|
9
|
-
import "../../chunk-
|
|
10
|
-
import "../../chunk-3O4V246Q.js";
|
|
10
|
+
import "../../chunk-U7JXQZVH.js";
|
|
11
11
|
import "../../chunk-MFSO5PUW.js";
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
} from "../../chunk-SF2V4IJ7.js";
|
|
15
|
-
import "../../chunk-QGEH5MZS.js";
|
|
16
|
-
import "../../chunk-GECOPE3S.js";
|
|
17
|
-
import "../../chunk-4NBH6YUZ.js";
|
|
12
|
+
import "../../chunk-2IMIUODV.js";
|
|
13
|
+
import "../../chunk-7TS5EJ4T.js";
|
|
18
14
|
import "../../chunk-FRUZDWXH.js";
|
|
19
15
|
import "../../chunk-3GQAWCBQ.js";
|
|
20
16
|
export {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Prompt templates for MCP
|
|
2
|
+
* Prompt templates for MCP agents.
|
|
3
3
|
*
|
|
4
4
|
* This module provides prompt templates to guide agents on how to use
|
|
5
|
-
* MCP tools
|
|
5
|
+
* MCP tools, including code execution mode.
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
8
|
* Collection of prompt templates for MCP agents.
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
export declare const PROMPTS: {
|
|
11
11
|
readonly CODE_MODE: "\n## MCP Code Mode Tool Usage Guide\n\nYou have access to an MCP Code Mode Client that allows you to execute JavaScript/TypeScript code with access to registered tools. Follow this workflow:\n\n### 1. Tool Discovery Phase\n**Always start by discovering available tools:**\n- Tools are organized by server namespace (e.g., `server_name.tool_name`)\n- Use the `search_tools(query, detail_level)` function to find available tools\n- You can access `__tool_namespaces` to see all available server namespaces\n\n```javascript\n// Find all GitHub-related tools\nconst tools = await search_tools(\"github\");\nfor (const tool of tools) {\n console.log(`${tool.server}.${tool.name}: ${tool.description}`);\n}\n\n// Get only tool names for quick overview\nconst tools = await search_tools(\"\", \"names\");\n```\n\n### 2. Interface Introspection\n**Understand tool contracts before using them:**\n- Use `search_tools` to get tool descriptions and input schemas\n- Look for \"Access as: server.tool(args)\" patterns in descriptions\n\n### 3. Code Execution Guidelines\n**When writing code:**\n- Use `await server.tool({ param: value })` syntax for all tool calls\n- Tools are async functions that return promises\n- You have access to standard JavaScript globals: `console`, `JSON`, `Math`, `Date`, etc.\n- All console output (`console.log`, `console.error`, etc.) is automatically captured and returned\n- Build properly structured input objects based on interface definitions\n- Handle errors appropriately with try/catch blocks\n- Chain tool calls by using results from previous calls\n\n### 4. Best Practices\n- **Discover first, code second**: Always explore available tools before writing execution code\n- **Respect namespaces**: Use full `server.tool` names to avoid conflicts\n- **Minimize Context**: Process large data in code, return only essential results\n- **Error handling**: Wrap tool calls in try/catch for robustness\n- **Data flow**: Chain tools by passing outputs as inputs to subsequent tools\n\n### 5. Available Runtime Context\n- `search_tools(query, detail_level)`: Function to discover tools\n- `__tool_namespaces`: Array of available server namespaces\n- All registered tools as `server.tool` functions\n- Standard JavaScript built-ins for data processing\n\n### Example Workflow\n\n```javascript\n// 1. Discover available tools\nconst github_tools = await search_tools(\"github pull request\");\nconsole.log(`Available GitHub PR tools: ${github_tools.map(t => t.name)}`);\n\n// 2. Call tools with proper parameters\nconst pr = await github.get_pull_request({\n owner: \"facebook\",\n repo: \"react\",\n number: 12345\n});\n\n// 3. Process results\nlet result;\nif (pr.state === 'open' && pr.labels.some(l => l.name === 'bug')) {\n // 4. Chain with other tools\n await slack.post_message({\n channel: \"#bugs\",\n text: `🐛 Bug PR needs review: ${pr.title}`\n });\n result = \"Notification sent\";\n} else {\n result = \"No action needed\";\n}\n\n// 5. Return structured results\nreturn {\n pr_number: pr.number,\n pr_title: pr.title,\n action_taken: result\n};\n```\n\nRemember: Always discover and understand available tools before attempting to use them in code execution.\n";
|
|
12
12
|
};
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/agents/prompts/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,eAAO,MAAM,OAAO;;CAEV,CAAC"}
|
package/dist/src/browser.cjs
CHANGED
package/dist/src/browser.js
CHANGED
|
@@ -3,9 +3,6 @@ import {
|
|
|
3
3
|
streamEventsToAISDK,
|
|
4
4
|
streamEventsToAISDKWithTools
|
|
5
5
|
} from "../chunk-LGDFGYRL.js";
|
|
6
|
-
import {
|
|
7
|
-
BrowserMCPClient
|
|
8
|
-
} from "../chunk-6M5L4OSE.js";
|
|
9
6
|
import "../chunk-GXNAXUDI.js";
|
|
10
7
|
import {
|
|
11
8
|
MCPAgent,
|
|
@@ -15,35 +12,35 @@ import {
|
|
|
15
12
|
getSupportedProviders,
|
|
16
13
|
isValidLLMString,
|
|
17
14
|
parseLLMString
|
|
18
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-MIKDMUFS.js";
|
|
19
16
|
import "../chunk-JRGQRPTN.js";
|
|
20
|
-
import "../chunk-
|
|
21
|
-
import {
|
|
22
|
-
HttpConnector,
|
|
23
|
-
MCPSession
|
|
24
|
-
} from "../chunk-3O4V246Q.js";
|
|
17
|
+
import "../chunk-U7JXQZVH.js";
|
|
25
18
|
import {
|
|
26
19
|
BaseAdapter
|
|
27
20
|
} from "../chunk-MFSO5PUW.js";
|
|
28
21
|
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} from "../chunk-J75I2C26.js";
|
|
32
|
-
import "../chunk-QGEH5MZS.js";
|
|
22
|
+
BrowserMCPClient
|
|
23
|
+
} from "../chunk-PO6UGK4I.js";
|
|
33
24
|
import {
|
|
34
|
-
BaseConnector
|
|
35
|
-
|
|
25
|
+
BaseConnector,
|
|
26
|
+
HttpConnector,
|
|
27
|
+
MCPSession
|
|
28
|
+
} from "../chunk-2IMIUODV.js";
|
|
36
29
|
import {
|
|
37
30
|
Tel,
|
|
38
31
|
Telemetry,
|
|
39
32
|
VERSION,
|
|
40
33
|
getPackageVersion,
|
|
41
34
|
setTelemetrySource
|
|
42
|
-
} from "../chunk-
|
|
35
|
+
} from "../chunk-7TS5EJ4T.js";
|
|
43
36
|
import {
|
|
44
37
|
Logger,
|
|
45
38
|
logger
|
|
46
39
|
} from "../chunk-FRUZDWXH.js";
|
|
40
|
+
import {
|
|
41
|
+
BrowserOAuthClientProvider,
|
|
42
|
+
onMcpAuthorization
|
|
43
|
+
} from "../chunk-J75I2C26.js";
|
|
47
44
|
import "../chunk-3GQAWCBQ.js";
|
|
48
45
|
export {
|
|
49
46
|
BaseAdapter,
|
package/dist/src/client.cjs
CHANGED
package/dist/src/client.js
CHANGED
|
@@ -4,13 +4,11 @@ import {
|
|
|
4
4
|
MCPClient,
|
|
5
5
|
VMCodeExecutor,
|
|
6
6
|
isVMAvailable
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-U7JXQZVH.js";
|
|
8
8
|
import {
|
|
9
9
|
MCPSession
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-GECOPE3S.js";
|
|
13
|
-
import "../chunk-4NBH6YUZ.js";
|
|
10
|
+
} from "../chunk-2IMIUODV.js";
|
|
11
|
+
import "../chunk-7TS5EJ4T.js";
|
|
14
12
|
import "../chunk-FRUZDWXH.js";
|
|
15
13
|
import "../chunk-3GQAWCBQ.js";
|
|
16
14
|
export {
|
package/dist/src/react/index.cjs
CHANGED
package/dist/src/react/index.js
CHANGED
|
@@ -9,19 +9,18 @@ import {
|
|
|
9
9
|
useWidgetProps,
|
|
10
10
|
useWidgetState,
|
|
11
11
|
useWidgetTheme
|
|
12
|
-
} from "../../chunk-
|
|
13
|
-
import "../../chunk-
|
|
14
|
-
import "../../chunk-
|
|
15
|
-
import {
|
|
16
|
-
onMcpAuthorization
|
|
17
|
-
} from "../../chunk-J75I2C26.js";
|
|
18
|
-
import "../../chunk-GECOPE3S.js";
|
|
12
|
+
} from "../../chunk-JYFYHDYK.js";
|
|
13
|
+
import "../../chunk-PO6UGK4I.js";
|
|
14
|
+
import "../../chunk-2IMIUODV.js";
|
|
19
15
|
import {
|
|
20
16
|
Tel,
|
|
21
17
|
Telemetry,
|
|
22
18
|
setTelemetrySource
|
|
23
|
-
} from "../../chunk-
|
|
19
|
+
} from "../../chunk-7TS5EJ4T.js";
|
|
24
20
|
import "../../chunk-FRUZDWXH.js";
|
|
21
|
+
import {
|
|
22
|
+
onMcpAuthorization
|
|
23
|
+
} from "../../chunk-J75I2C26.js";
|
|
25
24
|
import "../../chunk-3GQAWCBQ.js";
|
|
26
25
|
export {
|
|
27
26
|
Tel as BrowserTelemetry,
|
package/dist/src/server/index.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createRequest,
|
|
3
|
-
sendNotificationToAll,
|
|
4
|
-
sendNotificationToSession
|
|
5
|
-
} from "../../chunk-UWWLWLS2.js";
|
|
6
1
|
import {
|
|
7
2
|
getRequestContext,
|
|
8
3
|
hasRequestContext,
|
|
@@ -12,13 +7,18 @@ import {
|
|
|
12
7
|
createEnhancedContext,
|
|
13
8
|
findSessionContext,
|
|
14
9
|
isValidLogLevel
|
|
15
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-AEHNVFZG.js";
|
|
16
11
|
import {
|
|
17
12
|
convertToolResultToResourceResult
|
|
18
13
|
} from "../../chunk-362PI25Z.js";
|
|
19
14
|
import {
|
|
20
15
|
convertToolResultToPromptResult
|
|
21
16
|
} from "../../chunk-2EYAMIT3.js";
|
|
17
|
+
import {
|
|
18
|
+
createRequest,
|
|
19
|
+
sendNotificationToAll,
|
|
20
|
+
sendNotificationToSession
|
|
21
|
+
} from "../../chunk-UWWLWLS2.js";
|
|
22
22
|
import "../../chunk-KUEVOU4M.js";
|
|
23
23
|
import {
|
|
24
24
|
Telemetry,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
getPackageVersion,
|
|
31
31
|
isDeno,
|
|
32
32
|
pathHelpers
|
|
33
|
-
} from "../../chunk-
|
|
33
|
+
} from "../../chunk-7TS5EJ4T.js";
|
|
34
34
|
import "../../chunk-FRUZDWXH.js";
|
|
35
35
|
import {
|
|
36
36
|
__name
|
|
@@ -2205,7 +2205,7 @@ function registerResource(resourceDefinition, callback) {
|
|
|
2205
2205
|
const explicitMimeType = resourceDefinition.mimeType;
|
|
2206
2206
|
const wrappedCallback = /* @__PURE__ */ __name(async () => {
|
|
2207
2207
|
const { getRequestContext: getRequestContext2, runWithContext: runWithContext2 } = await import("../../context-storage-NA4MHWOZ.js");
|
|
2208
|
-
const { findSessionContext: findSessionContext2 } = await import("../../tool-execution-helpers-
|
|
2208
|
+
const { findSessionContext: findSessionContext2 } = await import("../../tool-execution-helpers-RRECKMIN.js");
|
|
2209
2209
|
const initialRequestContext = getRequestContext2();
|
|
2210
2210
|
const sessions = this.sessions || /* @__PURE__ */ new Map();
|
|
2211
2211
|
const { requestContext } = findSessionContext2(
|
|
@@ -2283,7 +2283,7 @@ function registerResourceTemplate(resourceTemplateDefinition, callback) {
|
|
|
2283
2283
|
async (uri) => {
|
|
2284
2284
|
const params = this.parseTemplateUri(uriTemplate, uri.toString());
|
|
2285
2285
|
const { getRequestContext: getRequestContext2, runWithContext: runWithContext2 } = await import("../../context-storage-NA4MHWOZ.js");
|
|
2286
|
-
const { findSessionContext: findSessionContext2 } = await import("../../tool-execution-helpers-
|
|
2286
|
+
const { findSessionContext: findSessionContext2 } = await import("../../tool-execution-helpers-RRECKMIN.js");
|
|
2287
2287
|
const initialRequestContext = getRequestContext2();
|
|
2288
2288
|
const sessions = this.sessions || /* @__PURE__ */ new Map();
|
|
2289
2289
|
const { requestContext } = findSessionContext2(
|
|
@@ -2338,7 +2338,7 @@ function registerPrompt(promptDefinition, callback) {
|
|
|
2338
2338
|
}
|
|
2339
2339
|
const wrappedCallback = /* @__PURE__ */ __name(async (params, extra) => {
|
|
2340
2340
|
const { getRequestContext: getRequestContext2, runWithContext: runWithContext2 } = await import("../../context-storage-NA4MHWOZ.js");
|
|
2341
|
-
const { findSessionContext: findSessionContext2 } = await import("../../tool-execution-helpers-
|
|
2341
|
+
const { findSessionContext: findSessionContext2 } = await import("../../tool-execution-helpers-RRECKMIN.js");
|
|
2342
2342
|
const initialRequestContext = getRequestContext2();
|
|
2343
2343
|
const sessions = this.sessions || /* @__PURE__ */ new Map();
|
|
2344
2344
|
const { requestContext } = findSessionContext2(
|
package/dist/src/version.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
sendProgressNotification,
|
|
11
11
|
shouldLogMessage,
|
|
12
12
|
withTimeout
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-AEHNVFZG.js";
|
|
14
14
|
import "./chunk-KUEVOU4M.js";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-7TS5EJ4T.js";
|
|
16
16
|
import "./chunk-FRUZDWXH.js";
|
|
17
17
|
import "./chunk-3GQAWCBQ.js";
|
|
18
18
|
export {
|