mbxai 0.6.16__py3-none-any.whl → 0.6.17__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
@@ -24,19 +24,22 @@ class MCPTool(Tool):
24
24
 
25
25
  def to_openai_function(self) -> dict[str, Any]:
26
26
  """Convert the tool to an OpenAI function definition."""
27
+ # Use the base Tool's schema conversion to ensure strict compliance
28
+ strict_schema = self._ensure_strict_schema(self.input_schema)
29
+
27
30
  return {
28
31
  "type": "function",
29
32
  "function": {
30
33
  "name": self.name,
31
34
  "description": self.description,
32
- "parameters": self._convert_to_openai_schema(self.input_schema)
35
+ "parameters": strict_schema
33
36
  }
34
37
  }
35
38
 
36
39
  def _convert_to_openai_schema(self, mcp_schema: dict[str, Any]) -> dict[str, Any]:
37
40
  """Convert MCP schema to OpenAI schema format."""
38
41
  if not mcp_schema:
39
- return {"type": "object", "properties": {}}
42
+ return {"type": "object", "properties": {}, "required": []}
40
43
 
41
44
  # If schema has a $ref, resolve it
42
45
  if "$ref" in mcp_schema:
@@ -49,9 +52,42 @@ class MCPTool(Tool):
49
52
  if "$ref" in input_schema:
50
53
  ref = input_schema["$ref"].split("/")[-1]
51
54
  input_schema = mcp_schema.get("$defs", {}).get(ref, {})
52
- return input_schema
55
+ mcp_schema = input_schema
56
+
57
+ # Create a new schema object to ensure we have all required fields
58
+ strict_schema = {
59
+ "type": "object",
60
+ "properties": {},
61
+ "required": []
62
+ }
63
+
64
+ # Copy over properties, ensuring each has type and description
65
+ if "properties" in mcp_schema:
66
+ for prop_name, prop in mcp_schema["properties"].items():
67
+ # Create a new property object with required fields
68
+ new_prop = {
69
+ "type": prop.get("type", "string"),
70
+ "description": prop.get("description", f"The {prop_name} parameter")
71
+ }
72
+
73
+ # Copy over any additional fields that might be useful
74
+ for key, value in prop.items():
75
+ if key not in new_prop:
76
+ new_prop[key] = value
77
+
78
+ strict_schema["properties"][prop_name] = new_prop
79
+
80
+ # Copy over required fields
81
+ if "required" in mcp_schema:
82
+ strict_schema["required"] = mcp_schema["required"]
83
+
84
+ # Ensure all required fields are actually in properties
85
+ strict_schema["required"] = [
86
+ req for req in strict_schema["required"]
87
+ if req in strict_schema["properties"]
88
+ ]
53
89
 
54
- return mcp_schema
90
+ return strict_schema
55
91
 
56
92
 
57
93
  class MCPClient(ToolClient):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mbxai
3
- Version: 0.6.16
3
+ Version: 0.6.17
4
4
  Summary: MBX AI SDK
5
5
  Project-URL: Homepage, https://www.mibexx.de
6
6
  Project-URL: Documentation, https://www.mibexx.de
@@ -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=B8ZpH-uecmTCgoDw65LwwVxsFWVoX-08t5ff0hOEPXk,6011
4
+ mbxai/mcp/client.py,sha256=3Nt1RoHCZzGj486nsazpiPLNca9zbr2485E1zkwcdY4,7456
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.dist-info/METADATA,sha256=d9Bpi8hqAYZZRz301NfXWU7A-50ZWSZqMTfbxvcMUbw,4108
16
- mbxai-0.6.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
17
- mbxai-0.6.16.dist-info/licenses/LICENSE,sha256=hEyhc4FxwYo3NQ40yNgZ7STqwVk-1_XcTXOnAPbGJAw,1069
18
- mbxai-0.6.16.dist-info/RECORD,,
15
+ mbxai-0.6.17.dist-info/METADATA,sha256=_n_7YTqqGoxqWAhVsOjMbdhL0lperoljbO-B2H0qbtQ,4108
16
+ mbxai-0.6.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
17
+ mbxai-0.6.17.dist-info/licenses/LICENSE,sha256=hEyhc4FxwYo3NQ40yNgZ7STqwVk-1_XcTXOnAPbGJAw,1069
18
+ mbxai-0.6.17.dist-info/RECORD,,
File without changes