mbxai 0.6.17__tar.gz → 0.6.18__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.17 → mbxai-0.6.18}/PKG-INFO +1 -1
- {mbxai-0.6.17 → mbxai-0.6.18}/pyproject.toml +1 -1
- {mbxai-0.6.17 → mbxai-0.6.18}/setup.py +1 -1
- {mbxai-0.6.17 → mbxai-0.6.18}/src/mbxai/mcp/client.py +20 -4
- {mbxai-0.6.17 → mbxai-0.6.18}/uv.lock +7 -7
- {mbxai-0.6.17 → mbxai-0.6.18}/.gitignore +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/LICENSE +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/README.md +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/src/mbxai/__init__.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/src/mbxai/core.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/src/mbxai/mcp/__init__.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/src/mbxai/mcp/example.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/src/mbxai/mcp/server.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/src/mbxai/openrouter/__init__.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/src/mbxai/openrouter/client.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/src/mbxai/openrouter/config.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/src/mbxai/openrouter/models.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/src/mbxai/tools/__init__.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/src/mbxai/tools/client.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/src/mbxai/tools/example.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/src/mbxai/tools/types.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/tests/test_core.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/tests/test_mcp.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/tests/test_openrouter.py +0 -0
- {mbxai-0.6.17 → mbxai-0.6.18}/tests/test_tools.py +0 -0
@@ -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)}")
|
@@ -292,11 +292,11 @@ wheels = [
|
|
292
292
|
|
293
293
|
[[package]]
|
294
294
|
name = "httpx-sse"
|
295
|
-
version = "0.6.
|
295
|
+
version = "0.6.18"
|
296
296
|
source = { registry = "https://pypi.org/simple" }
|
297
|
-
sdist = { url = "https://files.pythonhosted.org/packages/4c/60/8f4281fa9bbf3c8034fd54c0e7412e66edbab6bc74c4996bd616f8d0406e/httpx-sse-0.6.
|
297
|
+
sdist = { url = "https://files.pythonhosted.org/packages/4c/60/8f4281fa9bbf3c8034fd54c0e7412e66edbab6bc74c4996bd616f8d0406e/httpx-sse-0.6.18.tar.gz", hash = "sha256:1e81a3a3070ce322add1d3529ed42eb5f70817f45ed6ec915ab753f961139721", size = 12624 }
|
298
298
|
wheels = [
|
299
|
-
{ url = "https://files.pythonhosted.org/packages/e1/9b/a181f281f65d776426002f330c31849b86b31fc9d848db62e16f03ff739f/httpx_sse-0.6.
|
299
|
+
{ url = "https://files.pythonhosted.org/packages/e1/9b/a181f281f65d776426002f330c31849b86b31fc9d848db62e16f03ff739f/httpx_sse-0.6.18-py3-none-any.whl", hash = "sha256:f329af6eae57eaa2bdfd962b42524764af68075ea87370a2de920af5341e318f", size = 7819 },
|
300
300
|
]
|
301
301
|
|
302
302
|
[[package]]
|
@@ -446,7 +446,7 @@ wheels = [
|
|
446
446
|
|
447
447
|
[[package]]
|
448
448
|
name = "mbxai"
|
449
|
-
version = "0.6.
|
449
|
+
version = "0.6.18"
|
450
450
|
source = { editable = "." }
|
451
451
|
dependencies = [
|
452
452
|
{ name = "fastapi" },
|
@@ -980,14 +980,14 @@ wheels = [
|
|
980
980
|
|
981
981
|
[[package]]
|
982
982
|
name = "typing-inspection"
|
983
|
-
version = "0.6.
|
983
|
+
version = "0.6.18"
|
984
984
|
source = { registry = "https://pypi.org/simple" }
|
985
985
|
dependencies = [
|
986
986
|
{ name = "typing-extensions" },
|
987
987
|
]
|
988
|
-
sdist = { url = "https://files.pythonhosted.org/packages/82/5c/e6082df02e215b846b4b8c0b887a64d7d08ffaba30605502639d44c06b82/typing_inspection-0.6.
|
988
|
+
sdist = { url = "https://files.pythonhosted.org/packages/82/5c/e6082df02e215b846b4b8c0b887a64d7d08ffaba30605502639d44c06b82/typing_inspection-0.6.18.tar.gz", hash = "sha256:9765c87de36671694a67904bf2c96e395be9c6439bb6c87b5142569dcdd65122", size = 76222 }
|
989
989
|
wheels = [
|
990
|
-
{ url = "https://files.pythonhosted.org/packages/31/08/aa4fdfb71f7de5176385bd9e90852eaf6b5d622735020ad600f2bab54385/typing_inspection-0.6.
|
990
|
+
{ url = "https://files.pythonhosted.org/packages/31/08/aa4fdfb71f7de5176385bd9e90852eaf6b5d622735020ad600f2bab54385/typing_inspection-0.6.18-py3-none-any.whl", hash = "sha256:50e72559fcd2a6367a19f7a7e610e6afcb9fac940c650290eed893d61386832f", size = 14125 },
|
991
991
|
]
|
992
992
|
|
993
993
|
[[package]]
|
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
|
File without changes
|
File without changes
|