langchain-mcp-tools 0.1.10__py3-none-any.whl → 0.1.11__py3-none-any.whl
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.
- langchain_mcp_tools/langchain_mcp_tools.py +23 -8
- {langchain_mcp_tools-0.1.10.dist-info → langchain_mcp_tools-0.1.11.dist-info}/METADATA +13 -10
- langchain_mcp_tools-0.1.11.dist-info/RECORD +8 -0
- {langchain_mcp_tools-0.1.10.dist-info → langchain_mcp_tools-0.1.11.dist-info}/WHEEL +1 -1
- langchain_mcp_tools-0.1.10.dist-info/RECORD +0 -8
- {langchain_mcp_tools-0.1.10.dist-info → langchain_mcp_tools-0.1.11.dist-info}/licenses/LICENSE +0 -0
- {langchain_mcp_tools-0.1.10.dist-info → langchain_mcp_tools-0.1.11.dist-info}/top_level.txt +0 -0
@@ -24,8 +24,8 @@ from typing import (
|
|
24
24
|
try:
|
25
25
|
from jsonschema_pydantic import jsonschema_to_pydantic # type: ignore
|
26
26
|
from langchain_core.tools import BaseTool, ToolException
|
27
|
-
from mcp import ClientSession
|
28
|
-
from mcp.client.stdio import stdio_client
|
27
|
+
from mcp import ClientSession
|
28
|
+
from mcp.client.stdio import stdio_client, StdioServerParameters
|
29
29
|
import mcp.types as mcp_types
|
30
30
|
from pydantic import BaseModel
|
31
31
|
# from pydantic_core import to_json
|
@@ -90,12 +90,23 @@ async def spawn_mcp_server_and_get_transport(
|
|
90
90
|
server_params = StdioServerParameters(
|
91
91
|
command=server_config['command'],
|
92
92
|
args=server_config.get('args', []),
|
93
|
-
env=env
|
93
|
+
env=env,
|
94
|
+
cwd=server_config.get('cwd', None)
|
94
95
|
)
|
95
96
|
|
96
97
|
# Initialize stdio client and register it with exit stack for cleanup
|
98
|
+
# NOTE: Why the key name `stderr` for `server_config` was chosen:
|
99
|
+
# Unlike the TypeScript SDK's `StdioServerParameters`, the Python SDK's
|
100
|
+
# `StdioServerParameters` doesn't include `stderr`.
|
101
|
+
# Instead, it calls `stdio_client()` with a separate argument
|
102
|
+
# `errlog`. I once thought of using `errlog` for the key for the
|
103
|
+
# Pyhton version, but decided to follow the TypeScript version since
|
104
|
+
# its public API already exposes the key name and I choose consistency.
|
97
105
|
stdio_transport = await exit_stack.enter_async_context(
|
98
|
-
stdio_client(
|
106
|
+
stdio_client(
|
107
|
+
server_params,
|
108
|
+
errlog=server_config.get('stderr', None)
|
109
|
+
)
|
99
110
|
)
|
100
111
|
except Exception as e:
|
101
112
|
logger.error(f'Error spawning MCP server: {str(e)}')
|
@@ -247,7 +258,7 @@ async def get_mcp_server_tools(
|
|
247
258
|
return langchain_tools
|
248
259
|
|
249
260
|
|
250
|
-
# A very simple pre-
|
261
|
+
# A very simple pre-configured logger for fallback
|
251
262
|
def init_logger() -> logging.Logger:
|
252
263
|
logging.basicConfig(
|
253
264
|
level=logging.INFO, # logging.DEBUG,
|
@@ -287,8 +298,12 @@ async def convert_mcp_to_langchain_tools(
|
|
287
298
|
|
288
299
|
Example:
|
289
300
|
server_configs = {
|
290
|
-
|
291
|
-
|
301
|
+
'fetch': {
|
302
|
+
'command': 'uvx', 'args': ['mcp-server-fetch']
|
303
|
+
},
|
304
|
+
'weather': {
|
305
|
+
'command': 'npx', 'args': ['-y','@h1deya/mcp-server-weather']
|
306
|
+
}
|
292
307
|
}
|
293
308
|
tools, cleanup = await convert_mcp_to_langchain_tools(server_configs)
|
294
309
|
# Use tools...
|
@@ -299,7 +314,7 @@ async def convert_mcp_to_langchain_tools(
|
|
299
314
|
logger = logging.getLogger(__name__)
|
300
315
|
# Check if the root logger has handlers configured
|
301
316
|
if not logging.root.handlers and not logger.handlers:
|
302
|
-
# No logging configured, use
|
317
|
+
# No logging configured, use a simple pre-configured logger
|
303
318
|
logger = init_logger()
|
304
319
|
|
305
320
|
# Initialize AsyncExitStack for managing multiple server lifecycles
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: langchain-mcp-tools
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.11
|
4
4
|
Summary: Model Context Protocol (MCP) To LangChain Tools Conversion Utility
|
5
5
|
Project-URL: Bug Tracker, https://github.com/hideya/langchain-mcp-tools-py/issues
|
6
6
|
Project-URL: Source Code, https://github.com/hideya/langchain-mcp-tools-py
|
@@ -10,7 +10,7 @@ Description-Content-Type: text/markdown
|
|
10
10
|
License-File: LICENSE
|
11
11
|
Requires-Dist: jsonschema-pydantic>=0.6
|
12
12
|
Requires-Dist: langchain>=0.3.14
|
13
|
-
Requires-Dist: mcp>=1.
|
13
|
+
Requires-Dist: mcp>=1.6.0
|
14
14
|
Requires-Dist: pyjson5>=1.6.8
|
15
15
|
Provides-Extra: dev
|
16
16
|
Requires-Dist: dotenv>=0.9.9; extra == "dev"
|
@@ -35,21 +35,20 @@ dramatically expands LLM’s scope
|
|
35
35
|
by enabling external tool and resource integration, including
|
36
36
|
Google Drive, Slack, Notion, Spotify, Docker, PostgreSQL, and more…
|
37
37
|
|
38
|
-
Over
|
38
|
+
Over 2000 functional components available as MCP servers:
|
39
39
|
|
40
|
+
- [MCP Server Listing on the Official Site](https://github.com/modelcontextprotocol/servers?tab=readme-ov-file#model-context-protocol-servers)
|
40
41
|
- [MCP.so - Find Awesome MCP Servers and Clients](https://mcp.so/)
|
41
42
|
- [Smithery: MCP Server Registry](https://smithery.ai/)
|
42
|
-
- [pulse - Browse and discover MCP use cases, servers, clients, and news](https://www.pulsemcp.com/)
|
43
|
-
- [MCP Get Started/Example Servers](https://modelcontextprotocol.io/examples)
|
44
43
|
|
45
|
-
The goal of this utility is to make these
|
44
|
+
The goal of this utility is to make these 2000+ MCP servers readily accessible from LangChain.
|
46
45
|
|
47
46
|
It contains a utility function `convert_mcp_to_langchain_tools()`.
|
48
47
|
This async function handles parallel initialization of specified multiple MCP servers
|
49
48
|
and converts their available tools into a list of LangChain-compatible tools.
|
50
49
|
|
51
50
|
For detailed information on how to use this library, please refer to the following document:
|
52
|
-
- ["Supercharging LangChain: Integrating
|
51
|
+
- ["Supercharging LangChain: Integrating 2000+ MCP with ReAct"](https://medium.com/@h1deya/supercharging-langchain-integrating-450-mcp-with-react-d4e467cbf41a)
|
53
52
|
|
54
53
|
A typescript equivalent of this utility is available
|
55
54
|
[here](https://www.npmjs.com/package/@h1deya/langchain-mcp-tools)
|
@@ -73,7 +72,7 @@ but only the contents of the `mcpServers` property,
|
|
73
72
|
and is expressed as a `dict`, e.g.:
|
74
73
|
|
75
74
|
```python
|
76
|
-
|
75
|
+
mcp_servers = {
|
77
76
|
'filesystem': {
|
78
77
|
'command': 'npx',
|
79
78
|
'args': ['-y', '@modelcontextprotocol/server-filesystem', '.']
|
@@ -85,7 +84,7 @@ mcp_configs = {
|
|
85
84
|
}
|
86
85
|
|
87
86
|
tools, cleanup = await convert_mcp_to_langchain_tools(
|
88
|
-
|
87
|
+
mcp_servers
|
89
88
|
)
|
90
89
|
```
|
91
90
|
|
@@ -120,12 +119,16 @@ For hands-on experimentation with MCP server integration,
|
|
120
119
|
try [this LangChain application built with the utility](https://github.com/hideya/mcp-client-langchain-py)
|
121
120
|
|
122
121
|
For detailed information on how to use this library, please refer to the following document:
|
123
|
-
["Supercharging LangChain: Integrating
|
122
|
+
["Supercharging LangChain: Integrating 2000+ MCP with ReAct"](https://medium.com/@h1deya/supercharging-langchain-integrating-450-mcp-with-react-d4e467cbf41a)
|
124
123
|
|
125
124
|
## Limitations
|
126
125
|
|
127
126
|
Currently, only text results of tool calls are supported.
|
128
127
|
|
128
|
+
Remote MCP server access is not supported.
|
129
|
+
|
130
|
+
Optiional MCP client Features, Roots and Sampling, are not supported.
|
131
|
+
|
129
132
|
## Change Log
|
130
133
|
|
131
134
|
Can be found [here](https://github.com/hideya/langchain-mcp-tools-py/blob/main/CHANGELOG.md)
|
@@ -0,0 +1,8 @@
|
|
1
|
+
langchain_mcp_tools/__init__.py,sha256=Xtv2VphhrWB_KlxTIofHZqtCIGtNEl0MxugnrNXTERA,94
|
2
|
+
langchain_mcp_tools/langchain_mcp_tools.py,sha256=O6TxRRuS-uTOY08-WVKK86Dxx7-dCeFZZRLpBYaPIng,13577
|
3
|
+
langchain_mcp_tools/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
+
langchain_mcp_tools-0.1.11.dist-info/licenses/LICENSE,sha256=CRC91e8v116gCpnp7h49oIa6_zjhxqnHFTREeoZFJwA,1072
|
5
|
+
langchain_mcp_tools-0.1.11.dist-info/METADATA,sha256=lW4Mm8snEac1hYSuS0szfHmJZFBs79GAEo0bwyEW_sw,5212
|
6
|
+
langchain_mcp_tools-0.1.11.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
7
|
+
langchain_mcp_tools-0.1.11.dist-info/top_level.txt,sha256=aR_9V2A1Yt-Bca60KmndmGLUWb2wiM5IOG-Gkaf1dxY,20
|
8
|
+
langchain_mcp_tools-0.1.11.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
langchain_mcp_tools/__init__.py,sha256=Xtv2VphhrWB_KlxTIofHZqtCIGtNEl0MxugnrNXTERA,94
|
2
|
-
langchain_mcp_tools/langchain_mcp_tools.py,sha256=vIiOB8u62Q-7Mi8U6XI247g-xfxpE2QvoBeo0pbtFX4,12838
|
3
|
-
langchain_mcp_tools/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
langchain_mcp_tools-0.1.10.dist-info/licenses/LICENSE,sha256=CRC91e8v116gCpnp7h49oIa6_zjhxqnHFTREeoZFJwA,1072
|
5
|
-
langchain_mcp_tools-0.1.10.dist-info/METADATA,sha256=kAMCbY0YTAA5aj-SaiGqtAanX30ggpEeZO39zChua0Y,5135
|
6
|
-
langchain_mcp_tools-0.1.10.dist-info/WHEEL,sha256=DK49LOLCYiurdXXOXwGJm6U4DkHkg4lcxjhqwRa0CP4,91
|
7
|
-
langchain_mcp_tools-0.1.10.dist-info/top_level.txt,sha256=aR_9V2A1Yt-Bca60KmndmGLUWb2wiM5IOG-Gkaf1dxY,20
|
8
|
-
langchain_mcp_tools-0.1.10.dist-info/RECORD,,
|
{langchain_mcp_tools-0.1.10.dist-info → langchain_mcp_tools-0.1.11.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
File without changes
|