Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/mcpadapt/smolagents_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,15 @@ def adapt(
if k != "$defs"
}

# Parameter-less tools may omit `properties`; treat that as an empty object schema.
properties = input_schema.setdefault("properties", {})

# make sure mandatory `description` and `type` is provided for each arguments:
for k, v in input_schema["properties"].items():
for k, v in properties.items():
if "description" not in v:
input_schema["properties"][k]["description"] = "see tool description"
properties[k]["description"] = "see tool description"
if "type" not in v:
input_schema["properties"][k]["type"] = "string"
properties[k]["type"] = "string"

# Extract and resolve outputSchema if present (only if structured_output=True)
output_schema = None
Expand Down Expand Up @@ -235,7 +238,7 @@ def forward(
tool = MCPAdaptTool(
name=mcp_tool.name,
description=mcp_tool.description or "",
inputs=input_schema["properties"],
inputs=properties,
output_type=output_type,
output_schema=output_schema,
structured_output=self.structured_output,
Expand Down
27 changes: 27 additions & 0 deletions tests/test_smolagents_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,33 @@ def test_optional_sync(echo_server_optional_script):
assert tools[2](text="hello") == "Echo: hello"


def test_tool_with_no_input_parameters():
mcp_server_script = dedent(
'''
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("Version Server")

@mcp.tool()
def server_version() -> str:
"""Return the server version."""
return "1.0.0"

mcp.run()
'''
)
with MCPAdapt(
StdioServerParameters(
command="uv", args=["run", "python", "-c", mcp_server_script]
),
SmolAgentsAdapter(),
) as tools:
assert len(tools) == 1
assert tools[0].name == "server_version"
assert tools[0].inputs == {}
assert tools[0]() == "1.0.0"


def test_tool_name_with_dashes():
mcp_server_script = dedent(
'''
Expand Down