langchain-mcp-tools 0.1.5__py3-none-any.whl → 0.1.7__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.
@@ -28,7 +28,7 @@ try:
28
28
  from mcp.client.stdio import stdio_client
29
29
  import mcp.types as mcp_types
30
30
  from pydantic import BaseModel
31
- from pympler import asizeof
31
+ # from pydantic_core import to_json
32
32
  except ImportError as e:
33
33
  print(f'\nError: Required package not found: {e}')
34
34
  print('Please ensure all required packages are installed\n')
@@ -165,8 +165,8 @@ async def get_mcp_server_tools(
165
165
  Asynchronously executes the tool with given arguments.
166
166
  Logs input/output and handles errors.
167
167
  """
168
- logger.info(f'MCP tool "{server_name}"/"{tool.name}"'
169
- f' received input: {kwargs}')
168
+ logger.info(f'MCP tool "{server_name}"/"{tool.name}" '
169
+ f'received input: {kwargs}')
170
170
 
171
171
  try:
172
172
  result = await session.call_tool(self.name, kwargs)
@@ -186,7 +186,12 @@ async def get_mcp_server_tools(
186
186
  for item in result.content
187
187
  if isinstance(item, mcp_types.TextContent)
188
188
  )
189
- result_content_text = result_content_text or ''
189
+ # text_items = [
190
+ # item
191
+ # for item in result.content
192
+ # if isinstance(item, mcp_types.TextContent)
193
+ # ]
194
+ # result_content_text =to_json(text_items).decode()
190
195
 
191
196
  except KeyError as e:
192
197
  result_content_text = (
@@ -194,14 +199,25 @@ async def get_mcp_server_tools(
194
199
  f'contents: {repr(result.content)}'
195
200
  )
196
201
 
197
- # Log result size for monitoring
198
- size = asizeof.asizeof(result_content_text)
202
+ # Log rough result size for monitoring
203
+ size = len(result_content_text.encode())
199
204
  logger.info(f'MCP tool "{server_name}"/"{tool.name}" '
200
205
  f'received result (size: {size})')
201
206
 
207
+ # If no text content, return a clear message
208
+ # describing the situation.
209
+ result_content_text = (
210
+ result_content_text or
211
+ 'No text content available in response'
212
+ )
213
+
202
214
  return result_content_text
203
215
 
204
216
  except Exception as e:
217
+ logger.warn(
218
+ f'MCP tool "{server_name}"/"{tool.name}" '
219
+ f'caused error: {str(e)}'
220
+ )
205
221
  if self.handle_tool_error:
206
222
  return f'Error executing MCP tool: {str(e)}'
207
223
  raise
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: langchain-mcp-tools
3
- Version: 0.1.5
3
+ Version: 0.1.7
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,15 +10,15 @@ 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: langchain-anthropic>=0.3.1
14
- Requires-Dist: langchain-groq>=0.2.3
15
- Requires-Dist: langchain-openai>=0.3.0
16
- Requires-Dist: langgraph>=0.2.62
17
13
  Requires-Dist: mcp>=1.2.0
18
14
  Requires-Dist: pyjson5>=1.6.8
19
- Requires-Dist: pympler>=1.1
20
15
  Requires-Dist: python-dotenv>=1.0.1
21
16
  Provides-Extra: dev
17
+ Requires-Dist: dotenv>=0.9.9; extra == "dev"
18
+ Requires-Dist: langchain-anthropic>=0.3.1; extra == "dev"
19
+ Requires-Dist: langchain-groq>=0.2.3; extra == "dev"
20
+ Requires-Dist: langchain-openai>=0.3.0; extra == "dev"
21
+ Requires-Dist: langgraph>=0.2.62; extra == "dev"
22
22
  Requires-Dist: pytest>=8.3.4; extra == "dev"
23
23
  Requires-Dist: pytest-asyncio>=0.25.2; extra == "dev"
24
24
 
@@ -35,21 +35,21 @@ 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 450 functional components available as MCP servers:
38
+ Over 800 functional components available as MCP servers:
39
39
 
40
40
  - [Glama’s list of Open-Source MCP servers](https://glama.ai/mcp/servers)
41
41
  - [Smithery: MCP Server Registry](https://smithery.ai/)
42
42
  - [awesome-mcp-servers](https://github.com/hideya/awesome-mcp-servers#Server-Implementations)
43
43
  - [MCP Get Started/Example Servers](https://modelcontextprotocol.io/examples)
44
44
 
45
- The goal of this utility is to make these 450+ MCP servers readily accessible from LangChain.
45
+ The goal of this utility is to make these 800+ MCP servers readily accessible from LangChain.
46
46
 
47
47
  It contains a utility function `convert_mcp_to_langchain_tools()`.
48
48
  This async function handles parallel initialization of specified multiple MCP servers
49
49
  and converts their available tools into a list of LangChain-compatible tools.
50
50
 
51
51
  For detailed information on how to use this library, please refer to the following document:
52
- - ["Supercharging LangChain: Integrating 450+ MCP with ReAct"](https://medium.com/@h1deya/supercharging-langchain-integrating-450-mcp-with-react-d4e467cbf41a)
52
+ - ["Supercharging LangChain: Integrating 800+ MCP with ReAct"](https://medium.com/@h1deya/supercharging-langchain-integrating-800-mcp-with-react-d4e467cbf41a)
53
53
 
54
54
  A typescript equivalent of this utility is available
55
55
  [here](https://www.npmjs.com/package/@h1deya/langchain-mcp-tools)
@@ -120,7 +120,7 @@ For hands-on experimentation with MCP server integration,
120
120
  try [this LangChain application built with the utility](https://github.com/hideya/mcp-client-langchain-py)
121
121
 
122
122
  For detailed information on how to use this library, please refer to the following document:
123
- ["Supercharging LangChain: Integrating 450+ MCP with ReAct"](https://medium.com/@h1deya/supercharging-langchain-integrating-450-mcp-with-react-d4e467cbf41a)
123
+ ["Supercharging LangChain: Integrating 800+ MCP with ReAct"](https://medium.com/@h1deya/supercharging-langchain-integrating-800-mcp-with-react-d4e467cbf41a)
124
124
 
125
125
  ## Limitations
126
126
 
@@ -0,0 +1,8 @@
1
+ langchain_mcp_tools/__init__.py,sha256=Xtv2VphhrWB_KlxTIofHZqtCIGtNEl0MxugnrNXTERA,94
2
+ langchain_mcp_tools/langchain_mcp_tools.py,sha256=WY1ckLyIMbRIVhsECEFdAY6DnZB2Q3BLH-Nrb727M-o,11699
3
+ langchain_mcp_tools/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ langchain_mcp_tools-0.1.7.dist-info/LICENSE,sha256=CRC91e8v116gCpnp7h49oIa6_zjhxqnHFTREeoZFJwA,1072
5
+ langchain_mcp_tools-0.1.7.dist-info/METADATA,sha256=eGSPp9YQFZ9XWjssxhBqlVgw4gXyOmHvs3B-6dB1Lwc,5035
6
+ langchain_mcp_tools-0.1.7.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
7
+ langchain_mcp_tools-0.1.7.dist-info/top_level.txt,sha256=aR_9V2A1Yt-Bca60KmndmGLUWb2wiM5IOG-Gkaf1dxY,20
8
+ langchain_mcp_tools-0.1.7.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=UNvQSkj2MPV4aF1HFVLjE5AncXqw6eRLwqMuIQgefoc,10926
3
- langchain_mcp_tools/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- langchain_mcp_tools-0.1.5.dist-info/LICENSE,sha256=CRC91e8v116gCpnp7h49oIa6_zjhxqnHFTREeoZFJwA,1072
5
- langchain_mcp_tools-0.1.5.dist-info/METADATA,sha256=mlv50j7vIG3dtlmwP7qX2giU4G_T-PA5RYBWUitF-80,4954
6
- langchain_mcp_tools-0.1.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
7
- langchain_mcp_tools-0.1.5.dist-info/top_level.txt,sha256=aR_9V2A1Yt-Bca60KmndmGLUWb2wiM5IOG-Gkaf1dxY,20
8
- langchain_mcp_tools-0.1.5.dist-info/RECORD,,