praisonaiagents 0.0.66__py3-none-any.whl → 0.0.67__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.
@@ -0,0 +1,6 @@
1
+ """
2
+ Model Context Protocol (MCP) integration for PraisonAI Agents.
3
+ """
4
+ from .mcp import MCP
5
+
6
+ __all__ = ["MCP"]
@@ -4,7 +4,9 @@ import queue
4
4
  import time
5
5
  import inspect
6
6
  import shlex
7
- from typing import Dict, Any, List, Optional, Callable, Iterable, Union
7
+ import logging
8
+ import os
9
+ from typing import Any, List, Optional, Callable, Iterable, Union
8
10
  from functools import wraps, partial
9
11
 
10
12
  from mcp import ClientSession, StdioServerParameters
@@ -128,7 +130,7 @@ class MCP:
128
130
  ```
129
131
  """
130
132
 
131
- def __init__(self, command_or_string=None, args=None, *, command=None, **kwargs):
133
+ def __init__(self, command_or_string=None, args=None, *, command=None, timeout=60, debug=False, **kwargs):
132
134
  """
133
135
  Initialize the MCP connection and get tools.
134
136
 
@@ -136,8 +138,11 @@ class MCP:
136
138
  command_or_string: Either:
137
139
  - The command to run the MCP server (e.g., Python path)
138
140
  - A complete command string (e.g., "/path/to/python /path/to/app.py")
141
+ - For NPX: 'npx' command with args for smithery tools
139
142
  args: Arguments to pass to the command (when command_or_string is the command)
140
143
  command: Alternative parameter name for backward compatibility
144
+ timeout: Timeout in seconds for MCP server initialization and tool calls (default: 60)
145
+ debug: Enable debug logging for MCP operations (default: False)
141
146
  **kwargs: Additional parameters for StdioServerParameters
142
147
  """
143
148
  # Handle backward compatibility with named parameter 'command'
@@ -168,9 +173,24 @@ class MCP:
168
173
  # Wait for initialization
169
174
  if not self.runner.initialized.wait(timeout=30):
170
175
  print("Warning: MCP initialization timed out")
176
+
177
+ # Store additional parameters
178
+ self.timeout = timeout
179
+ self.debug = debug
180
+
181
+ if debug:
182
+ logging.getLogger("mcp-wrapper").setLevel(logging.DEBUG)
183
+
184
+ # Automatically detect if this is an NPX command
185
+ self.is_npx = cmd == 'npx' or (isinstance(cmd, str) and os.path.basename(cmd) == 'npx')
171
186
 
172
- # Generate tool functions immediately and store them
173
- self._tools = self._generate_tool_functions()
187
+ # For NPX-based MCP servers, use a different approach
188
+ if self.is_npx:
189
+ self._function_declarations = []
190
+ self._initialize_npx_mcp_tools(cmd, arguments)
191
+ else:
192
+ # Generate tool functions immediately and store them
193
+ self._tools = self._generate_tool_functions()
174
194
 
175
195
  def _generate_tool_functions(self) -> List[Callable]:
176
196
  """
@@ -264,6 +284,27 @@ class MCP:
264
284
 
265
285
  return wrapper
266
286
 
287
+ def _initialize_npx_mcp_tools(self, cmd, arguments):
288
+ """Initialize the NPX MCP tools by extracting tool definitions."""
289
+ try:
290
+ # For NPX tools, we'll use the same approach as regular MCP tools
291
+ # but we need to handle the initialization differently
292
+ if self.debug:
293
+ logging.debug(f"Initializing NPX MCP tools with command: {cmd} {' '.join(arguments)}")
294
+
295
+ # Generate tool functions using the regular MCP approach
296
+ self._tools = self._generate_tool_functions()
297
+
298
+ if self.debug:
299
+ logging.debug(f"Generated {len(self._tools)} NPX MCP tools")
300
+
301
+ except Exception as e:
302
+ if self.debug:
303
+ logging.error(f"Failed to initialize NPX MCP tools: {e}")
304
+ raise RuntimeError(f"Failed to initialize NPX MCP tools: {e}")
305
+
306
+
307
+
267
308
  def __iter__(self) -> Iterable[Callable]:
268
309
  """
269
310
  Allow the MCP instance to be used directly as an iterable of tools.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: praisonaiagents
3
- Version: 0.0.66
3
+ Version: 0.0.67
4
4
  Summary: Praison AI agents for completing complex tasks with Self Reflection Agents
5
5
  Author: Mervin Praison
6
6
  Requires-Dist: pydantic
@@ -11,7 +11,8 @@ praisonaiagents/knowledge/chunking.py,sha256=FzoNY0q8MkvG4gADqk4JcRhmH3lcEHbRdon
11
11
  praisonaiagents/knowledge/knowledge.py,sha256=fQNREDiwdoisfIxJBLVkteXgq_8Gbypfc3UaZbxf5QY,13210
12
12
  praisonaiagents/llm/__init__.py,sha256=ttPQQJQq6Tah-0updoEXDZFKWtJAM93rBWRoIgxRWO8,689
13
13
  praisonaiagents/llm/llm.py,sha256=6QMRW47fgFozibzaqxa3dwxlD756rMLCRjL3eNsw8QQ,74088
14
- praisonaiagents/mcp/mcp.py,sha256=xvORgbsbsdaY_j3jKCP8BH3ERoKi_ZK8zM57mobC2Ac,10488
14
+ praisonaiagents/mcp/__init__.py,sha256=IkYdrAK1bDQDm_0t3Wjt63Zwv3_IJgqz84Wqz9GH2iQ,111
15
+ praisonaiagents/mcp/mcp.py,sha256=7EJo2Eyw89ePQzeKUzRZgW3E2ztLkMwQj2lCjFlzecQ,12281
15
16
  praisonaiagents/memory/memory.py,sha256=I8dOTkrl1i-GgQbDcrFOsSruzJ7MiI6Ys37DK27wrUs,35537
16
17
  praisonaiagents/process/__init__.py,sha256=lkYbL7Hn5a0ldvJtkdH23vfIIZLIcanK-65C0MwaorY,52
17
18
  praisonaiagents/process/process.py,sha256=HPw84OhnKQW3EyrDkpoQu0DcpxThbrzR2hWUgwQh9Pw,59955
@@ -38,7 +39,7 @@ praisonaiagents/tools/xml_tools.py,sha256=iYTMBEk5l3L3ryQ1fkUnNVYK-Nnua2Kx2S0dxN
38
39
  praisonaiagents/tools/yaml_tools.py,sha256=uogAZrhXV9O7xvspAtcTfpKSQYL2nlOTvCQXN94-G9A,14215
39
40
  praisonaiagents/tools/yfinance_tools.py,sha256=s2PBj_1v7oQnOobo2fDbQBACEHl61ftG4beG6Z979ZE,8529
40
41
  praisonaiagents/tools/train/data/generatecot.py,sha256=H6bNh-E2hqL5MW6kX3hqZ05g9ETKN2-kudSjiuU_SD8,19403
41
- praisonaiagents-0.0.66.dist-info/METADATA,sha256=mZDRbV3kjDru4ehwjOVkMLJAKZeYq79yZB_8VjQDzUA,830
42
- praisonaiagents-0.0.66.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
43
- praisonaiagents-0.0.66.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
44
- praisonaiagents-0.0.66.dist-info/RECORD,,
42
+ praisonaiagents-0.0.67.dist-info/METADATA,sha256=sGyO2OxLcuZGGmq-2WZHg9RIvSB1tLPFOUpEst8VeU0,830
43
+ praisonaiagents-0.0.67.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
44
+ praisonaiagents-0.0.67.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
45
+ praisonaiagents-0.0.67.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (76.1.0)
2
+ Generator: setuptools (78.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5