diff --git a/lib/crewai/src/crewai/cli/plus_api.py b/lib/crewai/src/crewai/cli/plus_api.py index a3bb11b9f..1bfa59fd9 100644 --- a/lib/crewai/src/crewai/cli/plus_api.py +++ b/lib/crewai/src/crewai/cli/plus_api.py @@ -82,7 +82,7 @@ class PlusAPI: "file": encoded_file, "description": description, "available_exports": available_exports, - "tools_metadata": {"tools": tools_metadata} if tools_metadata else None, + "tools_metadata": {"package": handle, "tools": tools_metadata} if tools_metadata else None, } return self._make_request("POST", f"{self.TOOLS_RESOURCE}", json=params) diff --git a/lib/crewai/src/crewai/cli/tools/main.py b/lib/crewai/src/crewai/cli/tools/main.py index 881fae92a..0228518c7 100644 --- a/lib/crewai/src/crewai/cli/tools/main.py +++ b/lib/crewai/src/crewai/cli/tools/main.py @@ -269,6 +269,8 @@ class ToolCommand(BaseCommand, PlusAPIMixin): for tool in tools_metadata: console.print(f" [bold cyan]{tool.get('name', 'Unknown')}[/bold cyan]") + if tool.get("module"): + console.print(f" Module: {tool.get('module')}") console.print(f" Name: {tool.get('humanized_name', 'N/A')}") console.print(f" Description: {tool.get('description', 'N/A')[:80]}{'...' if len(tool.get('description', '')) > 80 else ''}") diff --git a/lib/crewai/src/crewai/cli/utils.py b/lib/crewai/src/crewai/cli/utils.py index 1a55b05a4..70d10ef65 100644 --- a/lib/crewai/src/crewai/cli/utils.py +++ b/lib/crewai/src/crewai/cli/utils.py @@ -690,8 +690,19 @@ def _extract_single_tool_metadata(tool_class: type) -> dict[str, Any] | None: schema = _unwrap_schema(core_schema) fields = schema.get("schema", {}).get("fields", {}) + try: + file_path = inspect.getfile(tool_class) + relative_path = Path(file_path).relative_to(Path.cwd()) + module_path = relative_path.with_suffix("") + if module_path.parts[0] == "src": + module_path = Path(*module_path.parts[1:]) + module = ".".join(module_path.parts) + except (TypeError, ValueError): + module = tool_class.__module__ + return { "name": tool_class.__name__, + "module": module, "humanized_name": _extract_field_default( fields.get("name"), fallback=tool_class.__name__ ), diff --git a/lib/crewai/tests/cli/test_plus_api.py b/lib/crewai/tests/cli/test_plus_api.py index 901392479..79baeb733 100644 --- a/lib/crewai/tests/cli/test_plus_api.py +++ b/lib/crewai/tests/cli/test_plus_api.py @@ -244,7 +244,7 @@ class TestPlusAPI(unittest.TestCase): "file": encoded_file, "description": description, "available_exports": available_exports, - "tools_metadata": {"tools": tools_metadata}, + "tools_metadata": {"package": handle, "tools": tools_metadata}, } mock_make_request.assert_called_once_with( "POST", "/crewai_plus/api/v1/tools", json=params