Skip to main content
Glama

DBT CLI MCP Server

A Model Context Protocol (MCP) server that wraps the dbt CLI tool, enabling AI coding agents to interact with dbt projects through standardized MCP tools.

Features

  • Execute dbt commands through MCP tools

  • Support for all major dbt operations (run, test, compile, etc.)

  • Command-line interface for direct interaction

  • Environment variable management for dbt projects

  • Configurable dbt executable path

  • Flexible profiles.yml location configuration

Related MCP server: @us-all/dbt-mcp

Installation

Prerequisites

  • Python 3.10 or higher

  • uv tool for Python environment management

  • dbt CLI installed

Setup

# Clone the repository with submodules
git clone --recurse-submodules https://github.com/yourusername/dbt-cli-mcp.git
cd dbt-cli-mcp

# If you already cloned without --recurse-submodules, initialize the submodule
# git submodule update --init

# Create and activate a virtual environment
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
uv pip install -e .

# For development, install development dependencies
uv pip install -e ".[dev]"

Usage

Command Line Interface

The package provides a command-line interface for direct interaction with dbt:

# Run dbt models
dbt-mcp run --models customers --project-dir /path/to/project

# Run dbt models with a custom profiles directory
dbt-mcp run --models customers --project-dir /path/to/project --profiles-dir /path/to/profiles

# List dbt resources
dbt-mcp ls --resource-type model --output-format json

# Run dbt tests
dbt-mcp test --project-dir /path/to/project

# Get help
dbt-mcp --help
dbt-mcp run --help

You can also use the module directly:

python -m src.cli run --models customers --project-dir /path/to/project

Command Line Options

  • --dbt-path: Path to dbt executable (default: "dbt")

  • --env-file: Path to environment file (default: ".env")

  • --log-level: Logging level (default: "INFO")

  • --profiles-dir: Path to directory containing profiles.yml file (defaults to project-dir if not specified)

Environment Variables

The server can also be configured using environment variables:

  • DBT_PATH: Path to dbt executable

  • ENV_FILE: Path to environment file

  • LOG_LEVEL: Logging level

  • DBT_PROFILES_DIR: Path to directory containing profiles.yml file

Using with MCP Clients

To use the server with an MCP client like Claude for Desktop, add it to the client's configuration:

{
  "mcpServers": {
    "dbt": {
      "command": "uv",
      "args": ["--directory", "/path/to/dbt-cli-mcp", "run", "src/server.py"],
      "env": {
        "DBT_PATH": "/absolute/path/to/dbt",
        "ENV_FILE": ".env"
        // You can also set DBT_PROFILES_DIR here for a server-wide default
      }
    }
  }
}

⚠️ IMPORTANT: Absolute Project Path Required ⚠️

When using any tool from this MCP server, you MUST specify the FULL ABSOLUTE PATH to your dbt project directory with the project_dir parameter. Relative paths will not work correctly.

// ❌ INCORRECT - Will NOT work
{
  "project_dir": "."
}

// ✅ CORRECT - Will work
{
  "project_dir": "/Users/username/path/to/your/dbt/project"
}

See the complete dbt MCP usage guide for more detailed instructions and examples.

Available Tools

The server provides the following MCP tools:

  • dbt_run: Run dbt models (requires absolute project_dir)

  • dbt_test: Run dbt tests (requires absolute project_dir)

  • dbt_ls: List dbt resources (requires absolute project_dir)

  • dbt_compile: Compile dbt models (requires absolute project_dir)

  • dbt_debug: Debug dbt project setup (requires absolute project_dir)

  • dbt_deps: Install dbt package dependencies (requires absolute project_dir)

  • dbt_seed: Load CSV files as seed data (requires absolute project_dir)

  • dbt_show: Preview model results (requires absolute project_dir)


### dbt Profiles Configuration

When using the dbt MCP tools, it's important to understand how dbt profiles are handled:

1. The `project_dir` parameter **MUST** be an absolute path (e.g., `/Users/username/project` not `.`) that points to a directory containing both:
   - A valid `dbt_project.yml` file
   - A valid `profiles.yml` file with the profile referenced in the project

2. The MCP server automatically sets the `DBT_PROFILES_DIR` environment variable to the absolute path of the directory specified in `project_dir`. This tells dbt where to look for the profiles.yml file.

3. If you encounter a "Could not find profile named 'X'" error, it means either:
   - The profiles.yml file is missing from the project directory
   - The profiles.yml file doesn't contain the profile referenced in dbt_project.yml
   - You provided a relative path instead of an absolute path for `project_dir`

Example of a valid profiles.yml file:

