camel-ai 0.2.64__py3-none-any.whl → 0.2.66__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.
Potentially problematic release.
This version of camel-ai might be problematic. Click here for more details.
- camel/__init__.py +1 -1
- camel/agents/chat_agent.py +19 -7
- camel/agents/mcp_agent.py +1 -5
- camel/benchmarks/mock_website/README.md +96 -0
- camel/benchmarks/mock_website/mock_web.py +299 -0
- camel/benchmarks/mock_website/requirements.txt +3 -0
- camel/benchmarks/mock_website/shopping_mall/app.py +465 -0
- camel/benchmarks/mock_website/task.json +104 -0
- camel/datasets/models.py +1 -1
- camel/datasets/static_dataset.py +6 -0
- camel/models/openai_model.py +1 -0
- camel/societies/workforce/role_playing_worker.py +9 -1
- camel/societies/workforce/single_agent_worker.py +8 -1
- camel/societies/workforce/workforce.py +13 -4
- camel/tasks/task.py +69 -1
- camel/toolkits/async_browser_toolkit.py +97 -54
- camel/toolkits/browser_toolkit.py +65 -18
- camel/toolkits/function_tool.py +81 -9
- camel/toolkits/mcp_toolkit.py +70 -19
- camel/toolkits/playwright_mcp_toolkit.py +16 -3
- camel/toolkits/task_planning_toolkit.py +134 -0
- camel/types/enums.py +5 -1
- camel/utils/mcp_client.py +1 -35
- {camel_ai-0.2.64.dist-info → camel_ai-0.2.66.dist-info}/METADATA +4 -12
- {camel_ai-0.2.64.dist-info → camel_ai-0.2.66.dist-info}/RECORD +27 -21
- {camel_ai-0.2.64.dist-info → camel_ai-0.2.66.dist-info}/WHEEL +0 -0
- {camel_ai-0.2.64.dist-info → camel_ai-0.2.66.dist-info}/licenses/LICENSE +0 -0
camel/toolkits/mcp_toolkit.py
CHANGED
|
@@ -98,8 +98,6 @@ class MCPToolkit(BaseToolkit):
|
|
|
98
98
|
timeout (Optional[float], optional): Timeout for connection attempts
|
|
99
99
|
in seconds. This timeout applies to individual client connections.
|
|
100
100
|
(default: :obj:`None`)
|
|
101
|
-
strict (Optional[bool], optional): Flag to indicate strict mode.
|
|
102
|
-
(default: :obj:`False`)
|
|
103
101
|
|
|
104
102
|
Note:
|
|
105
103
|
At least one of :obj:`clients`, :obj:`config_path`, or
|
|
@@ -148,7 +146,6 @@ class MCPToolkit(BaseToolkit):
|
|
|
148
146
|
config_path: Optional[str] = None,
|
|
149
147
|
config_dict: Optional[Dict[str, Any]] = None,
|
|
150
148
|
timeout: Optional[float] = None,
|
|
151
|
-
strict: Optional[bool] = False,
|
|
152
149
|
):
|
|
153
150
|
# Call parent constructor first
|
|
154
151
|
super().__init__(timeout=timeout)
|
|
@@ -165,7 +162,6 @@ class MCPToolkit(BaseToolkit):
|
|
|
165
162
|
raise ValueError(error_msg)
|
|
166
163
|
|
|
167
164
|
self.clients: List[MCPClient] = clients or []
|
|
168
|
-
self.strict = strict # Store strict parameter
|
|
169
165
|
self._is_connected = False
|
|
170
166
|
self._exit_stack: Optional[AsyncExitStack] = None
|
|
171
167
|
|
|
@@ -313,7 +309,6 @@ class MCPToolkit(BaseToolkit):
|
|
|
313
309
|
config_path: Optional[str] = None,
|
|
314
310
|
config_dict: Optional[Dict[str, Any]] = None,
|
|
315
311
|
timeout: Optional[float] = None,
|
|
316
|
-
strict: Optional[bool] = False,
|
|
317
312
|
) -> "MCPToolkit":
|
|
318
313
|
r"""Factory method that creates and connects to all MCP servers.
|
|
319
314
|
|
|
@@ -331,8 +326,6 @@ class MCPToolkit(BaseToolkit):
|
|
|
331
326
|
config file. (default: :obj:`None`)
|
|
332
327
|
timeout (Optional[float], optional): Timeout for connection
|
|
333
328
|
attempts in seconds. (default: :obj:`None`)
|
|
334
|
-
strict (Optional[bool], optional): Flag to indicate strict mode.
|
|
335
|
-
(default: :obj:`False`)
|
|
336
329
|
|
|
337
330
|
Returns:
|
|
338
331
|
MCPToolkit: A fully initialized and connected :obj:`MCPToolkit`
|
|
@@ -361,7 +354,6 @@ class MCPToolkit(BaseToolkit):
|
|
|
361
354
|
config_path=config_path,
|
|
362
355
|
config_dict=config_dict,
|
|
363
356
|
timeout=timeout,
|
|
364
|
-
strict=strict,
|
|
365
357
|
)
|
|
366
358
|
try:
|
|
367
359
|
await toolkit.connect()
|
|
@@ -381,11 +373,10 @@ class MCPToolkit(BaseToolkit):
|
|
|
381
373
|
config_path: Optional[str] = None,
|
|
382
374
|
config_dict: Optional[Dict[str, Any]] = None,
|
|
383
375
|
timeout: Optional[float] = None,
|
|
384
|
-
strict: Optional[bool] = False,
|
|
385
376
|
) -> "MCPToolkit":
|
|
386
377
|
r"""Synchronously create and connect to all MCP servers."""
|
|
387
378
|
return run_async(cls.create)(
|
|
388
|
-
clients, config_path, config_dict, timeout
|
|
379
|
+
clients, config_path, config_dict, timeout
|
|
389
380
|
)
|
|
390
381
|
|
|
391
382
|
def _load_clients_from_config(self, config_path: str) -> List[MCPClient]:
|
|
@@ -442,12 +433,10 @@ class MCPToolkit(BaseToolkit):
|
|
|
442
433
|
|
|
443
434
|
try:
|
|
444
435
|
# Use the new mcp_client factory function
|
|
445
|
-
# Pass timeout
|
|
436
|
+
# Pass timeout from toolkit if available
|
|
446
437
|
kwargs = {}
|
|
447
438
|
if hasattr(self, "timeout") and self.timeout is not None:
|
|
448
439
|
kwargs["timeout"] = self.timeout
|
|
449
|
-
if hasattr(self, "strict") and self.strict is not None:
|
|
450
|
-
kwargs["strict"] = self.strict
|
|
451
440
|
|
|
452
441
|
client = create_mcp_client(cfg, **kwargs)
|
|
453
442
|
return client
|
|
@@ -455,17 +444,68 @@ class MCPToolkit(BaseToolkit):
|
|
|
455
444
|
error_msg = f"Failed to create client for server '{name}': {e}"
|
|
456
445
|
raise ValueError(error_msg) from e
|
|
457
446
|
|
|
447
|
+
def _ensure_strict_tool_schema(self, tool: FunctionTool) -> FunctionTool:
|
|
448
|
+
r"""Ensure a tool has a strict schema compatible with OpenAI's
|
|
449
|
+
requirements.
|
|
450
|
+
|
|
451
|
+
Args:
|
|
452
|
+
tool (FunctionTool): The tool to check and update if necessary.
|
|
453
|
+
|
|
454
|
+
Returns:
|
|
455
|
+
FunctionTool: The tool with a strict schema.
|
|
456
|
+
"""
|
|
457
|
+
try:
|
|
458
|
+
schema = tool.get_openai_tool_schema()
|
|
459
|
+
|
|
460
|
+
# Check if the tool already has strict mode enabled
|
|
461
|
+
if schema.get("function", {}).get("strict") is True:
|
|
462
|
+
return tool
|
|
463
|
+
|
|
464
|
+
# Update the schema to be strict
|
|
465
|
+
if "function" in schema:
|
|
466
|
+
schema["function"]["strict"] = True
|
|
467
|
+
|
|
468
|
+
# Ensure parameters have proper strict mode configuration
|
|
469
|
+
parameters = schema["function"].get("parameters", {})
|
|
470
|
+
if parameters:
|
|
471
|
+
# Ensure additionalProperties is false
|
|
472
|
+
parameters["additionalProperties"] = False
|
|
473
|
+
|
|
474
|
+
# Process properties to handle optional fields
|
|
475
|
+
properties = parameters.get("properties", {})
|
|
476
|
+
parameters["required"] = list(properties.keys())
|
|
477
|
+
|
|
478
|
+
# Apply the sanitization function from function_tool
|
|
479
|
+
from camel.toolkits.function_tool import (
|
|
480
|
+
sanitize_and_enforce_required,
|
|
481
|
+
)
|
|
482
|
+
|
|
483
|
+
schema = sanitize_and_enforce_required(schema)
|
|
484
|
+
|
|
485
|
+
tool.set_openai_tool_schema(schema)
|
|
486
|
+
logger.debug(
|
|
487
|
+
f"Updated tool '{tool.get_function_name()}' to strict mode"
|
|
488
|
+
)
|
|
489
|
+
|
|
490
|
+
except Exception as e:
|
|
491
|
+
logger.warning(f"Failed to ensure strict schema for tool: {e}")
|
|
492
|
+
|
|
493
|
+
return tool
|
|
494
|
+
|
|
458
495
|
def get_tools(self) -> List[FunctionTool]:
|
|
459
496
|
r"""Aggregates all tools from the managed MCP client instances.
|
|
460
497
|
|
|
461
498
|
Collects and combines tools from all connected MCP clients into a
|
|
462
499
|
single unified list. Each tool is converted to a CAMEL-compatible
|
|
463
|
-
:obj:`FunctionTool` that can be used with CAMEL agents.
|
|
500
|
+
:obj:`FunctionTool` that can be used with CAMEL agents. All tools
|
|
501
|
+
are ensured to have strict schemas compatible with OpenAI's
|
|
502
|
+
requirements.
|
|
464
503
|
|
|
465
504
|
Returns:
|
|
466
505
|
List[FunctionTool]: Combined list of all available function tools
|
|
467
|
-
from all connected MCP servers. Returns an
|
|
468
|
-
clients are connected or if no tools are
|
|
506
|
+
from all connected MCP servers with strict schemas. Returns an
|
|
507
|
+
empty list if no clients are connected or if no tools are
|
|
508
|
+
available.
|
|
469
509
|
|
|
470
510
|
Note:
|
|
471
511
|
This method can be called even when the toolkit is not connected,
|
|
@@ -492,14 +532,25 @@ class MCPToolkit(BaseToolkit):
|
|
|
492
532
|
for i, client in enumerate(self.clients):
|
|
493
533
|
try:
|
|
494
534
|
client_tools = client.get_tools()
|
|
495
|
-
|
|
535
|
+
|
|
536
|
+
# Ensure all tools have strict schemas
|
|
537
|
+
strict_tools = []
|
|
538
|
+
for tool in client_tools:
|
|
539
|
+
strict_tool = self._ensure_strict_tool_schema(tool)
|
|
540
|
+
strict_tools.append(strict_tool)
|
|
541
|
+
|
|
542
|
+
all_tools.extend(strict_tools)
|
|
496
543
|
logger.debug(
|
|
497
|
-
f"Client {i+1} contributed {len(
|
|
544
|
+
f"Client {i+1} contributed {len(strict_tools)} "
|
|
545
|
+
f"tools (strict mode enabled)"
|
|
498
546
|
)
|
|
499
547
|
except Exception as e:
|
|
500
548
|
logger.error(f"Failed to get tools from client {i+1}: {e}")
|
|
501
549
|
|
|
502
|
-
logger.info(
|
|
550
|
+
logger.info(
|
|
551
|
+
f"Total tools available: {len(all_tools)} (all with strict "
|
|
552
|
+
f"schemas)"
|
|
553
|
+
)
|
|
503
554
|
return all_tools
|
|
504
555
|
|
|
505
556
|
def get_text_tools(self) -> str:
|
|
@@ -27,17 +27,29 @@ class PlaywrightMCPToolkit(BaseToolkit):
|
|
|
27
27
|
Attributes:
|
|
28
28
|
timeout (Optional[float]): Connection timeout in seconds.
|
|
29
29
|
(default: :obj:`None`)
|
|
30
|
+
additional_args (Optional[List[str]]): Additional command-line
|
|
31
|
+
arguments to pass to the Playwright MCP server. For example,
|
|
32
|
+
`["--cdp-endpoint=http://localhost:9222"]`.
|
|
33
|
+
(default: :obj:`None`)
|
|
30
34
|
|
|
31
35
|
Note:
|
|
32
36
|
Currently only supports asynchronous operation mode.
|
|
33
37
|
"""
|
|
34
38
|
|
|
35
|
-
def __init__(
|
|
36
|
-
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
timeout: Optional[float] = None,
|
|
42
|
+
additional_args: Optional[List[str]] = None,
|
|
43
|
+
) -> None:
|
|
44
|
+
r"""Initializes the PlaywrightMCPToolkit.
|
|
37
45
|
|
|
38
46
|
Args:
|
|
39
47
|
timeout (Optional[float]): Connection timeout in seconds.
|
|
40
48
|
(default: :obj:`None`)
|
|
49
|
+
additional_args (Optional[List[str]]): Additional command-line
|
|
50
|
+
arguments to pass to the Playwright MCP server. For example,
|
|
51
|
+
`["--cdp-endpoint=http://localhost:9222"]`.
|
|
52
|
+
(default: :obj:`None`)
|
|
41
53
|
"""
|
|
42
54
|
super().__init__(timeout=timeout)
|
|
43
55
|
|
|
@@ -46,7 +58,8 @@ class PlaywrightMCPToolkit(BaseToolkit):
|
|
|
46
58
|
"mcpServers": {
|
|
47
59
|
"playwright": {
|
|
48
60
|
"command": "npx",
|
|
49
|
-
"args": ["@playwright/mcp@latest"]
|
|
61
|
+
"args": ["@playwright/mcp@latest"]
|
|
62
|
+
+ (additional_args or []),
|
|
50
63
|
}
|
|
51
64
|
}
|
|
52
65
|
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
# See the License for the specific language governing permissions and
|
|
12
|
+
# limitations under the License.
|
|
13
|
+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
|
14
|
+
import uuid
|
|
15
|
+
from typing import List, Optional
|
|
16
|
+
|
|
17
|
+
from camel.logger import get_logger
|
|
18
|
+
from camel.tasks import Task
|
|
19
|
+
from camel.toolkits import BaseToolkit, FunctionTool
|
|
20
|
+
|
|
21
|
+
logger = get_logger(__name__)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class TaskPlanningToolkit(BaseToolkit):
|
|
25
|
+
r"""A toolkit for task decomposition and re-planning."""
|
|
26
|
+
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
timeout: Optional[float] = None,
|
|
30
|
+
):
|
|
31
|
+
r"""Initialize the TaskPlanningToolkit.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
timeout (Optional[float]): The timeout for the toolkit.
|
|
35
|
+
(default: :obj: `None`)
|
|
36
|
+
"""
|
|
37
|
+
super().__init__(timeout=timeout)
|
|
38
|
+
|
|
39
|
+
def decompose_task(
|
|
40
|
+
self,
|
|
41
|
+
original_task_content: str,
|
|
42
|
+
sub_task_contents: List[str],
|
|
43
|
+
original_task_id: Optional[str] = None,
|
|
44
|
+
) -> List[Task]:
|
|
45
|
+
r"""Use the tool to decompose an original task into several sub-tasks.
|
|
46
|
+
It creates new Task objects from the provided original task content,
|
|
47
|
+
used when the original task is complex and needs to be decomposed.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
original_task_content (str): The content of the task to be
|
|
51
|
+
decomposed.
|
|
52
|
+
sub_task_contents (List[str]): A list of strings, where each
|
|
53
|
+
string is the content for a new sub-task.
|
|
54
|
+
original_task_id (Optional[str]): The id of the task to be
|
|
55
|
+
decomposed. If not provided, a new id will be generated.
|
|
56
|
+
(default: :obj: `None`)
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
List[Task]: A list of newly created sub-task objects.
|
|
60
|
+
"""
|
|
61
|
+
# Create the original task object from its content
|
|
62
|
+
original_task = Task(
|
|
63
|
+
content=original_task_content,
|
|
64
|
+
id=original_task_id if original_task_id else str(uuid.uuid4()),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
new_tasks: List[Task] = []
|
|
68
|
+
for i, content in enumerate(sub_task_contents):
|
|
69
|
+
new_task = Task(
|
|
70
|
+
content=content,
|
|
71
|
+
id=f"{original_task.id}.{i}",
|
|
72
|
+
parent=original_task,
|
|
73
|
+
)
|
|
74
|
+
new_tasks.append(new_task)
|
|
75
|
+
original_task.subtasks.append(new_task)
|
|
76
|
+
|
|
77
|
+
logger.debug(
|
|
78
|
+
f"Decomposed task (content: '{original_task.content[:50]}...', "
|
|
79
|
+
f"id: {original_task.id}) into {len(new_tasks)} sub-tasks: "
|
|
80
|
+
f"{[task.id for task in new_tasks]}"
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
return new_tasks
|
|
84
|
+
|
|
85
|
+
def replan_tasks(
|
|
86
|
+
self,
|
|
87
|
+
original_task_content: str,
|
|
88
|
+
sub_task_contents: List[str],
|
|
89
|
+
original_task_id: Optional[str] = None,
|
|
90
|
+
) -> List[Task]:
|
|
91
|
+
r"""Use the tool to re_decompose a task into several subTasks.
|
|
92
|
+
It creates new Task objects from the provided original task content,
|
|
93
|
+
used when the decomposed tasks are not good enough to help finish
|
|
94
|
+
the task.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
original_task_content (str): The content of the task to be
|
|
98
|
+
decomposed.
|
|
99
|
+
sub_task_contents (List[str]): A list of strings, where each
|
|
100
|
+
string is the content for a new sub-task.
|
|
101
|
+
original_task_id (Optional[str]): The id of the task to be
|
|
102
|
+
decomposed. (default: :obj: `None`)
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
List[Task]: Reordered or modified tasks.
|
|
106
|
+
"""
|
|
107
|
+
original_task = Task(
|
|
108
|
+
content=original_task_content,
|
|
109
|
+
id=original_task_id if original_task_id else str(uuid.uuid4()),
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
new_tasks: List[Task] = []
|
|
113
|
+
for i, content in enumerate(sub_task_contents):
|
|
114
|
+
new_task = Task(
|
|
115
|
+
content=content,
|
|
116
|
+
id=f"{original_task.id}.{i}",
|
|
117
|
+
parent=original_task,
|
|
118
|
+
)
|
|
119
|
+
new_tasks.append(new_task)
|
|
120
|
+
original_task.subtasks.append(new_task)
|
|
121
|
+
|
|
122
|
+
logger.debug(
|
|
123
|
+
f"RePlan task (content: '{original_task.content[:50]}...', "
|
|
124
|
+
f"id: {original_task.id}) into {len(new_tasks)} sub-tasks: "
|
|
125
|
+
f"{[task.id for task in new_tasks]}"
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
return new_tasks
|
|
129
|
+
|
|
130
|
+
def get_tools(self) -> List[FunctionTool]:
|
|
131
|
+
return [
|
|
132
|
+
FunctionTool(self.decompose_task),
|
|
133
|
+
FunctionTool(self.replan_tasks),
|
|
134
|
+
]
|
camel/types/enums.py
CHANGED
|
@@ -30,7 +30,7 @@ class RoleType(Enum):
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
class ModelType(UnifiedModelType, Enum):
|
|
33
|
-
DEFAULT = os.getenv("DEFAULT_MODEL_TYPE", "gpt-
|
|
33
|
+
DEFAULT = os.getenv("DEFAULT_MODEL_TYPE", "gpt-4.1-mini-2025-04-14")
|
|
34
34
|
|
|
35
35
|
GPT_3_5_TURBO = "gpt-3.5-turbo"
|
|
36
36
|
GPT_4 = "gpt-4"
|
|
@@ -47,6 +47,7 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
47
47
|
GPT_4_1_NANO = "gpt-4.1-nano-2025-04-14"
|
|
48
48
|
O4_MINI = "o4-mini"
|
|
49
49
|
O3 = "o3"
|
|
50
|
+
O3_PRO = "o3-pro"
|
|
50
51
|
|
|
51
52
|
AWS_CLAUDE_3_7_SONNET = "anthropic.claude-3-7-sonnet-20250219-v1:0"
|
|
52
53
|
AWS_CLAUDE_3_5_SONNET = "anthropic.claude-3-5-sonnet-20241022-v2:0"
|
|
@@ -472,6 +473,7 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
472
473
|
ModelType.O1,
|
|
473
474
|
ModelType.O1_PREVIEW,
|
|
474
475
|
ModelType.O1_MINI,
|
|
476
|
+
ModelType.O3_PRO,
|
|
475
477
|
ModelType.O3_MINI,
|
|
476
478
|
ModelType.GPT_4_5_PREVIEW,
|
|
477
479
|
ModelType.GPT_4_1,
|
|
@@ -512,6 +514,7 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
512
514
|
ModelType.O1_PREVIEW,
|
|
513
515
|
ModelType.O1_MINI,
|
|
514
516
|
ModelType.O3_MINI,
|
|
517
|
+
ModelType.O3_PRO,
|
|
515
518
|
ModelType.GPT_4_5_PREVIEW,
|
|
516
519
|
ModelType.GPT_4_1,
|
|
517
520
|
ModelType.GPT_4_1_MINI,
|
|
@@ -1207,6 +1210,7 @@ class ModelType(UnifiedModelType, Enum):
|
|
|
1207
1210
|
elif self in {
|
|
1208
1211
|
ModelType.O1,
|
|
1209
1212
|
ModelType.O3_MINI,
|
|
1213
|
+
ModelType.O3_PRO,
|
|
1210
1214
|
ModelType.CLAUDE_2_1,
|
|
1211
1215
|
ModelType.CLAUDE_3_OPUS,
|
|
1212
1216
|
ModelType.CLAUDE_3_SONNET,
|
camel/utils/mcp_client.py
CHANGED
|
@@ -173,8 +173,6 @@ class MCPClient:
|
|
|
173
173
|
initialization. (default: :obj:`None`)
|
|
174
174
|
timeout (Optional[float], optional): Timeout for waiting for messages
|
|
175
175
|
from the server in seconds. (default: :obj:`10.0`)
|
|
176
|
-
strict (Optional[bool], optional): Strict mode for generating
|
|
177
|
-
FunctionTool objects. (default: :obj:`False`)
|
|
178
176
|
|
|
179
177
|
Examples:
|
|
180
178
|
STDIO server:
|
|
@@ -209,20 +207,6 @@ class MCPClient:
|
|
|
209
207
|
async with MCPClient({"url": "ws://localhost:8080/mcp"}) as client:
|
|
210
208
|
tools = client.get_tools()
|
|
211
209
|
|
|
212
|
-
With strict mode enabled:
|
|
213
|
-
|
|
214
|
-
.. code-block:: python
|
|
215
|
-
|
|
216
|
-
async with MCPClient({
|
|
217
|
-
"command": "npx",
|
|
218
|
-
"args": [
|
|
219
|
-
"-y",
|
|
220
|
-
"@modelcontextprotocol/server-filesystem",
|
|
221
|
-
"/path"
|
|
222
|
-
]
|
|
223
|
-
}, strict=True) as client:
|
|
224
|
-
tools = client.get_tools()
|
|
225
|
-
|
|
226
210
|
Attributes:
|
|
227
211
|
config (ServerConfig): The server configuration object.
|
|
228
212
|
client_info (Optional[types.Implementation]): Client implementation
|
|
@@ -235,14 +219,12 @@ class MCPClient:
|
|
|
235
219
|
config: Union[ServerConfig, Dict[str, Any]],
|
|
236
220
|
client_info: Optional[types.Implementation] = None,
|
|
237
221
|
timeout: Optional[float] = 10.0,
|
|
238
|
-
strict: Optional[bool] = False,
|
|
239
222
|
):
|
|
240
223
|
# Convert dict config to ServerConfig if needed
|
|
241
224
|
if isinstance(config, dict):
|
|
242
225
|
config = ServerConfig(**config)
|
|
243
226
|
|
|
244
227
|
self.config = config
|
|
245
|
-
self.strict = strict
|
|
246
228
|
|
|
247
229
|
# Validate transport type early (this will raise ValueError if invalid)
|
|
248
230
|
_ = self.config.transport_type
|
|
@@ -766,7 +748,6 @@ class MCPClient:
|
|
|
766
748
|
"name": mcp_tool.name,
|
|
767
749
|
"description": mcp_tool.description
|
|
768
750
|
or "No description provided.",
|
|
769
|
-
"strict": self.strict,
|
|
770
751
|
"parameters": parameters,
|
|
771
752
|
},
|
|
772
753
|
}
|
|
@@ -932,8 +913,7 @@ def create_mcp_client(
|
|
|
932
913
|
dictionary is provided, it will be automatically converted to
|
|
933
914
|
a :obj:`ServerConfig`.
|
|
934
915
|
**kwargs: Additional keyword arguments passed to the :obj:`MCPClient`
|
|
935
|
-
constructor, such as :obj:`client_info`, :obj:`timeout
|
|
936
|
-
:obj:`strict`.
|
|
916
|
+
constructor, such as :obj:`client_info`, :obj:`timeout`.
|
|
937
917
|
|
|
938
918
|
Returns:
|
|
939
919
|
MCPClient: A configured :obj:`MCPClient` instance ready for use as
|
|
@@ -972,20 +952,6 @@ def create_mcp_client(
|
|
|
972
952
|
"url": "ws://localhost:8080/mcp"
|
|
973
953
|
}) as client:
|
|
974
954
|
tools = client.get_tools()
|
|
975
|
-
|
|
976
|
-
With strict mode enabled:
|
|
977
|
-
|
|
978
|
-
.. code-block:: python
|
|
979
|
-
|
|
980
|
-
async with create_mcp_client({
|
|
981
|
-
"command": "npx",
|
|
982
|
-
"args": [
|
|
983
|
-
"-y",
|
|
984
|
-
"@modelcontextprotocol/server-filesystem",
|
|
985
|
-
"/path",
|
|
986
|
-
],
|
|
987
|
-
}, strict=True) as client:
|
|
988
|
-
tools = client.get_tools()
|
|
989
955
|
"""
|
|
990
956
|
return MCPClient(config, **kwargs)
|
|
991
957
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: camel-ai
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.66
|
|
4
4
|
Summary: Communicative Agents for AI Society Study
|
|
5
5
|
Project-URL: Homepage, https://www.camel-ai.org/
|
|
6
6
|
Project-URL: Repository, https://github.com/camel-ai/camel
|
|
@@ -21,7 +21,6 @@ Requires-Dist: psutil<6,>=5.9.8
|
|
|
21
21
|
Requires-Dist: pydantic>=2.10.6
|
|
22
22
|
Requires-Dist: tiktoken<0.8,>=0.7.0
|
|
23
23
|
Provides-Extra: all
|
|
24
|
-
Requires-Dist: accelerate<0.27,>=0.26.0; extra == 'all'
|
|
25
24
|
Requires-Dist: aci-sdk>=1.0.0b1; extra == 'all'
|
|
26
25
|
Requires-Dist: agentops<0.4,>=0.3.21; extra == 'all'
|
|
27
26
|
Requires-Dist: aiosqlite<0.21,>=0.20.0; extra == 'all'
|
|
@@ -53,6 +52,7 @@ Requires-Dist: fastapi>=0.115.11; extra == 'all'
|
|
|
53
52
|
Requires-Dist: ffmpeg-python<0.3,>=0.2.0; extra == 'all'
|
|
54
53
|
Requires-Dist: firecrawl-py<2,>=1.0.0; extra == 'all'
|
|
55
54
|
Requires-Dist: fish-audio-sdk<2025,>=2024.12.5; extra == 'all'
|
|
55
|
+
Requires-Dist: flask>=2.0; extra == 'all'
|
|
56
56
|
Requires-Dist: fpdf>=1.7.2; extra == 'all'
|
|
57
57
|
Requires-Dist: google-api-python-client==2.166.0; extra == 'all'
|
|
58
58
|
Requires-Dist: google-auth-httplib2==0.2.0; extra == 'all'
|
|
@@ -83,9 +83,7 @@ Requires-Dist: newspaper3k<0.3,>=0.2.8; extra == 'all'
|
|
|
83
83
|
Requires-Dist: notion-client<3,>=2.2.1; extra == 'all'
|
|
84
84
|
Requires-Dist: numpy<=2.2,>=1.2; extra == 'all'
|
|
85
85
|
Requires-Dist: openapi-spec-validator<0.8,>=0.7.1; extra == 'all'
|
|
86
|
-
Requires-Dist: opencv-python<5,>=4; extra == 'all'
|
|
87
86
|
Requires-Dist: openpyxl>=3.1.5; extra == 'all'
|
|
88
|
-
Requires-Dist: outlines<0.2,>=0.1.7; extra == 'all'
|
|
89
87
|
Requires-Dist: pandas<2,>=1.5.3; extra == 'all'
|
|
90
88
|
Requires-Dist: pandasai<3,>=2.3.0; extra == 'all'
|
|
91
89
|
Requires-Dist: playwright>=1.50.0; extra == 'all'
|
|
@@ -115,7 +113,6 @@ Requires-Dist: rouge<2,>=1.0.1; extra == 'all'
|
|
|
115
113
|
Requires-Dist: scenedetect>=0.6.5.2; extra == 'all'
|
|
116
114
|
Requires-Dist: scholarly[tor]==1.7.11; extra == 'all'
|
|
117
115
|
Requires-Dist: scrapegraph-py<2,>=1.12.0; extra == 'all'
|
|
118
|
-
Requires-Dist: sentence-transformers<4,>=3.0.1; extra == 'all'
|
|
119
116
|
Requires-Dist: sentencepiece<0.3,>=0.2; extra == 'all'
|
|
120
117
|
Requires-Dist: slack-bolt<2,>=1.20.1; extra == 'all'
|
|
121
118
|
Requires-Dist: slack-sdk<4,>=3.27.2; extra == 'all'
|
|
@@ -125,7 +122,6 @@ Requires-Dist: sympy<2,>=1.13.3; extra == 'all'
|
|
|
125
122
|
Requires-Dist: tabulate>=0.9.0; extra == 'all'
|
|
126
123
|
Requires-Dist: tavily-python<0.6,>=0.5.0; extra == 'all'
|
|
127
124
|
Requires-Dist: textblob<0.18,>=0.17.1; extra == 'all'
|
|
128
|
-
Requires-Dist: torch; extra == 'all'
|
|
129
125
|
Requires-Dist: transformers<5,>=4; extra == 'all'
|
|
130
126
|
Requires-Dist: tree-sitter-python<0.24,>=0.23.6; extra == 'all'
|
|
131
127
|
Requires-Dist: tree-sitter<0.24,>=0.23.2; extra == 'all'
|
|
@@ -162,6 +158,7 @@ Requires-Dist: rouge<2,>=1.0.1; extra == 'data-tools'
|
|
|
162
158
|
Requires-Dist: stripe<12,>=11.3.0; extra == 'data-tools'
|
|
163
159
|
Requires-Dist: textblob<0.18,>=0.17.1; extra == 'data-tools'
|
|
164
160
|
Provides-Extra: dev
|
|
161
|
+
Requires-Dist: flask>=2.0; extra == 'dev'
|
|
165
162
|
Requires-Dist: gradio<4,>=3; extra == 'dev'
|
|
166
163
|
Requires-Dist: mock<6,>=5; extra == 'dev'
|
|
167
164
|
Requires-Dist: mypy<2,>=1.5.1; extra == 'dev'
|
|
@@ -218,13 +215,11 @@ Requires-Dist: tabulate>=0.9.0; extra == 'document-tools'
|
|
|
218
215
|
Requires-Dist: unstructured==0.16.20; extra == 'document-tools'
|
|
219
216
|
Requires-Dist: xls2xlsx>=0.2.0; extra == 'document-tools'
|
|
220
217
|
Provides-Extra: huggingface
|
|
221
|
-
Requires-Dist: accelerate<0.27,>=0.26.0; extra == 'huggingface'
|
|
222
218
|
Requires-Dist: datasets<4,>=3; extra == 'huggingface'
|
|
223
219
|
Requires-Dist: diffusers<0.26,>=0.25.0; extra == 'huggingface'
|
|
224
|
-
Requires-Dist:
|
|
220
|
+
Requires-Dist: huggingface-hub; extra == 'huggingface'
|
|
225
221
|
Requires-Dist: sentencepiece<0.3,>=0.2; extra == 'huggingface'
|
|
226
222
|
Requires-Dist: soundfile<0.14,>=0.13; extra == 'huggingface'
|
|
227
|
-
Requires-Dist: torch; extra == 'huggingface'
|
|
228
223
|
Requires-Dist: transformers<5,>=4; extra == 'huggingface'
|
|
229
224
|
Provides-Extra: media-tools
|
|
230
225
|
Requires-Dist: ffmpeg-python<0.3,>=0.2.0; extra == 'media-tools'
|
|
@@ -261,9 +256,7 @@ Requires-Dist: mcp-simple-arxiv==0.2.2; extra == 'owl'
|
|
|
261
256
|
Requires-Dist: newspaper3k<0.3,>=0.2.8; extra == 'owl'
|
|
262
257
|
Requires-Dist: numpy<=2.2,>=1.2; extra == 'owl'
|
|
263
258
|
Requires-Dist: openapi-spec-validator<0.8,>=0.7.1; extra == 'owl'
|
|
264
|
-
Requires-Dist: opencv-python<5,>=4; extra == 'owl'
|
|
265
259
|
Requires-Dist: openpyxl>=3.1.5; extra == 'owl'
|
|
266
|
-
Requires-Dist: outlines<0.2,>=0.1.7; extra == 'owl'
|
|
267
260
|
Requires-Dist: pandas<2,>=1.5.3; extra == 'owl'
|
|
268
261
|
Requires-Dist: pandasai<3,>=2.3.0; extra == 'owl'
|
|
269
262
|
Requires-Dist: playwright>=1.50.0; extra == 'owl'
|
|
@@ -304,7 +297,6 @@ Requires-Dist: pyobvector>=0.1.18; extra == 'rag'
|
|
|
304
297
|
Requires-Dist: pytidb-experimental==0.0.1.dev4; extra == 'rag'
|
|
305
298
|
Requires-Dist: qdrant-client<2,>=1.9.0; extra == 'rag'
|
|
306
299
|
Requires-Dist: rank-bm25<0.3,>=0.2.2; extra == 'rag'
|
|
307
|
-
Requires-Dist: sentence-transformers<4,>=3.0.1; extra == 'rag'
|
|
308
300
|
Requires-Dist: unstructured==0.16.20; extra == 'rag'
|
|
309
301
|
Requires-Dist: weaviate-client>=4.15.0; extra == 'rag'
|
|
310
302
|
Provides-Extra: research-tools
|