mbxai 0.6.25__tar.gz → 0.6.26__tar.gz
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-0.6.25 → mbxai-0.6.26}/PKG-INFO +1 -1
- {mbxai-0.6.25 → mbxai-0.6.26}/pyproject.toml +1 -1
- {mbxai-0.6.25 → mbxai-0.6.26}/setup.py +1 -1
- {mbxai-0.6.25 → mbxai-0.6.26}/src/mbxai/__init__.py +1 -1
- {mbxai-0.6.25 → mbxai-0.6.26}/src/mbxai/mcp/client.py +7 -75
- {mbxai-0.6.25 → mbxai-0.6.26}/src/mbxai/mcp/server.py +1 -1
- {mbxai-0.6.25 → mbxai-0.6.26}/uv.lock +1 -1
- {mbxai-0.6.25 → mbxai-0.6.26}/.gitignore +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/LICENSE +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/README.md +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/src/mbxai/core.py +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/src/mbxai/mcp/__init__.py +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/src/mbxai/mcp/example.py +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/src/mbxai/openrouter/__init__.py +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/src/mbxai/openrouter/client.py +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/src/mbxai/openrouter/config.py +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/src/mbxai/openrouter/models.py +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/src/mbxai/tools/__init__.py +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/src/mbxai/tools/client.py +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/src/mbxai/tools/example.py +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/src/mbxai/tools/types.py +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/tests/test_core.py +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/tests/test_mcp.py +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/tests/test_openrouter.py +0 -0
- {mbxai-0.6.25 → mbxai-0.6.26}/tests/test_tools.py +0 -0
@@ -24,89 +24,21 @@ 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
|
-
#
|
27
|
+
# Convert schema to strict format, keeping input wrapper
|
28
28
|
strict_schema = convert_to_strict_schema(self.input_schema, strict=self.strict, keep_input_wrapper=True)
|
29
|
-
logger.info(f"Converted schema for {self.name}: {json.dumps(strict_schema, indent=2)}")
|
30
29
|
|
31
|
-
|
30
|
+
function_def = {
|
32
31
|
"type": "function",
|
33
32
|
"function": {
|
34
33
|
"name": self.name,
|
35
34
|
"description": self.description,
|
36
|
-
"parameters": strict_schema
|
35
|
+
"parameters": strict_schema,
|
36
|
+
"strict": True
|
37
37
|
}
|
38
38
|
}
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
if not mcp_schema:
|
43
|
-
return {"type": "object", "properties": {}, "required": []}
|
44
|
-
|
45
|
-
# Create a new schema object to ensure we have all required fields
|
46
|
-
strict_schema = {
|
47
|
-
"type": "object",
|
48
|
-
"properties": {},
|
49
|
-
"required": []
|
50
|
-
}
|
51
|
-
|
52
|
-
# Add additionalProperties: false for strict tools
|
53
|
-
if self.strict:
|
54
|
-
strict_schema["additionalProperties"] = False
|
55
|
-
|
56
|
-
# Handle input wrapper
|
57
|
-
if "properties" in mcp_schema and "input" in mcp_schema["properties"]:
|
58
|
-
input_schema = mcp_schema["properties"]["input"]
|
59
|
-
logger.info(f"Found input wrapper. Input schema: {json.dumps(input_schema, indent=2)}")
|
60
|
-
|
61
|
-
# If input has a $ref, resolve it
|
62
|
-
if "$ref" in input_schema:
|
63
|
-
ref = input_schema["$ref"].split("/")[-1]
|
64
|
-
input_schema = mcp_schema.get("$defs", {}).get(ref, {})
|
65
|
-
logger.info(f"Resolved $ref to: {json.dumps(input_schema, indent=2)}")
|
66
|
-
|
67
|
-
# Create the input property schema
|
68
|
-
input_prop_schema = {
|
69
|
-
"type": "object",
|
70
|
-
"properties": {},
|
71
|
-
"required": []
|
72
|
-
}
|
73
|
-
|
74
|
-
# Add additionalProperties: false for input schema
|
75
|
-
if self.strict:
|
76
|
-
input_prop_schema["additionalProperties"] = False
|
77
|
-
|
78
|
-
# Copy over input properties
|
79
|
-
if "properties" in input_schema:
|
80
|
-
for prop_name, prop in input_schema["properties"].items():
|
81
|
-
# Create a new property object with required fields
|
82
|
-
new_prop = {
|
83
|
-
"type": prop.get("type", "string"),
|
84
|
-
"description": prop.get("description", f"The {prop_name} parameter")
|
85
|
-
}
|
86
|
-
|
87
|
-
# Copy over any additional fields that might be useful
|
88
|
-
for key, value in prop.items():
|
89
|
-
if key not in new_prop:
|
90
|
-
new_prop[key] = value
|
91
|
-
|
92
|
-
input_prop_schema["properties"][prop_name] = new_prop
|
93
|
-
logger.info(f"Added property {prop_name}: {json.dumps(new_prop, indent=2)}")
|
94
|
-
|
95
|
-
# Copy over required fields for input schema
|
96
|
-
if "required" in input_schema:
|
97
|
-
input_prop_schema["required"] = input_schema["required"]
|
98
|
-
logger.info(f"Added required fields for input schema: {input_prop_schema['required']}")
|
99
|
-
|
100
|
-
# Add the input property to the main schema
|
101
|
-
strict_schema["properties"]["input"] = input_prop_schema
|
102
|
-
|
103
|
-
# Copy over required fields for main schema
|
104
|
-
if "required" in mcp_schema:
|
105
|
-
strict_schema["required"] = mcp_schema["required"]
|
106
|
-
logger.info(f"Added required fields for main schema: {strict_schema['required']}")
|
107
|
-
|
108
|
-
logger.info(f"Final strict schema: {json.dumps(strict_schema, indent=2)}")
|
109
|
-
return strict_schema
|
39
|
+
|
40
|
+
logger.info(f"Created function definition for {self.name}: {json.dumps(function_def, indent=2)}")
|
41
|
+
return function_def
|
110
42
|
|
111
43
|
|
112
44
|
class MCPClient(ToolClient):
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|