langroid 0.53.0__py3-none-any.whl → 0.53.1__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.
@@ -1,10 +1,22 @@
1
1
  from .decorators import mcp_tool
2
- from .fastmcp_client import FastMCPClient, make_mcp_tool_sync, make_mcp_tool
2
+ from .fastmcp_client import (
3
+ FastMCPClient,
4
+ get_langroid_tool,
5
+ get_langroid_tool_async,
6
+ get_langroid_tools,
7
+ get_langroid_tools_async,
8
+ get_mcp_tool_async,
9
+ get_mcp_tools_async,
10
+ )
3
11
 
4
12
 
5
13
  __all__ = [
6
14
  "mcp_tool",
7
15
  "FastMCPClient",
8
- "make_mcp_tool_sync",
9
- "make_mcp_tool",
16
+ "get_langroid_tool",
17
+ "get_langroid_tool_async",
18
+ "get_langroid_tools",
19
+ "get_langroid_tools_async",
20
+ "get_mcp_tool_async",
21
+ "get_mcp_tools_async",
10
22
  ]
@@ -1,7 +1,7 @@
1
1
  from typing import Callable, Type
2
2
 
3
3
  from langroid.agent.tool_message import ToolMessage
4
- from langroid.agent.tools.mcp.fastmcp_client import make_mcp_tool_sync
4
+ from langroid.agent.tools.mcp.fastmcp_client import get_langroid_tool
5
5
 
6
6
 
