You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When loading an MCP tool (e.g. mcp_server_tavily), an exception occurs in _generate_tool_inputs(...). key "type" is not found.
Code to reproduce the error
# Load an MCP server like so
server_parameters = StdioServerParameters(
command="python",
args=["mcp_server_tavily.py"],
)
# then see what tools it exposes
with ToolCollection.from_mcp(server_parameters) as toolset:
for tool in [*toolset.tools]:
print(tool.name)
Error logs (if any)
File ".../lib/python3.11/site-packages/mcpadapt/smolagents_adapter.py", line 30, in <dictcomp>
k: {"type": v["type"], "description": v.get("description", "")}
~^^^^^^^^
KeyError: 'type'
Expected behavior
No exception
Packages version:
smolagents==1.8.1
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
This edit fixed the exception, but I am not sure if it causes a regression:
def _generate_tool_inputs(resolved_json_schema: dict[str, Any]) -> dict[str, str]:
"""
takes an json_schema as used in the MCP protocol and return an inputs dict for
smolagents tools. see AUTHORIZED_TYPES in smolagents.tools for the types allowed.
Note that we consider the json_schema to already have $ref resolved with jsonref for
example.
"""
# debuging
items = resolved_json_schema.items()
print(items)
return {
# TODO: use google-docstring-parser to parse description of args and pass it here...
k: {"type": v["type"] if "type" in v else "object", "description": v.get("description", "")}
for k, v in resolved_json_schema.items()
}
Describe the bug
When loading an MCP tool (e.g. mcp_server_tavily), an exception occurs in _generate_tool_inputs(...). key "type" is not found.
Code to reproduce the error
Error logs (if any)
Expected behavior
No exception
Packages version:
smolagents==1.8.1
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: