Skip to content
Closed
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
8 changes: 6 additions & 2 deletions src/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@


@mcp.tool()
def echo_tool(text: str = Field(description="The text to echo")) -> str:
def echo_tool(
id: int | float | None,
text: str = Field(description="The text to echo"),
) -> str:
"""Echo the input text

Args:
id (int|float|None): (Optional) Id
text (str): The text to echo

Returns:
str: The echoed text
"""
return text
return f"echo_tool({id},{text})"


@mcp.resource("echo://static")
Expand Down
11 changes: 5 additions & 6 deletions src/mcpadapt/crewai_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ def _run(self, *args: Any, **kwargs: Any) -> Any:
filtered_kwargs: dict[str, Any] = {}
schema_properties = mcp_tool.inputSchema.get("properties", {})

for key, value in kwargs.items():
if value is None and key in schema_properties:
prop_schema = schema_properties[key]
for key, prop_schema in schema_properties.items():
if not key in kwargs:
# Check if the property allows null
# Simple check: if type is a list containing "null" or anyOf includes null
if isinstance(prop_schema.get("type"), list):
Expand All @@ -81,10 +80,10 @@ def _run(self, *args: Any, **kwargs: Any) -> Any:
opt.get("type") == "null"
for opt in prop_schema["anyOf"]
):
filtered_kwargs[key] = value
filtered_kwargs[key] = prop_schema.get("default", None)
# If neither case allows null, skip the None value
else:
filtered_kwargs[key] = value
filtered_kwargs[key] = kwargs[key]

return func(filtered_kwargs).content[0].text # type: ignore

Expand Down Expand Up @@ -118,4 +117,4 @@ async def async_adapt(
CrewAIAdapter(),
) as tools:
print(tools)
print(tools[0].run(text="hello"))
assert tools[0].run(text="hello") == "echo_tool(None,hello)"