praisonaiagents 0.0.82__py3-none-any.whl → 0.0.84__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.
- praisonaiagents/mcp/mcp.py +8 -7
- praisonaiagents/mcp/mcp_sse.py +9 -5
- {praisonaiagents-0.0.82.dist-info → praisonaiagents-0.0.84.dist-info}/METADATA +3 -1
- {praisonaiagents-0.0.82.dist-info → praisonaiagents-0.0.84.dist-info}/RECORD +6 -6
- {praisonaiagents-0.0.82.dist-info → praisonaiagents-0.0.84.dist-info}/WHEEL +1 -1
- {praisonaiagents-0.0.82.dist-info → praisonaiagents-0.0.84.dist-info}/top_level.txt +0 -0
praisonaiagents/mcp/mcp.py
CHANGED
@@ -16,13 +16,14 @@ from mcp.client.stdio import stdio_client
|
|
16
16
|
class MCPToolRunner(threading.Thread):
|
17
17
|
"""A dedicated thread for running MCP operations."""
|
18
18
|
|
19
|
-
def __init__(self, server_params):
|
19
|
+
def __init__(self, server_params, timeout=60):
|
20
20
|
super().__init__(daemon=True)
|
21
21
|
self.server_params = server_params
|
22
22
|
self.queue = queue.Queue()
|
23
23
|
self.result_queue = queue.Queue()
|
24
24
|
self.initialized = threading.Event()
|
25
25
|
self.tools = []
|
26
|
+
self.timeout = timeout
|
26
27
|
self.start()
|
27
28
|
|
28
29
|
def run(self):
|
@@ -74,9 +75,9 @@ class MCPToolRunner(threading.Thread):
|
|
74
75
|
def call_tool(self, tool_name, arguments):
|
75
76
|
"""Call an MCP tool and wait for the result."""
|
76
77
|
if not self.initialized.is_set():
|
77
|
-
self.initialized.wait(timeout=
|
78
|
+
self.initialized.wait(timeout=self.timeout)
|
78
79
|
if not self.initialized.is_set():
|
79
|
-
return "Error: MCP initialization timed out"
|
80
|
+
return f"Error: MCP initialization timed out after {self.timeout} seconds"
|
80
81
|
|
81
82
|
# Put request in queue
|
82
83
|
self.queue.put((tool_name, arguments))
|
@@ -189,7 +190,7 @@ class MCP:
|
|
189
190
|
if isinstance(command_or_string, str) and re.match(r'^https?://', command_or_string):
|
190
191
|
# Import the SSE client implementation
|
191
192
|
from .mcp_sse import SSEMCPClient
|
192
|
-
self.sse_client = SSEMCPClient(command_or_string, debug=debug)
|
193
|
+
self.sse_client = SSEMCPClient(command_or_string, debug=debug, timeout=timeout)
|
193
194
|
self._tools = list(self.sse_client.tools)
|
194
195
|
self.is_sse = True
|
195
196
|
self.is_npx = False
|
@@ -216,11 +217,11 @@ class MCP:
|
|
216
217
|
args=arguments,
|
217
218
|
**kwargs
|
218
219
|
)
|
219
|
-
self.runner = MCPToolRunner(self.server_params)
|
220
|
+
self.runner = MCPToolRunner(self.server_params, timeout)
|
220
221
|
|
221
222
|
# Wait for initialization
|
222
|
-
if not self.runner.initialized.wait(timeout=
|
223
|
-
print("Warning: MCP initialization timed out")
|
223
|
+
if not self.runner.initialized.wait(timeout=self.timeout):
|
224
|
+
print(f"Warning: MCP initialization timed out after {self.timeout} seconds")
|
224
225
|
|
225
226
|
# Automatically detect if this is an NPX command
|
226
227
|
self.is_npx = cmd == 'npx' or (isinstance(cmd, str) and os.path.basename(cmd) == 'npx')
|
praisonaiagents/mcp/mcp_sse.py
CHANGED
@@ -31,7 +31,7 @@ def get_event_loop():
|
|
31
31
|
class SSEMCPTool:
|
32
32
|
"""A wrapper for an MCP tool that can be used with praisonaiagents."""
|
33
33
|
|
34
|
-
def __init__(self, name: str, description: str, session: ClientSession, input_schema: Optional[Dict[str, Any]] = None):
|
34
|
+
def __init__(self, name: str, description: str, session: ClientSession, input_schema: Optional[Dict[str, Any]] = None, timeout: int = 60):
|
35
35
|
self.name = name
|
36
36
|
self.__name__ = name # Required for Agent to recognize it as a tool
|
37
37
|
self.__qualname__ = name # Required for Agent to recognize it as a tool
|
@@ -39,6 +39,7 @@ class SSEMCPTool:
|
|
39
39
|
self.description = description
|
40
40
|
self.session = session
|
41
41
|
self.input_schema = input_schema or {}
|
42
|
+
self.timeout = timeout
|
42
43
|
|
43
44
|
# Create a signature based on input schema
|
44
45
|
params = []
|
@@ -66,7 +67,7 @@ class SSEMCPTool:
|
|
66
67
|
future = asyncio.run_coroutine_threadsafe(self._async_call(**kwargs), loop)
|
67
68
|
try:
|
68
69
|
# Wait for the result with a timeout
|
69
|
-
return future.result(timeout=
|
70
|
+
return future.result(timeout=self.timeout)
|
70
71
|
except Exception as e:
|
71
72
|
logger.error(f"Error calling tool {self.name}: {e}")
|
72
73
|
return f"Error: {str(e)}"
|
@@ -102,16 +103,18 @@ class SSEMCPTool:
|
|
102
103
|
class SSEMCPClient:
|
103
104
|
"""A client for connecting to an MCP server over SSE."""
|
104
105
|
|
105
|
-
def __init__(self, server_url: str, debug: bool = False):
|
106
|
+
def __init__(self, server_url: str, debug: bool = False, timeout: int = 60):
|
106
107
|
"""
|
107
108
|
Initialize an SSE MCP client.
|
108
109
|
|
109
110
|
Args:
|
110
111
|
server_url: The URL of the SSE MCP server
|
111
112
|
debug: Whether to enable debug logging
|
113
|
+
timeout: Timeout in seconds for operations (default: 60)
|
112
114
|
"""
|
113
115
|
self.server_url = server_url
|
114
116
|
self.debug = debug
|
117
|
+
self.timeout = timeout
|
115
118
|
self.session = None
|
116
119
|
self.tools = []
|
117
120
|
|
@@ -139,7 +142,7 @@ class SSEMCPClient:
|
|
139
142
|
|
140
143
|
# Run the initialization in the event loop
|
141
144
|
future = asyncio.run_coroutine_threadsafe(self._async_initialize(), loop)
|
142
|
-
self.tools = future.result(timeout=
|
145
|
+
self.tools = future.result(timeout=self.timeout)
|
143
146
|
|
144
147
|
async def _async_initialize(self):
|
145
148
|
"""Asynchronously initialize the connection and tools."""
|
@@ -169,7 +172,8 @@ class SSEMCPClient:
|
|
169
172
|
name=tool.name,
|
170
173
|
description=tool.description if hasattr(tool, 'description') else f"Call the {tool.name} tool",
|
171
174
|
session=self.session,
|
172
|
-
input_schema=input_schema
|
175
|
+
input_schema=input_schema,
|
176
|
+
timeout=self.timeout
|
173
177
|
)
|
174
178
|
tools.append(wrapper)
|
175
179
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: praisonaiagents
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.84
|
4
4
|
Summary: Praison AI agents for completing complex tasks with Self Reflection Agents
|
5
5
|
Author: Mervin Praison
|
6
6
|
Requires-Dist: pydantic
|
@@ -9,6 +9,8 @@ Requires-Dist: openai
|
|
9
9
|
Requires-Dist: mcp>=1.6.0
|
10
10
|
Provides-Extra: mcp
|
11
11
|
Requires-Dist: mcp>=1.6.0; extra == "mcp"
|
12
|
+
Requires-Dist: fastapi>=0.115.0; extra == "mcp"
|
13
|
+
Requires-Dist: uvicorn>=0.34.0; extra == "mcp"
|
12
14
|
Provides-Extra: memory
|
13
15
|
Requires-Dist: chromadb>=0.5.23; extra == "memory"
|
14
16
|
Provides-Extra: knowledge
|
@@ -12,8 +12,8 @@ praisonaiagents/knowledge/knowledge.py,sha256=Po0JZsgjYJrXdNSggmUGOWidZEF0f8xo4n
|
|
12
12
|
praisonaiagents/llm/__init__.py,sha256=ttPQQJQq6Tah-0updoEXDZFKWtJAM93rBWRoIgxRWO8,689
|
13
13
|
praisonaiagents/llm/llm.py,sha256=5SII0qUgaVbDTHdNfq4foV_vAjSwilz9Mw6p_S5LZfk,88393
|
14
14
|
praisonaiagents/mcp/__init__.py,sha256=ibbqe3_7XB7VrIcUcetkZiUZS1fTVvyMy_AqCSFG8qc,240
|
15
|
-
praisonaiagents/mcp/mcp.py,sha256=
|
16
|
-
praisonaiagents/mcp/mcp_sse.py,sha256=
|
15
|
+
praisonaiagents/mcp/mcp.py,sha256=foarT5IoCZ6V8P9AbnqnWQHKmshJoD24gf3OP4sD_IM,16419
|
16
|
+
praisonaiagents/mcp/mcp_sse.py,sha256=DLh3F_aoVRM1X-7hgIOWOw4FQ1nGmn9YNbQTesykzn4,6792
|
17
17
|
praisonaiagents/memory/memory.py,sha256=I8dOTkrl1i-GgQbDcrFOsSruzJ7MiI6Ys37DK27wrUs,35537
|
18
18
|
praisonaiagents/process/__init__.py,sha256=lkYbL7Hn5a0ldvJtkdH23vfIIZLIcanK-65C0MwaorY,52
|
19
19
|
praisonaiagents/process/process.py,sha256=HPw84OhnKQW3EyrDkpoQu0DcpxThbrzR2hWUgwQh9Pw,59955
|
@@ -40,7 +40,7 @@ praisonaiagents/tools/xml_tools.py,sha256=iYTMBEk5l3L3ryQ1fkUnNVYK-Nnua2Kx2S0dxN
|
|
40
40
|
praisonaiagents/tools/yaml_tools.py,sha256=uogAZrhXV9O7xvspAtcTfpKSQYL2nlOTvCQXN94-G9A,14215
|
41
41
|
praisonaiagents/tools/yfinance_tools.py,sha256=s2PBj_1v7oQnOobo2fDbQBACEHl61ftG4beG6Z979ZE,8529
|
42
42
|
praisonaiagents/tools/train/data/generatecot.py,sha256=H6bNh-E2hqL5MW6kX3hqZ05g9ETKN2-kudSjiuU_SD8,19403
|
43
|
-
praisonaiagents-0.0.
|
44
|
-
praisonaiagents-0.0.
|
45
|
-
praisonaiagents-0.0.
|
46
|
-
praisonaiagents-0.0.
|
43
|
+
praisonaiagents-0.0.84.dist-info/METADATA,sha256=4JjpgU3oHjBZpNViGQJbjv1J0vKseHp96wo13sT-jwk,1244
|
44
|
+
praisonaiagents-0.0.84.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
45
|
+
praisonaiagents-0.0.84.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
|
46
|
+
praisonaiagents-0.0.84.dist-info/RECORD,,
|
File without changes
|