install_deps
Install dbt packages defined in packages.yml to enable using their macros in your DBT project during interactive development.
Instructions
Install dbt packages defined in packages.yml.
This tool enables interactive workflow where an LLM can:
Suggest using a dbt package (e.g., dbt_utils)
Edit packages.yml to add the package
Run install_deps() to install it
Write code that uses the package's macros
This completes the recommendation workflow without breaking conversation flow.
Returns: Installation results with status and installed packages
Example workflow: User: "Create a date dimension table" LLM: 1. Checks: list_resources(type="macro") -> no dbt_utils 2. Edits: packages.yml (adds dbt_utils package) 3. Runs: install_deps() (installs package) 4. Creates: models/date_dim.sql (uses dbt_utils.date_spine)
Note: This is an interactive development tool, not infrastructure automation. It enables the LLM to act on its own recommendations mid-conversation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/dbt_core_mcp/server.py:1232-1273 (handler)The core handler function that runs 'dbt deps' to install packages from packages.yml, reloads the manifest, detects installed packages by scanning macros, and returns success status with list of packages.async def toolImpl_install_deps(self) -> dict[str, Any]: """Implementation of install_deps tool.""" # Execute dbt deps logger.info("Running dbt deps to install packages") result = await self.runner.invoke(["deps"]) # type: ignore if not result.success: error_msg = str(result.exception) if result.exception else "deps failed" return { "status": "error", "message": error_msg, "command": "dbt deps", } # Reload manifest to pick up newly installed packages logger.info("Reloading manifest to include new packages") await self.manifest.load() # type: ignore # Get list of installed packages by checking for package macros installed_packages = set() assert self.manifest is not None manifest_dict = self.manifest.get_manifest_dict() macros = manifest_dict.get("macros", {}) project_name = manifest_dict.get("metadata", {}).get("project_name", "") for unique_id in macros: # macro.package_name.macro_name format if unique_id.startswith("macro."): parts = unique_id.split(".") if len(parts) >= 2: package_name = parts[1] # Exclude built-in dbt package and project package if package_name != "dbt" and package_name != project_name: installed_packages.add(package_name) return { "status": "success", "command": "dbt deps", "installed_packages": sorted(installed_packages), "message": f"Successfully installed {len(installed_packages)} package(s)", }
- src/dbt_core_mcp/server.py:1719-1746 (registration)FastMCP tool registration decorator and wrapper function that handles context initialization and delegates to the toolImpl_install_deps handler.@self.app.tool() async def install_deps(ctx: Context) -> dict[str, Any]: """Install dbt packages defined in packages.yml. This tool enables interactive workflow where an LLM can: 1. Suggest using a dbt package (e.g., dbt_utils) 2. Edit packages.yml to add the package 3. Run install_deps() to install it 4. Write code that uses the package's macros This completes the recommendation workflow without breaking conversation flow. Returns: Installation results with status and installed packages Example workflow: User: "Create a date dimension table" LLM: 1. Checks: list_resources(type="macro") -> no dbt_utils 2. Edits: packages.yml (adds dbt_utils package) 3. Runs: install_deps() (installs package) 4. Creates: models/date_dim.sql (uses dbt_utils.date_spine) Note: This is an interactive development tool, not infrastructure automation. It enables the LLM to act on its own recommendations mid-conversation. """ await self._ensure_initialized_with_context(ctx) return await self.toolImpl_install_deps()