@h1deya/langchain-mcp-tools 0.1.7 → 0.1.8
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
|
@@ -9,7 +9,7 @@ This function handles parallel initialization of specified multiple MCP servers
|
|
|
9
9
|
and converts their available tools into an array of
|
|
10
10
|
[LangChain-compatible tools](https://js.langchain.com/docs/how_to/tool_calling/).
|
|
11
11
|
|
|
12
|
-
A python
|
|
12
|
+
A python equivalent of this utility library is available
|
|
13
13
|
[here](https://pypi.org/project/langchain-mcp-tools)
|
|
14
14
|
|
|
15
15
|
## Requirements
|
|
@@ -45,11 +45,12 @@ const mcpServers: McpServersConfig = {
|
|
|
45
45
|
const { tools, cleanup } = await convertMcpToLangchainTools(mcpServers);
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
and returns LangChain Tools
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
This utility function initializes all specified MCP servers in parallel,
|
|
49
|
+
and returns [LangChain Tools](https://api.js.langchain.com/modules/_langchain_core.tools.html)
|
|
50
|
+
(`tools: StructuredTool[]`)
|
|
51
|
+
by gathering available MCP tools from the servers,
|
|
52
|
+
and by wrapping them into LangChain tools.
|
|
53
|
+
It also returns an async callback function (`cleanup: McpServerCleanupFn`)
|
|
53
54
|
to be invoked to close all MCP server sessions when finished.
|
|
54
55
|
|
|
55
56
|
The returned tools can be used with LangChain, e.g.:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StructuredTool } from '@langchain/core/tools';
|
|
2
2
|
interface McpServerConfig {
|
|
3
3
|
command: string;
|
|
4
4
|
args: readonly string[];
|
|
@@ -21,7 +21,7 @@ export interface McpServerCleanupFn {
|
|
|
21
21
|
* @param options - Optional logging configuration
|
|
22
22
|
*
|
|
23
23
|
* @returns A promise that resolves to:
|
|
24
|
-
* - tools: Array of
|
|
24
|
+
* - tools: Array of StructuredTool instances ready for use with LangChain
|
|
25
25
|
* - cleanup: Function to properly terminate all server connections
|
|
26
26
|
*
|
|
27
27
|
* @throws McpInitializationError if any server fails to initialize
|
|
@@ -33,7 +33,7 @@ export interface McpServerCleanupFn {
|
|
|
33
33
|
* });
|
|
34
34
|
*/
|
|
35
35
|
export declare function convertMcpToLangchainTools(configs: McpServersConfig, options?: LogOptions): Promise<{
|
|
36
|
-
tools:
|
|
36
|
+
tools: StructuredTool[];
|
|
37
37
|
cleanup: McpServerCleanupFn;
|
|
38
38
|
}>;
|
|
39
39
|
export {};
|
|
@@ -23,7 +23,7 @@ class McpInitializationError extends Error {
|
|
|
23
23
|
* @param options - Optional logging configuration
|
|
24
24
|
*
|
|
25
25
|
* @returns A promise that resolves to:
|
|
26
|
-
* - tools: Array of
|
|
26
|
+
* - tools: Array of StructuredTool instances ready for use with LangChain
|
|
27
27
|
* - cleanup: Function to properly terminate all server connections
|
|
28
28
|
*
|
|
29
29
|
* @throws McpInitializationError if any server fails to initialize
|
|
@@ -81,7 +81,7 @@ export async function convertMcpToLangchainTools(configs, options) {
|
|
|
81
81
|
* @param logger - Logger instance for recording operation details
|
|
82
82
|
*
|
|
83
83
|
* @returns A promise that resolves to:
|
|
84
|
-
* - tools: Array of
|
|
84
|
+
* - tools: Array of StructuredTool instances from this server
|
|
85
85
|
* - cleanup: Function to properly terminate the server connection
|
|
86
86
|
*
|
|
87
87
|
* @throws McpInitializationError if server initialization fails
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h1deya/langchain-mcp-tools",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "MCP To LangChain Tools Conversion Utility",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"test": "vitest run",
|
|
35
35
|
"test:watch": "vitest",
|
|
36
36
|
"test:coverage": "vitest run --coverage",
|
|
37
|
-
"clean": "
|
|
37
|
+
"clean": "git clean -fdx"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@langchain/core": "^0.3.27",
|