langchain-mcp-tools 0.0.15__py3-none-any.whl → 0.0.16__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-0.0.15.dist-info → langchain_mcp_tools-0.0.16.dist-info}/METADATA +1 -3
- langchain_mcp_tools-0.0.16.dist-info/RECORD +8 -0
- langchain_mcp_tools-0.0.16.dist-info/top_level.txt +1 -0
- langchain_mcp_tools-0.0.15.dist-info/RECORD +0 -10
- langchain_mcp_tools-0.0.15.dist-info/top_level.txt +0 -1
- src/tests/__init__.py +0 -2
- src/tests/test_langchain_mcp_tools.py +0 -163
- {src/langchain_mcp_tools → langchain_mcp_tools}/__init__.py +0 -0
- {src/langchain_mcp_tools → langchain_mcp_tools}/langchain_mcp_tools.py +0 -0
- {src/langchain_mcp_tools → langchain_mcp_tools}/py.typed +0 -0
- {langchain_mcp_tools-0.0.15.dist-info → langchain_mcp_tools-0.0.16.dist-info}/LICENSE +0 -0
- {langchain_mcp_tools-0.0.15.dist-info → langchain_mcp_tools-0.0.16.dist-info}/WHEEL +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: langchain-mcp-tools
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.16
|
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
|
@@ -18,8 +18,6 @@ Requires-Dist: mcp>=1.2.0
|
|
18
18
|
Requires-Dist: pyjson5>=1.6.8
|
19
19
|
Requires-Dist: pympler>=1.1
|
20
20
|
Requires-Dist: python-dotenv>=1.0.1
|
21
|
-
Requires-Dist: pytest>=8.3.4
|
22
|
-
Requires-Dist: pytest-asyncio>=0.25.2
|
23
21
|
Provides-Extra: dev
|
24
22
|
Requires-Dist: twine>=6.0.1; extra == "dev"
|
25
23
|
|
@@ -0,0 +1,8 @@
|
|
1
|
+
langchain_mcp_tools/__init__.py,sha256=Xtv2VphhrWB_KlxTIofHZqtCIGtNEl0MxugnrNXTERA,94
|
2
|
+
langchain_mcp_tools/langchain_mcp_tools.py,sha256=EJgm28o2M3mBsFkeDtpw6hooSE1oWwjFJYhRfirxCgE,10511
|
3
|
+
langchain_mcp_tools/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
+
langchain_mcp_tools-0.0.16.dist-info/LICENSE,sha256=CRC91e8v116gCpnp7h49oIa6_zjhxqnHFTREeoZFJwA,1072
|
5
|
+
langchain_mcp_tools-0.0.16.dist-info/METADATA,sha256=S7Ii62KuH2HTe1eg3eqSqfpUWWagTKz0diIn3Wdc-Ns,6876
|
6
|
+
langchain_mcp_tools-0.0.16.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
7
|
+
langchain_mcp_tools-0.0.16.dist-info/top_level.txt,sha256=aR_9V2A1Yt-Bca60KmndmGLUWb2wiM5IOG-Gkaf1dxY,20
|
8
|
+
langchain_mcp_tools-0.0.16.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
langchain_mcp_tools
|
@@ -1,10 +0,0 @@
|
|
1
|
-
src/langchain_mcp_tools/__init__.py,sha256=Xtv2VphhrWB_KlxTIofHZqtCIGtNEl0MxugnrNXTERA,94
|
2
|
-
src/langchain_mcp_tools/langchain_mcp_tools.py,sha256=EJgm28o2M3mBsFkeDtpw6hooSE1oWwjFJYhRfirxCgE,10511
|
3
|
-
src/langchain_mcp_tools/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
src/tests/__init__.py,sha256=1tFqfPgsnrucXkBKUZ5LMAJ1lk5pdnHAFlUNqR_w21E,31
|
5
|
-
src/tests/test_langchain_mcp_tools.py,sha256=oy5fpsvf-p5YV6zPORau_Wz8rmkF-mNWR3T2r03XzjI,4464
|
6
|
-
langchain_mcp_tools-0.0.15.dist-info/LICENSE,sha256=CRC91e8v116gCpnp7h49oIa6_zjhxqnHFTREeoZFJwA,1072
|
7
|
-
langchain_mcp_tools-0.0.15.dist-info/METADATA,sha256=v-caB8b65upCaAni4N6ChUSjr6rGCAV4fwlH-Uy0S5M,6943
|
8
|
-
langchain_mcp_tools-0.0.15.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
9
|
-
langchain_mcp_tools-0.0.15.dist-info/top_level.txt,sha256=74rtVfumQlgAPzR5_2CgYN24MB0XARCg0t-gzk6gTrM,4
|
10
|
-
langchain_mcp_tools-0.0.15.dist-info/RECORD,,
|
@@ -1 +0,0 @@
|
|
1
|
-
src
|
src/tests/__init__.py
DELETED
@@ -1,163 +0,0 @@
|
|
1
|
-
import pytest
|
2
|
-
from unittest.mock import AsyncMock, MagicMock, patch
|
3
|
-
from langchain_core.tools import BaseTool
|
4
|
-
from langchain_mcp_tools.langchain_mcp_tools import (
|
5
|
-
convert_mcp_to_langchain_tools,
|
6
|
-
)
|
7
|
-
|
8
|
-
# Fix the asyncio mark warning by installing pytest-asyncio
|
9
|
-
pytest_plugins = ('pytest_asyncio',)
|
10
|
-
|
11
|
-
|
12
|
-
@pytest.fixture
|
13
|
-
def mock_stdio_client():
|
14
|
-
with patch('langchain_mcp_tools.langchain_mcp_tools.stdio_client') as mock:
|
15
|
-
mock.return_value.__aenter__.return_value = (AsyncMock(), AsyncMock())
|
16
|
-
yield mock
|
17
|
-
|
18
|
-
|
19
|
-
@pytest.fixture
|
20
|
-
def mock_client_session():
|
21
|
-
with patch('langchain_mcp_tools.langchain_mcp_tools.ClientSession') as mock:
|
22
|
-
session = AsyncMock()
|
23
|
-
# Mock the list_tools response
|
24
|
-
session.list_tools.return_value = MagicMock(
|
25
|
-
tools=[
|
26
|
-
MagicMock(
|
27
|
-
name="tool1",
|
28
|
-
description="Test tool",
|
29
|
-
inputSchema={"type": "object", "properties": {}}
|
30
|
-
)
|
31
|
-
]
|
32
|
-
)
|
33
|
-
mock.return_value.__aenter__.return_value = session
|
34
|
-
yield mock
|
35
|
-
|
36
|
-
|
37
|
-
@pytest.mark.asyncio
|
38
|
-
async def test_convert_mcp_to_langchain_tools_empty():
|
39
|
-
server_configs = {}
|
40
|
-
tools, cleanup = await convert_mcp_to_langchain_tools(server_configs)
|
41
|
-
assert isinstance(tools, list)
|
42
|
-
assert len(tools) == 0
|
43
|
-
await cleanup()
|
44
|
-
|
45
|
-
|
46
|
-
"""
|
47
|
-
@pytest.mark.asyncio
|
48
|
-
async def test_convert_mcp_to_langchain_tools_invalid_config():
|
49
|
-
server_configs = {"invalid": {"command": "nonexistent"}}
|
50
|
-
with pytest.raises(Exception):
|
51
|
-
await convert_mcp_to_langchain_tools(server_configs)
|
52
|
-
"""
|
53
|
-
|
54
|
-
|
55
|
-
"""
|
56
|
-
@pytest.mark.asyncio
|
57
|
-
async def test_convert_single_mcp_success(
|
58
|
-
mock_stdio_client,
|
59
|
-
mock_client_session
|
60
|
-
):
|
61
|
-
# Test data
|
62
|
-
server_name = "test_server"
|
63
|
-
server_config = {
|
64
|
-
"command": "test_command",
|
65
|
-
"args": ["--test"],
|
66
|
-
"env": {"TEST_ENV": "value"}
|
67
|
-
}
|
68
|
-
langchain_tools = []
|
69
|
-
ready_event = asyncio.Event()
|
70
|
-
cleanup_event = asyncio.Event()
|
71
|
-
|
72
|
-
# Create task
|
73
|
-
task = asyncio.create_task(
|
74
|
-
convert_single_mcp_to_langchain_tools(
|
75
|
-
server_name,
|
76
|
-
server_config,
|
77
|
-
langchain_tools,
|
78
|
-
ready_event,
|
79
|
-
cleanup_event
|
80
|
-
)
|
81
|
-
)
|
82
|
-
|
83
|
-
# Wait for ready event
|
84
|
-
await asyncio.wait_for(ready_event.wait(), timeout=1.0)
|
85
|
-
|
86
|
-
# Verify tools were created
|
87
|
-
assert len(langchain_tools) == 1
|
88
|
-
assert isinstance(langchain_tools[0], BaseTool)
|
89
|
-
assert langchain_tools[0].name == "tool1"
|
90
|
-
|
91
|
-
# Trigger cleanup
|
92
|
-
cleanup_event.set()
|
93
|
-
await task
|
94
|
-
"""
|
95
|
-
|
96
|
-
|
97
|
-
@pytest.mark.asyncio
|
98
|
-
async def test_convert_mcp_to_langchain_tools_multiple_servers(
|
99
|
-
mock_stdio_client,
|
100
|
-
mock_client_session
|
101
|
-
):
|
102
|
-
server_configs = {
|
103
|
-
"server1": {"command": "cmd1", "args": []},
|
104
|
-
"server2": {"command": "cmd2", "args": []}
|
105
|
-
}
|
106
|
-
|
107
|
-
tools, cleanup = await convert_mcp_to_langchain_tools(server_configs)
|
108
|
-
|
109
|
-
# Verify correct number of tools created
|
110
|
-
assert len(tools) == 2 # One tool per server
|
111
|
-
assert all(isinstance(tool, BaseTool) for tool in tools)
|
112
|
-
|
113
|
-
# Test cleanup
|
114
|
-
await cleanup()
|
115
|
-
|
116
|
-
|
117
|
-
"""
|
118
|
-
@pytest.mark.asyncio
|
119
|
-
async def test_tool_execution(mock_stdio_client, mock_client_session):
|
120
|
-
server_configs = {
|
121
|
-
"test_server": {"command": "test", "args": []}
|
122
|
-
}
|
123
|
-
|
124
|
-
# Mock the tool execution response
|
125
|
-
session = mock_client_session.return_value.__aenter__.return_value
|
126
|
-
session.call_tool.return_value = MagicMock(
|
127
|
-
isError=False,
|
128
|
-
content={"result": "success"}
|
129
|
-
)
|
130
|
-
|
131
|
-
tools, cleanup = await convert_mcp_to_langchain_tools(server_configs)
|
132
|
-
|
133
|
-
# Test tool execution
|
134
|
-
result = await tools[0]._arun(test_param="value")
|
135
|
-
assert result == {"result": "success"}
|
136
|
-
|
137
|
-
# Verify tool was called with correct parameters
|
138
|
-
session.call_tool.assert_called_once_with("tool1", {"test_param": "value"})
|
139
|
-
|
140
|
-
await cleanup()
|
141
|
-
"""
|
142
|
-
|
143
|
-
|
144
|
-
@pytest.mark.asyncio
|
145
|
-
async def test_tool_execution_error(mock_stdio_client, mock_client_session):
|
146
|
-
server_configs = {
|
147
|
-
"test_server": {"command": "test", "args": []}
|
148
|
-
}
|
149
|
-
|
150
|
-
# Mock error response
|
151
|
-
session = mock_client_session.return_value.__aenter__.return_value
|
152
|
-
session.call_tool.return_value = MagicMock(
|
153
|
-
isError=True,
|
154
|
-
content="Error message"
|
155
|
-
)
|
156
|
-
|
157
|
-
tools, cleanup = await convert_mcp_to_langchain_tools(server_configs)
|
158
|
-
|
159
|
-
# Test tool execution error
|
160
|
-
with pytest.raises(Exception):
|
161
|
-
await tools[0]._arun(test_param="value")
|
162
|
-
|
163
|
-
await cleanup()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|