diff --git a/src/echo.py b/src/echo.py index 69d783f..e6ce4b0 100644 --- a/src/echo.py +++ b/src/echo.py @@ -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") diff --git a/src/mcpadapt/crewai_adapter.py b/src/mcpadapt/crewai_adapter.py index 3ebef56..4f2d82e 100644 --- a/src/mcpadapt/crewai_adapter.py +++ b/src/mcpadapt/crewai_adapter.py @@ -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): @@ -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 @@ -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)"