```yaml
jaffle_shop:  # This name must match the profile in dbt_project.yml
  target: dev
  outputs:
    dev:
      type: duckdb
      path: 'jaffle_shop.duckdb'
      threads: 24

When running commands through the MCP server, ensure your project directory is structured correctly with both configuration files present.

Development

Integration Tests

The project includes integration tests that verify functionality against a real dbt project:

# Run all integration tests
python integration_tests/run_all.py

# Run a specific integration test
python integration_tests/test_dbt_run.py

Test Project Setup

The integration tests use the jaffle_shop_duckdb project which is included as a Git submodule in the dbt_integration_tests directory. When you clone the repository with --recurse-submodules as mentioned in the Setup section, this will automatically be initialized.

If you need to update the test project to the latest version from the original repository:

git submodule update --remote dbt_integration_tests/jaffle_shop_duckdb

If you're seeing errors about missing files in the jaffle_shop_duckdb directory, you may need to initialize the submodule:

git submodule update --init

License

MIT

Available Tools

9 tools
dbt_buildA

Run build command (seeds, tests, snapshots, and models). An AI agent should use this tool when it needs to execute a comprehensive build process that runs seeds, snapshots, models, and tests in the correct order. This is ideal for complete project deployment or ensuring all components work together.

    Returns:
        Output from the dbt build command as text (this command does not support JSON output format)
    

Inputs: models, selector, exclude, project_dir, +2 more. Returns: result

dbt_compileA

Compile dbt models. An AI agent should use this tool when it needs to generate the SQL that will be executed without actually running it against the database. This is valuable for validating SQL syntax, previewing transformations, or investigating how dbt interprets models before committing to execution.

    Returns:
        Output from the dbt compile command as text (this command does not support JSON output format)
    

Inputs: models, selector, exclude, project_dir, +1 more. Returns: result

dbt_debugA

Run dbt debug to validate the project setup. An AI agent should use this tool when it needs to troubleshoot configuration issues, check database connectivity, or verify that all project dependencies are properly installed. This is essential for diagnosing problems before attempting to run models or tests.

    Returns:
        Output from the dbt debug command as text (this command does not support JSON output format)
    

Inputs: project_dir, profiles_dir. Returns: result

dbt_depsA

Install dbt package dependencies. An AI agent should use this tool when it needs to install or update external packages that the dbt project depends on. This ensures that all required modules, macros, and models from other packages are available before running the project.

    Returns:
        Output from the dbt deps command as text (this command does not support JSON output format)
    

Inputs: project_dir, profiles_dir. Returns: result

dbt_lsA

List dbt resources. An AI agent should use this tool when it needs to discover available models, tests, sources, and other resources within a dbt project. This helps the agent understand the project structure, identify dependencies, and select specific resources for other operations like running or testing.

    Returns:
        When output_format is 'json' (default):
          - With verbose=False (default): returns a simplified JSON with only name, resource_type, and depends_on.nodes
          - With verbose=True: returns a full JSON with all resource details
        When output_format is 'name', 'path', or 'selector', returns plain text with the respective format.
    

Inputs: models, selector, exclude, resource_type, +4 more. Returns: result

dbt_runA

Run dbt models. An AI agent should use this tool when it needs to execute dbt models to transform data and build analytical tables in the data warehouse. This is essential for refreshing data or implementing new data transformations in a project.

    Returns:
        Output from the dbt run command as text (this command does not support JSON output format)
    

Inputs: models, selector, exclude, project_dir, +2 more. Returns: result

dbt_seedA

Load CSV files as seed data. An AI agent should use this tool when it needs to load initial data from CSV files into the database. This is essential for creating reference tables, test datasets, or any static data that models will depend on.

    Returns:
        Output from the dbt seed command as text (this command does not support JSON output format)
    

Inputs: selector, exclude, project_dir, profiles_dir. Returns: result

dbt_showA

Preview the results of a model. An AI agent should use this tool when it needs to preview data from a specific model without materializing it. This helps inspect transformation results, debug issues, or demonstrate how data looks after processing without modifying the target database.

    Returns:
        Output from the dbt show command, defaulting to JSON format if not specified
    

Inputs: models (required), project_dir, profiles_dir, limit, +1 more. Returns: result

dbt_testA

Run dbt tests. An AI agent should use this tool when it needs to validate data quality and integrity by running tests defined in a dbt project. This helps ensure that data transformations meet expected business rules and constraints before being used for analysis or reporting.

    Returns:
        Output from the dbt test command as text (this command does not support JSON output format)
    

Inputs: models, selector, exclude, project_dir, +1 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.5/5.0

    Scored across 9 tools

    Disambiguation5/5

    Each tool corresponds to a distinct dbt CLI command with a clear, non-overlapping purpose. The descriptions explicitly differentiate their use cases, such as dbt_build for comprehensive builds versus dbt_run for model execution, preventing agent misselection.

    Naming Consistency5/5

    All tool names follow a consistent 'dbt_' prefix with the exact CLI command name in lowercase, such as dbt_build, dbt_compile, and dbt_debug. This uniform pattern makes the set predictable and easy to navigate for agents.

    Tool Count5/5

    With 9 tools, the server covers core dbt CLI operations without being overwhelming. This count aligns well with the domain, providing essential commands for project management, execution, and validation in a data transformation workflow.

    Completeness5/5

    The tool set offers comprehensive coverage of dbt CLI functionality, including project setup (debug, deps), resource listing (ls), execution (run, build, seed, test), and inspection (compile, show). No obvious gaps exist for typical agent workflows in this domain.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      C
      maintenance
      A read-only MCP server that exposes dbt project artifacts and data quality result tables (BigQuery/Postgres) to LLM clients, enabling deep introspection, run-history analysis, source freshness, test coverage, and lineage walks.
      27
      76 npm
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A minimal, extensible MCP server to run dbt models via CLI, HTTP API, or AI interfaces like Claude, with Slack notifications for task completions.
      1
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server that provides tools to interact with dbt, including dbt Core, Cloud CLI, Semantic Layer, and Discovery API.
      Apache 2.0