mbxai 0.6.17__py3-none-any.whl → 0.6.18__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.
mbxai/mcp/client.py
CHANGED
@@ -4,6 +4,7 @@ from typing import Any, TypeVar, Callable
|
|
4
4
|
import httpx
|
5
5
|
import logging
|
6
6
|
import asyncio
|
7
|
+
import json
|
7
8
|
from pydantic import BaseModel, Field
|
8
9
|
|
9
10
|
from ..tools import ToolClient, Tool
|
@@ -24,8 +25,14 @@ class MCPTool(Tool):
|
|
24
25
|
|
25
26
|
def to_openai_function(self) -> dict[str, Any]:
|
26
27
|
"""Convert the tool to an OpenAI function definition."""
|
27
|
-
#
|
28
|
-
|
28
|
+
# Log the original schema
|
29
|
+
logger.info(f"Original schema for {self.name}: {json.dumps(self.input_schema, indent=2)}")
|
30
|
+
|
31
|
+
# Convert the schema to strict format
|
32
|
+
strict_schema = self._convert_to_openai_schema(self.input_schema)
|
33
|
+
|
34
|
+
# Log the converted schema
|
35
|
+
logger.info(f"Converted schema for {self.name}: {json.dumps(strict_schema, indent=2)}")
|
29
36
|
|
30
37
|
return {
|
31
38
|
"type": "function",
|
@@ -41,10 +48,14 @@ class MCPTool(Tool):
|
|
41
48
|
if not mcp_schema:
|
42
49
|
return {"type": "object", "properties": {}, "required": []}
|
43
50
|
|
51
|
+
logger.info(f"Starting schema conversion for {self.name}")
|
52
|
+
logger.info(f"Initial schema: {json.dumps(mcp_schema, indent=2)}")
|
53
|
+
|
44
54
|
# If schema has a $ref, resolve it
|
45
55
|
if "$ref" in mcp_schema:
|
46
56
|
ref = mcp_schema["$ref"].split("/")[-1]
|
47
57
|
mcp_schema = mcp_schema.get("$defs", {}).get(ref, {})
|
58
|
+
logger.info(f"Resolved $ref to: {json.dumps(mcp_schema, indent=2)}")
|
48
59
|
|
49
60
|
# If schema has an input wrapper, unwrap it
|
50
61
|
if "properties" in mcp_schema and "input" in mcp_schema["properties"]:
|
@@ -53,6 +64,7 @@ class MCPTool(Tool):
|
|
53
64
|
ref = input_schema["$ref"].split("/")[-1]
|
54
65
|
input_schema = mcp_schema.get("$defs", {}).get(ref, {})
|
55
66
|
mcp_schema = input_schema
|
67
|
+
logger.info(f"Unwrapped input schema: {json.dumps(mcp_schema, indent=2)}")
|
56
68
|
|
57
69
|
# Create a new schema object to ensure we have all required fields
|
58
70
|
strict_schema = {
|
@@ -76,17 +88,21 @@ class MCPTool(Tool):
|
|
76
88
|
new_prop[key] = value
|
77
89
|
|
78
90
|
strict_schema["properties"][prop_name] = new_prop
|
91
|
+
logger.info(f"Added property {prop_name}: {json.dumps(new_prop, indent=2)}")
|
79
92
|
|
80
93
|
# Copy over required fields
|
81
94
|
if "required" in mcp_schema:
|
82
95
|
strict_schema["required"] = mcp_schema["required"]
|
96
|
+
logger.info(f"Added required fields: {strict_schema['required']}")
|
83
97
|
|
84
98
|
# Ensure all required fields are actually in properties
|
85
99
|
strict_schema["required"] = [
|
86
100
|
req for req in strict_schema["required"]
|
87
101
|
if req in strict_schema["properties"]
|
88
102
|
]
|
103
|
+
logger.info(f"Final required fields: {strict_schema['required']}")
|
89
104
|
|
105
|
+
logger.info(f"Final strict schema: {json.dumps(strict_schema, indent=2)}")
|
90
106
|
return strict_schema
|
91
107
|
|
92
108
|
|
@@ -159,7 +175,7 @@ class MCPClient(ToolClient):
|
|
159
175
|
|
160
176
|
# Register each tool
|
161
177
|
for idx, tool_data in enumerate(tools_data):
|
162
|
-
logger.
|
178
|
+
logger.info(f"Processing tool {idx}: {json.dumps(tool_data, indent=2)}")
|
163
179
|
|
164
180
|
# Ensure tool_data is a dictionary
|
165
181
|
if not isinstance(tool_data, dict):
|
@@ -181,4 +197,4 @@ class MCPClient(ToolClient):
|
|
181
197
|
logger.info(f"Successfully registered tool: {tool.name}")
|
182
198
|
except Exception as e:
|
183
199
|
logger.error(f"Failed to register tool: {str(e)}")
|
184
|
-
logger.error(f"Tool data that caused the error: {tool_data}")
|
200
|
+
logger.error(f"Tool data that caused the error: {json.dumps(tool_data, indent=2)}")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
mbxai/__init__.py,sha256=TPQPmobkBuhgo14NoMCbpjcR4Lgi3T-hc27EY0cDggk,48
|
2
2
|
mbxai/core.py,sha256=WMvmU9TTa7M_m-qWsUew4xH8Ul6xseCZ2iBCXJTW-Bs,196
|
3
3
|
mbxai/mcp/__init__.py,sha256=_ek9iYdYqW5saKetj4qDci11jxesQDiHPJRpHMKkxgU,175
|
4
|
-
mbxai/mcp/client.py,sha256=
|
4
|
+
mbxai/mcp/client.py,sha256=_FKq0oayE4eMklHdeMapBzJhzdJ0yAvGYz81-RB5GQY,8408
|
5
5
|
mbxai/mcp/example.py,sha256=oaol7AvvZnX86JWNz64KvPjab5gg1VjVN3G8eFSzuaE,2350
|
6
6
|
mbxai/mcp/server.py,sha256=T0-Y7FeHRFqSTp2ERU96fOQlQJKjMFxg8oqC4dzBmBA,3463
|
7
7
|
mbxai/openrouter/__init__.py,sha256=Ito9Qp_B6q-RLGAQcYyTJVWwR2YAZvNqE-HIYXxhtD8,298
|
@@ -12,7 +12,7 @@ mbxai/tools/__init__.py,sha256=QUFaXhDm-UKcuAtT1rbKzhBkvyRBVokcQIOf9cxIuwc,160
|
|
12
12
|
mbxai/tools/client.py,sha256=qOf8MiQ8_flPUNiMioOyjeEaV8rN1EBWb98T8qTC3D4,17582
|
13
13
|
mbxai/tools/example.py,sha256=1HgKK39zzUuwFbnp3f0ThyWVfA_8P28PZcTwaUw5K78,2232
|
14
14
|
mbxai/tools/types.py,sha256=pFSV59rebWASnIQb27wVg1kFYbCGZmPlOjrLNfNuvrc,3245
|
15
|
-
mbxai-0.6.
|
16
|
-
mbxai-0.6.
|
17
|
-
mbxai-0.6.
|
18
|
-
mbxai-0.6.
|
15
|
+
mbxai-0.6.18.dist-info/METADATA,sha256=LsCxFm_0dH1JcYPmOMBZZhYXOk0TiO3HPh69RyhjLXk,4108
|
16
|
+
mbxai-0.6.18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
17
|
+
mbxai-0.6.18.dist-info/licenses/LICENSE,sha256=hEyhc4FxwYo3NQ40yNgZ7STqwVk-1_XcTXOnAPbGJAw,1069
|
18
|
+
mbxai-0.6.18.dist-info/RECORD,,
|
File without changes
|
File without changes
|