7
7
  def mcp_tool(
@@ -18,7 +18,7 @@ def mcp_tool(
18
18
 
19
19
  def decorator(user_cls: Type[ToolMessage]) -> Type[ToolMessage]:
20
20
  # build the “real” ToolMessage subclass for this server/tool
21
- RealTool: Type[ToolMessage] = make_mcp_tool_sync(server, tool_name)
21
+ RealTool: Type[ToolMessage] = get_langroid_tool(server, tool_name)
22
22
 
23
23
  # copy user‐defined methods / attributes onto RealTool
24
24
  for name, attr in user_cls.__dict__.items():
@@ -113,11 +113,14 @@ class FastMCPClient:
113
113
  # Default fallback
114
114
  return Any, Field(default=default, description=desc)
115
115
 
116
- async def make_tool(self, tool_name: str) -> Type[ToolMessage]:
117
- """Create a Langroid ToolMessage subclass for the given tool name."""
116
+ async def get_langroid_tool(self, tool_name: str) -> Type[ToolMessage]:
117
+ """
118
+ Create a Langroid ToolMessage subclass from the MCP Tool
119
+ with the given `tool_name`.
120
+ """
118
121
  if not self.client:
119
122
  raise RuntimeError("Client not initialized. Use async with FastMCPClient.")
120
- target = await self.find_mcp_tool(tool_name)
123
+ target = await self.get_mcp_tool_async(tool_name)
121
124
  if target is None:
122
125
  raise ValueError(f"No tool named {tool_name}")
123
126
  props = target.inputSchema.get("properties", {})
@@ -167,7 +170,7 @@ class FastMCPClient:
167
170
 
168
171
  return tool_model
169
172
 
170
- async def get_tools(self) -> List[Type[ToolMessage]]:
173
+ async def get_langroid_tools(self) -> List[Type[ToolMessage]]:
171
174
  """
172
175
  Get all available tools as Langroid ToolMessage classes,
173
176
  handling nested schemas, with `handle_async` methods
@@ -177,11 +180,12 @@ class FastMCPClient:
177
180
  resp = await self.client.list_tools()
178
181
  tools: List[Type[ToolMessage]] = []
179
182
  for t in resp:
180
- tools.append(await self.make_tool(t.name))
183
+ tools.append(await self.get_langroid_tool(t.name))
181
184
  return tools
182
185
 
183
- async def find_mcp_tool(self, name: str) -> Optional[Tool]:
184
- """Find the MCP Tool matching `name`, or None if missing.
186
+ async def get_mcp_tool_async(self, name: str) -> Optional[Tool]:
187
+ """Find the "original" MCP Tool (i.e. of type mcp.types.Tool) on the server
188
+ matching `name`, or None if missing.
185
189
 
186
190
  Args:
187
191
  name: Name of the tool to look up.
@@ -240,10 +244,46 @@ class FastMCPClient:
240
244
  return self._convert_tool_result(tool_name, result)
241
245
 
242
246
 
243
- async def make_mcp_tool(server: str, tool_name: str) -> Type[ToolMessage]:
247
+ async def get_langroid_tool_async(
248
+ server: str | ClientTransport,
249
+ tool_name: str,
250
+ ) -> Type[ToolMessage]:
251
+ async with FastMCPClient(server) as client:
252
+ return await client.get_langroid_tool(tool_name)
253
+
254
+
255
+ def get_langroid_tool(
256
+ server: str | ClientTransport,
257
+ tool_name: str,
258
+ ) -> Type[ToolMessage]:
259
+ return asyncio.run(get_langroid_tool_async(server, tool_name))
260
+
261
+
262
+ async def get_langroid_tools_async(
263
+ server: str | ClientTransport,
264
+ ) -> List[Type[ToolMessage]]:
244
265
  async with FastMCPClient(server) as client:
245
- return await client.make_tool(tool_name)
266
+ return await client.get_langroid_tools()
246
267
 
247
268
 
248
- def make_mcp_tool_sync(server: str, tool_name: str) -> Type[ToolMessage]:
249
- return asyncio.run(make_mcp_tool(server, tool_name))
269
+ def get_langroid_tools(
270
+ server: str | ClientTransport,
271
+ ) -> List[Type[ToolMessage]]:
272
+ return asyncio.run(get_langroid_tools_async(server))
273
+
274
+
275
+ async def get_mcp_tool_async(
276
+ server: str | ClientTransport,
277
+ name: str,
278
+ ) -> Optional[Tool]:
279
+ async with FastMCPClient(server) as client:
280
+ return await client.get_mcp_tool_async(name)
281
+
282
+
283
+ async def get_mcp_tools_async(
284
+ server: str | ClientTransport,
285
+ ) -> List[Tool]:
286
+ async with FastMCPClient(server) as client:
287
+ if not client.client:
288
+ raise RuntimeError("Client not initialized. Use async with FastMCPClient.")
289
+ return await client.client.list_tools()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langroid
3
- Version: 0.53.0
3
+ Version: 0.53.1
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  Author-email: Prasad Chalasani <pchalasani@gmail.com>
6
6
  License: MIT
@@ -54,9 +54,9 @@ langroid/agent/tools/retrieval_tool.py,sha256=zcAV20PP_6VzSd-UE-IJcabaBseFL_QNz5
54
54
  langroid/agent/tools/rewind_tool.py,sha256=XAXL3BpNhCmBGYq_qi_sZfHJuIw7NY2jp4wnojJ7WRs,5606
55
55
  langroid/agent/tools/segment_extract_tool.py,sha256=__srZ_VGYLVOdPrITUM8S0HpmX4q7r5FHWMDdHdEv8w,1440
56
56
  langroid/agent/tools/tavily_search_tool.py,sha256=soI-j0HdgVQLf09wRQScaEK4b5RpAX9C4cwOivRFWWI,1903
57
- langroid/agent/tools/mcp/__init__.py,sha256=aMW4cRepRbE44iCGQu_fQF623bN8Q1HHBbRMGaO22kY,210
58
- langroid/agent/tools/mcp/decorators.py,sha256=zyV8iYq3dg3taHEkaC5aNncyb4UdNBp-i1tRhMOFkd4,1147
59
- langroid/agent/tools/mcp/fastmcp_client.py,sha256=goj7GSbez28cFaa-KmQRavw7MY_hHUCYhKP0fUZLDms,9548
57
+ langroid/agent/tools/mcp/__init__.py,sha256=cQb3gYxXk0YZ23QCqbVNMbMeCeWCJj6w3gqGnvyqv7w,459
58
+ langroid/agent/tools/mcp/decorators.py,sha256=mWnlTjyI9PMNi750PWzC_2B6V5K_XdxH0Co9kE2yAj0,1145
59
+ langroid/agent/tools/mcp/fastmcp_client.py,sha256=KUe73yqyKMTT7PxZfUaC0x23aRai0O09bbuyhHZfVo0,10630
60
60
  langroid/cachedb/__init__.py,sha256=G2KyNnk3Qkhv7OKyxTOnpsxfDycx3NY0O_wXkJlalNY,96
61
61
  langroid/cachedb/base.py,sha256=ztVjB1DtN6pLCujCWnR6xruHxwVj3XkYniRTYAKKqk0,1354
62
62
  langroid/cachedb/redis_cachedb.py,sha256=7kgnbf4b5CKsCrlL97mHWKvdvlLt8zgn7lc528jEpiE,5141
@@ -132,7 +132,7 @@ langroid/vector_store/pineconedb.py,sha256=otxXZNaBKb9f_H75HTaU3lMHiaR2NUp5MqwLZ
132
132
  langroid/vector_store/postgres.py,sha256=wHPtIi2qM4fhO4pMQr95pz1ZCe7dTb2hxl4VYspGZoA,16104
133
133
  langroid/vector_store/qdrantdb.py,sha256=O6dSBoDZ0jzfeVBd7LLvsXu083xs2fxXtPa9gGX3JX4,18443
134
134
  langroid/vector_store/weaviatedb.py,sha256=Yn8pg139gOy3zkaPfoTbMXEEBCiLiYa1MU5d_3UA1K4,11847
135
- langroid-0.53.0.dist-info/METADATA,sha256=JohvBH6oCb3ki2nsiIcPT0IiNmmn0dM2eNjQ9lsLn5E,63549
136
- langroid-0.53.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
137
- langroid-0.53.0.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
138
- langroid-0.53.0.dist-info/RECORD,,
135
+ langroid-0.53.1.dist-info/METADATA,sha256=A36mOdb9KvdWGTTWAxCzr0jLyLU4IGoXUk8bO7CmCnc,63549
136
+ langroid-0.53.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
137
+ langroid-0.53.1.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
138
+ langroid-0.53.1.dist-info/RECORD,,