mbxai 0.6.19__py3-none-any.whl → 0.6.20__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/__init__.py +1 -1
- mbxai/mcp/client.py +8 -13
- mbxai/mcp/server.py +1 -1
- mbxai/tools/types.py +14 -0
- {mbxai-0.6.19.dist-info → mbxai-0.6.20.dist-info}/METADATA +1 -1
- {mbxai-0.6.19.dist-info → mbxai-0.6.20.dist-info}/RECORD +8 -8
- {mbxai-0.6.19.dist-info → mbxai-0.6.20.dist-info}/WHEEL +0 -0
- {mbxai-0.6.19.dist-info → mbxai-0.6.20.dist-info}/licenses/LICENSE +0 -0
mbxai/__init__.py
CHANGED
mbxai/mcp/client.py
CHANGED
@@ -16,28 +16,23 @@ T = TypeVar("T", bound=BaseModel)
|
|
16
16
|
|
17
17
|
|
18
18
|
class MCPTool(Tool):
|
19
|
-
"""
|
20
|
-
|
21
|
-
|
22
|
-
strict: bool =
|
23
|
-
input_schema: dict[str, Any] = Field(description="The input schema for the tool")
|
24
|
-
function: Callable[..., Any] | None = Field(default=None, description="The function that implements the tool")
|
25
|
-
_converted_schema: dict[str, Any] | None = None
|
19
|
+
"""A tool from the MCP server."""
|
20
|
+
input_schema: dict[str, Any]
|
21
|
+
internal_url: str
|
22
|
+
strict: bool = True
|
26
23
|
|
27
24
|
def to_openai_function(self) -> dict[str, Any]:
|
28
25
|
"""Convert the tool to an OpenAI function definition."""
|
29
|
-
# Use
|
30
|
-
|
31
|
-
|
32
|
-
self._converted_schema = convert_to_strict_schema(self.input_schema, self.strict)
|
33
|
-
logger.debug(f"Converted schema for {self.name}: {json.dumps(self._converted_schema, indent=2)}")
|
26
|
+
# Use the base Tool's schema conversion
|
27
|
+
strict_schema = convert_to_strict_schema(self.input_schema, strict=self.strict)
|
28
|
+
logger.info(f"Converted schema for {self.name}: {json.dumps(strict_schema, indent=2)}")
|
34
29
|
|
35
30
|
return {
|
36
31
|
"type": "function",
|
37
32
|
"function": {
|
38
33
|
"name": self.name,
|
39
34
|
"description": self.description,
|
40
|
-
"parameters":
|
35
|
+
"parameters": strict_schema
|
41
36
|
}
|
42
37
|
}
|
43
38
|
|
mbxai/mcp/server.py
CHANGED
mbxai/tools/types.py
CHANGED
@@ -4,6 +4,10 @@ Type definitions for the tools package.
|
|
4
4
|
|
5
5
|
from typing import Any, Callable
|
6
6
|
from pydantic import BaseModel, Field
|
7
|
+
import logging
|
8
|
+
import json
|
9
|
+
|
10
|
+
logger = logging.getLogger(__name__)
|
7
11
|
|
8
12
|
def convert_to_strict_schema(schema: dict[str, Any], strict: bool = True) -> dict[str, Any]:
|
9
13
|
"""Convert a schema to strict format required by OpenAI.
|
@@ -15,6 +19,9 @@ def convert_to_strict_schema(schema: dict[str, Any], strict: bool = True) -> dic
|
|
15
19
|
Returns:
|
16
20
|
A schema in strict format
|
17
21
|
"""
|
22
|
+
logger.info(f"Converting schema to strict format. Input schema: {json.dumps(schema, indent=2)}")
|
23
|
+
logger.info(f"Strict mode: {strict}")
|
24
|
+
|
18
25
|
if not schema:
|
19
26
|
return {"type": "object", "properties": {}, "required": []}
|
20
27
|
|
@@ -32,11 +39,13 @@ def convert_to_strict_schema(schema: dict[str, Any], strict: bool = True) -> dic
|
|
32
39
|
# Handle input wrapper
|
33
40
|
if "properties" in schema and "input" in schema["properties"]:
|
34
41
|
input_schema = schema["properties"]["input"]
|
42
|
+
logger.info(f"Found input wrapper. Input schema: {json.dumps(input_schema, indent=2)}")
|
35
43
|
|
36
44
|
# If input has a $ref, resolve it
|
37
45
|
if "$ref" in input_schema:
|
38
46
|
ref = input_schema["$ref"].split("/")[-1]
|
39
47
|
input_schema = schema.get("$defs", {}).get(ref, {})
|
48
|
+
logger.info(f"Resolved $ref to: {json.dumps(input_schema, indent=2)}")
|
40
49
|
|
41
50
|
# Create the input property schema
|
42
51
|
input_prop_schema = {
|
@@ -64,10 +73,12 @@ def convert_to_strict_schema(schema: dict[str, Any], strict: bool = True) -> dic
|
|
64
73
|
new_prop[key] = value
|
65
74
|
|
66
75
|
input_prop_schema["properties"][prop_name] = new_prop
|
76
|
+
logger.info(f"Added property {prop_name}: {json.dumps(new_prop, indent=2)}")
|
67
77
|
|
68
78
|
# Copy over required fields for input schema
|
69
79
|
if "required" in input_schema:
|
70
80
|
input_prop_schema["required"] = input_schema["required"]
|
81
|
+
logger.info(f"Added required fields for input schema: {input_prop_schema['required']}")
|
71
82
|
|
72
83
|
# Add the input property to the main schema
|
73
84
|
strict_schema["properties"]["input"] = input_prop_schema
|
@@ -75,7 +86,9 @@ def convert_to_strict_schema(schema: dict[str, Any], strict: bool = True) -> dic
|
|
75
86
|
# Copy over required fields for main schema
|
76
87
|
if "required" in schema:
|
77
88
|
strict_schema["required"] = schema["required"]
|
89
|
+
logger.info(f"Added required fields for main schema: {strict_schema['required']}")
|
78
90
|
|
91
|
+
logger.info(f"Final strict schema: {json.dumps(strict_schema, indent=2)}")
|
79
92
|
return strict_schema
|
80
93
|
|
81
94
|
class ToolCall(BaseModel):
|
@@ -95,6 +108,7 @@ class Tool(BaseModel):
|
|
95
108
|
"""Convert the tool to an OpenAI function definition."""
|
96
109
|
# Ensure schema is in strict format
|
97
110
|
strict_schema = convert_to_strict_schema(self.schema)
|
111
|
+
logger.info(f"Converted schema for {self.name}: {json.dumps(strict_schema, indent=2)}")
|
98
112
|
|
99
113
|
return {
|
100
114
|
"type": "function",
|
@@ -1,9 +1,9 @@
|
|
1
|
-
mbxai/__init__.py,sha256=
|
1
|
+
mbxai/__init__.py,sha256=k5Jl-pIwvz4w-b1_h3wR6y9AzjIl18Pwd10AZN-l-rk,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=UhrtsR13px-3MyfHvida5Eh_ou9-ofVexHkhMUEmYH8,7748
|
5
5
|
mbxai/mcp/example.py,sha256=oaol7AvvZnX86JWNz64KvPjab5gg1VjVN3G8eFSzuaE,2350
|
6
|
-
mbxai/mcp/server.py,sha256=
|
6
|
+
mbxai/mcp/server.py,sha256=65DvS6RyZ59tRThiFo_bCm3C_SbagGtzkTKEAh2JLLM,3463
|
7
7
|
mbxai/openrouter/__init__.py,sha256=Ito9Qp_B6q-RLGAQcYyTJVWwR2YAZvNqE-HIYXxhtD8,298
|
8
8
|
mbxai/openrouter/client.py,sha256=nusxYObyLAMGQd6J9u2uLfkRXyE5kZmdIGdlU-76HPo,13529
|
9
9
|
mbxai/openrouter/config.py,sha256=Ia93s-auim9Sq71eunVDbn9ET5xX2zusXpV4JBdHAzs,3251
|
@@ -11,8 +11,8 @@ mbxai/openrouter/models.py,sha256=b3IjjtZAjeGOf2rLsdnCD1HacjTnS8jmv_ZXorc-KJQ,26
|
|
11
11
|
mbxai/tools/__init__.py,sha256=ogxrHvgJ7OR62Lmd5x9Eh5d2C0jqWyQis7Zy3yKpZ78,218
|
12
12
|
mbxai/tools/client.py,sha256=qOf8MiQ8_flPUNiMioOyjeEaV8rN1EBWb98T8qTC3D4,17582
|
13
13
|
mbxai/tools/example.py,sha256=1HgKK39zzUuwFbnp3f0ThyWVfA_8P28PZcTwaUw5K78,2232
|
14
|
-
mbxai/tools/types.py,sha256=
|
15
|
-
mbxai-0.6.
|
16
|
-
mbxai-0.6.
|
17
|
-
mbxai-0.6.
|
18
|
-
mbxai-0.6.
|
14
|
+
mbxai/tools/types.py,sha256=lAmy35IX04QV18Am8Ebd-0o6i34QU0vv82FaBYznu_E,4375
|
15
|
+
mbxai-0.6.20.dist-info/METADATA,sha256=BQJaUY0ZGe924fILDvEIPefVaPPyu66BFSWZ9Rc-JS8,4148
|
16
|
+
mbxai-0.6.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
17
|
+
mbxai-0.6.20.dist-info/licenses/LICENSE,sha256=hEyhc4FxwYo3NQ40yNgZ7STqwVk-1_XcTXOnAPbGJAw,1069
|
18
|
+
mbxai-0.6.20.dist-info/RECORD,,
|
File without changes
|
File without changes
|