@h1deya/langchain-mcp-tools 0.1.12 → 0.1.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/README.md CHANGED
@@ -11,21 +11,21 @@ dramatically expands LLM’s scope
11
11
  by enabling external tool and resource integration, including
12
12
  Google Drive, Slack, Notion, Spotify, Docker, PostgreSQL, and more…
13
13
 
14
- Over 450 functional components available as MCP servers:
14
+ Over 800 functional components available as MCP servers:
15
15
 
16
16
  - [Glama’s list of Open-Source MCP servers](https://glama.ai/mcp/servers)
17
17
  - [Smithery: MCP Server Registry](https://smithery.ai/)
18
18
  - [awesome-mcp-servers](https://github.com/hideya/awesome-mcp-servers#Server-Implementations)
19
19
  - [MCP Get Started/Example Servers](https://modelcontextprotocol.io/examples)
20
20
 
21
- The goal of this utility is to make these 450+ MCP servers readily accessible from LangChain.
21
+ The goal of this utility is to make these 800+ MCP servers readily accessible from LangChain.
22
22
 
23
23
  It contains a utility function `convertMcpToLangchainTools()`.
24
24
  This async function handles parallel initialization of specified multiple MCP servers
25
25
  and converts their available tools into an array of LangChain-compatible tools.
26
26
 
27
27
  For detailed information on how to use this library, please refer to the following document:
28
- - ["Supercharging LangChain: Integrating 450+ MCP with ReAct"](https://medium.com/@h1deya/supercharging-langchain-integrating-450-mcp-with-react-d4e467cbf41a)
28
+ - ["Supercharging LangChain: Integrating 800+ MCP with ReAct"](https://medium.com/@h1deya/supercharging-langchain-integrating-800-mcp-with-react-d4e467cbf41a)
29
29
 
30
30
  A python equivalent of this utility is available
31
31
  [here](https://pypi.org/project/langchain-mcp-tools)
@@ -91,7 +91,7 @@ For hands-on experimentation with MCP server integration,
91
91
  try [this LangChain application built with the utility](https://github.com/hideya/mcp-client-langchain-ts)
92
92
 
93
93
  For detailed information on how to use this library, please refer to the following document:
94
- ["Supercharging LangChain: Integrating 450+ MCP with ReAct"](https://medium.com/@h1deya/supercharging-langchain-integrating-450-mcp-with-react-d4e467cbf41a)
94
+ ["Supercharging LangChain: Integrating 800+ MCP with ReAct"](https://medium.com/@h1deya/supercharging-langchain-integrating-800-mcp-with-react-d4e467cbf41a)
95
95
 
96
96
  ## Limitations
97
97
 
@@ -121,29 +121,40 @@ async function convertSingleMcpToLangchainTools(serverName, config, logger) {
121
121
  // FIXME
122
122
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
123
123
  schema: jsonSchemaToZod(tool.inputSchema),
124
- func: async (input) => {
124
+ func: async function (input) {
125
125
  logger.info(`MCP tool "${serverName}"/"${tool.name}" received input:`, input);
126
- // Execute tool call
127
- const result = await client?.request({
128
- method: "tools/call",
129
- params: {
130
- name: tool.name,
131
- arguments: input,
132
- },
133
- }, CallToolResultSchema);
134
- // Handles null/undefined cases gracefully
135
- if (!result?.content) {
136
- logger.info(`MCP tool "${serverName}"/"${tool.name}" received null/undefined result`);
137
- return '';
126
+ try {
127
+ // Execute tool call
128
+ const result = await client?.request({
129
+ method: "tools/call",
130
+ params: {
131
+ name: tool.name,
132
+ arguments: input,
133
+ },
134
+ }, CallToolResultSchema);
135
+ // Handles null/undefined cases gracefully
136
+ if (!result?.content) {
137
+ logger.info(`MCP tool "${serverName}"/"${tool.name}" received null/undefined result`);
138
+ return '';
139
+ }
140
+ const textContent = result.content
141
+ .filter(content => content.type === 'text')
142
+ .map(content => content.text)
143
+ .join('\n\n');
144
+ // const textItems = result.content
145
+ // .filter(content => content.type === 'text')
146
+ // .map(content => content.text)
147
+ // const textContent = JSON.stringify(textItems);
148
+ // Log rough result size for monitoring
149
+ const size = new TextEncoder().encode(textContent).length;
150
+ logger.info(`MCP tool "${serverName}"/"${tool.name}" received result (size: ${size})`);
151
+ // If no text content, return a clear message describing the situation
152
+ return textContent || 'No text content available in response';
153
+ }
154
+ catch (error) {
155
+ logger.warn(`MCP tool "${serverName}"/"${tool.name}" caused error: ${error}`);
156
+ return `Error executing MCP tool: ${error}`;
138
157
  }
139
- // For multiple content pieces or mixed types
140
- const textContent = result.content
141
- .filter(content => content.type === 'text')
142
- .map(content => content.text)
143
- .join('\n\n');
144
- logger.info(`MCP tool "${serverName}"/"${tool.name}" received result (length: ${textContent.length})`);
145
- // If no text content, return a clear message describing the situation
146
- return textContent || 'No text content available in response';
147
158
  },
148
159
  })));
149
160
  logger.info(`MCP server "${serverName}": ${tools.length} tool(s) available:`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h1deya/langchain-mcp-tools",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "MCP To LangChain Tools Conversion Utility",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -33,11 +33,14 @@
33
33
  "build": "tsc",
34
34
  "prepare": "npm run build",
35
35
  "watch": "tsc --watch",
36
+ "example": "tsx examples/example.ts",
36
37
  "lint": "eslint src",
37
38
  "test": "vitest run",
38
39
  "test:watch": "vitest",
39
40
  "test:coverage": "vitest run --coverage",
40
- "clean": "git clean -fdxn -e .env && read -p 'OK?' && git clean -fdx -e .env"
41
+ "clean": "git clean -fdxn -e .env && read -p 'OK?' && git clean -fdx -e .env",
42
+ "do-publish": "npm run clean && npm install && npm publish --access=public",
43
+ "publish-dry-run": "npm run clean && npm install && npm publish --access=public --dry-run"
41
44
  },
42
45
  "dependencies": {
43
46
  "@langchain/core": "^0.3.27",
@@ -47,11 +50,16 @@
47
50
  },
48
51
  "devDependencies": {
49
52
  "@eslint/js": "^9.17.0",
53
+ "@langchain/anthropic": "^0.3.11",
54
+ "@langchain/langgraph": "^0.2.36",
55
+ "@langchain/openai": "^0.3.16",
50
56
  "@types/node": "^22.10.5",
51
57
  "@typescript-eslint/eslint-plugin": "^8.19.0",
52
58
  "@typescript-eslint/parser": "^8.19.0",
53
59
  "@vitest/coverage-v8": "^2.1.8",
60
+ "dotenv": "^16.4.7",
54
61
  "eslint": "^9.17.0",
62
+ "tsx": "^4.19.3",
55
63
  "typescript": "^5.7.2",
56
64
  "typescript-eslint": "^8.19.0",
57
65
  "vitest": "^2.1.8"