mcp-use 0.1.19 → 0.1.20
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"langchain_adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/langchain_adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"langchain_adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/langchain_adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAEV,IAAI,IAAI,OAAO,EAChB,MAAM,oCAAoC,CAAA;AAE3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAM1D,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAYvC,qBAAa,gBAAiB,SAAQ,WAAW,CAAC,uBAAuB,CAAC;gBAC5D,eAAe,GAAE,MAAM,EAAO;IAI1C;;OAEG;IACH,SAAS,CAAC,WAAW,CACnB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,aAAa,GACvB,uBAAuB,GAAG,IAAI;CA8BlC"}
|
@@ -12,47 +12,6 @@ function schemaToZod(schema) {
|
|
12
12
|
return z.any();
|
13
13
|
}
|
14
14
|
}
|
15
|
-
function parseMcpToolResult(toolResult) {
|
16
|
-
if (toolResult.isError) {
|
17
|
-
throw new Error(`Tool execution failed: ${toolResult.content}`);
|
18
|
-
}
|
19
|
-
if (!toolResult.content || toolResult.content.length === 0) {
|
20
|
-
throw new Error('Tool execution returned no content');
|
21
|
-
}
|
22
|
-
let decoded = '';
|
23
|
-
for (const item of toolResult.content) {
|
24
|
-
switch (item.type) {
|
25
|
-
case 'text': {
|
26
|
-
decoded += item.text;
|
27
|
-
break;
|
28
|
-
}
|
29
|
-
case 'image': {
|
30
|
-
decoded += item.data;
|
31
|
-
break;
|
32
|
-
}
|
33
|
-
case 'resource': {
|
34
|
-
const res = item.resource;
|
35
|
-
if (res?.text !== undefined) {
|
36
|
-
decoded += res.text;
|
37
|
-
}
|
38
|
-
else if (res?.blob !== undefined) {
|
39
|
-
// eslint-disable-next-line node/prefer-global/buffer
|
40
|
-
decoded += res.blob instanceof Uint8Array || res.blob instanceof Buffer
|
41
|
-
// eslint-disable-next-line node/prefer-global/buffer
|
42
|
-
? Buffer.from(res.blob).toString('base64')
|
43
|
-
: String(res.blob);
|
44
|
-
}
|
45
|
-
else {
|
46
|
-
throw new Error(`Unexpected resource type: ${res?.type}`);
|
47
|
-
}
|
48
|
-
break;
|
49
|
-
}
|
50
|
-
default:
|
51
|
-
throw new Error(`Unexpected content type: ${item.type}`);
|
52
|
-
}
|
53
|
-
}
|
54
|
-
return decoded;
|
55
|
-
}
|
56
15
|
export class LangChainAdapter extends BaseAdapter {
|
57
16
|
constructor(disallowedTools = []) {
|
58
17
|
super(disallowedTools);
|
@@ -77,7 +36,7 @@ export class LangChainAdapter extends BaseAdapter {
|
|
77
36
|
logger.debug(`MCP tool \"${mcpTool.name}\" received input: ${JSON.stringify(input)}`);
|
78
37
|
try {
|
79
38
|
const result = await connector.callTool(mcpTool.name, input);
|
80
|
-
return
|
39
|
+
return JSON.stringify(result);
|
81
40
|
}
|
82
41
|
catch (err) {
|
83
42
|
logger.error(`Error executing MCP tool: ${err.message}`);
|
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.20",
|
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": "mcp-use, Inc.",
|