From fa831e29c609fd035eaea9acb72d2040df6823eb Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 1 Apr 2026 17:55:53 -0700 Subject: [PATCH] fix: add tool repository credentials to uv build in tool publish When running 'uv build' during tool publish, the build process now has access to tool repository credentials. This mirrors the pattern used in run_crew.py, ensuring private package indexes are properly authenticated during the build. Co-Authored-By: Claude Opus 4.5 --- lib/crewai/src/crewai/cli/tools/main.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/crewai/src/crewai/cli/tools/main.py b/lib/crewai/src/crewai/cli/tools/main.py index 72c1e6e25..67a508e64 100644 --- a/lib/crewai/src/crewai/cli/tools/main.py +++ b/lib/crewai/src/crewai/cli/tools/main.py @@ -21,6 +21,7 @@ from crewai.cli.utils import ( get_project_description, get_project_name, get_project_version, + read_toml, tree_copy, tree_find_and_replace, ) @@ -116,11 +117,26 @@ class ToolCommand(BaseCommand, PlusAPIMixin): self._print_tools_preview(tools_metadata) self._print_current_organization() + build_env = os.environ.copy() + try: + pyproject_data = read_toml() + sources = pyproject_data.get("tool", {}).get("uv", {}).get("sources", {}) + + for source_config in sources.values(): + if isinstance(source_config, dict): + index = source_config.get("index") + if index: + index_env = build_env_with_tool_repository_credentials(index) + build_env.update(index_env) + except Exception: # noqa: S110 + pass + with tempfile.TemporaryDirectory() as temp_build_dir: subprocess.run( # noqa: S603 ["uv", "build", "--sdist", "--out-dir", temp_build_dir], # noqa: S607 check=True, capture_output=False, + env=build_env, ) tarball_filename = next(