Metadata-Version: 2.4
Name: dbt-mcp
Version: 0.1.3
Summary: A MCP (Model Context Protocol) server for interacting with dbt resources.
Project-URL: Documentation, https://github.com/dbt-labs/dbt-mcp#readme
Project-URL: Issues, https://github.com/dbt-labs/dbt-mcp/issues
Project-URL: Source, https://github.com/dbt-labs/dbt-mcp
Author: dbt Labs
License: Copyright 2025 dbt Labs
        
        Licensed under the Apache License, Version 2.0 (the "License");
        you may not use this file except in compliance with the License.
        You may obtain a copy of the License at
        
            http://www.apache.org/licenses/LICENSE-2.0
        
        Unless required by applicable law or agreed to in writing, software
        distributed under the License is distributed on an "AS IS" BASIS,
        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        See the License for the specific language governing permissions and
        limitations under the License.
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.12
Requires-Dist: dbt-sl-sdk[sync]==0.11.0
Requires-Dist: mcp[cli]==1.6.0
Requires-Dist: pandas==2.2.3
Requires-Dist: python-dotenv==1.0.1
Requires-Dist: requests==2.32.3
Description-Content-Type: text/markdown

# dbt MCP Server

This MCP (Model Context Protocol) server provides tools to interact with dbt. Read [this](https://docs.getdbt.com/blog/introducing-dbt-mcp-server) blog to learn more.

## Architecture

![architecture diagram of the dbt MCP server](https://github.com/user-attachments/assets/89b8a24b-da7b-4e54-ba48-afceaa56f956)

## Installation

Want to get going quickly?

```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/dbt-labs/dbt-mcp/refs/heads/main/install.sh)"
```
The installer also serves as an updater, simply run it again and it will detect your exisiting dbt-mcp installation and offers to update it.

## Configuration

The MCP server takes the following configuration:


### Tool Groups
| Name | Default | Description |
|------|---------|-------------|
| `DISABLE_DBT_CLI` | `false` | Set this to `true` to disable dbt Core and dbt Cloud CLI MCP tools |
| `DISABLE_SEMANTIC_LAYER` | `false` | Set this to `true` to disable dbt Semantic Layer MCP objects |
| `DISABLE_DISCOVERY` | `false` | Set this to `true` to disable dbt Discovery API MCP objects |
| `DISABLE_REMOTE` | `true` | Set this to `false` to enable remote MCP objects |


### Configuration for Discovery and Semantic Layer
| Name | Default | Description |
|------|---------|-------------|
| `DBT_HOST` | `cloud.getdbt.com` | Your dbt Cloud instance hostname. This will look like an `Access URL` found [here](https://docs.getdbt.com/docs/cloud/about-cloud/access-regions-ip-addresses). If you are using Multi-cell, do not include the `ACCOUNT_PREFIX` here |
| `MULTICELL_ACCOUNT_PREFIX` | - | If you are using Multi-cell, set this to your `ACCOUNT_PREFIX`. If you are not using Multi-cell, do not set this environment variable. You can learn more [here](https://docs.getdbt.com/docs/cloud/about-cloud/access-regions-ip-addresses) |
| `DBT_TOKEN` | - | Your personal access token or service token. **Note** Service token is required when using the Semantic Layer |
| `DBT_PROD_ENV_ID` | - | Your dbt Cloud production environment ID |

### Configuration for Remote Tools
| Name | Description |
|------|-------------|
| `DBT_DEV_ENV_ID` | Your dbt Cloud development environment ID |
| `DBT_USER_ID` | Your dbt Cloud user ID |

### Configuration for dbt CLI
| Name | Description |
|------|-------------|
| `DBT_PROJECT_DIR` | The path to your dbt Project |
| `DBT_PATH` | The path to your dbt Core or dbt Cloud CLI executable. You can find your dbt executable by running `which dbt` |

## Using with MCP Clients

After going through [Installation](#installation), you can use your server with an MCP client.

This configuration will be added to the respective client's config file. Be sure to replace the sections within `<>`:

If you used the installation script, the mcp server has been installed in your user directory at `~/.dbt-mcp/`.

```json
 {
  "mcpServers": {
    "dbt-mcp": {
      "command": "/Users/<YOUR USERNAME>/.dbt-mcp/.venv/bin/mcp",
      "args": [
        "run",
        "/Users/<YOUR USERNAME>/.dbt-mcp/.venv/lib/python3.12/site-packages/dbt_mcp/main.py"
      ],
      "env": {
        // see config above
        // "DBT_HOST": "cloud.getdbt.com"
        // "DBT_TOKEN": "dbtu_...."
      }
    }
  }
}
```

`<path-to-mcp-executable>` depends on your OS:
- Linux & Mac: `<path-to-this-directory>/.venv/bin/mcp`
- PC: `<path-to-this-directory>/.venv/Scripts/mcp`


## Claude Desktop

Follow [these](https://modelcontextprotocol.io/quickstart/user) instructions to create the `claude_desktop_config.json` file and connect.

On Mac, you can find the Claude Desktop logs at `~/Library/Logs/Claude`.

## Cursor

1. Open the Cursor menu and select Settings → Cursor Settings → MCP
2. Click "Add new global MCP server"
3. Add the config from above to the provided `mcp.json` file
4. Verify your connection is active within the MCP tab

Cursor MCP docs [here](https://docs.cursor.com/context/model-context-protocol) for reference

## VS Code

1. Open the Settings menu (Command + Comma) and select the correct tab atop the page for your use case
    - `Workspace` - configures the server in the context of your workspace
    - `User` - configures the server in the context of your user

2. Select Features → Chat

3. Ensure that "Mcp" is `Enabled`

![mcp-vscode-settings](https://github.com/user-attachments/assets/3d3fa853-2398-422a-8a6d-7f0a97120aba)

4. Click "Edit in settings.json" under "Mcp > Discovery"

5. Add your server configuration (`dbt`) to the provided `settings.json` file as one of the servers:
```json
{
    "mcp": {
        "inputs": [],
        "servers": {
          "dbt": {
            "command": "<path-to-mcp-executable>",
            "args": ["run", "<path-to-this-directory>/src/dbt_mcp/main.py"]
          }
        }
    }
}
```

`<path-to-mcp-executable>` depends on your OS:
- Linux & Mac: `<path-to-this-directory>/.venv/bin/mcp`
- PC: `<path-to-this-directory>/.venv/Scripts/mcp`

6. You can start, stop, and configure your MCP servers by:
- Running the `MCP: List Servers` command from the Command Palette (Control + Command + P) and selecting the server
- Utlizing the keywords inline within the `settings.json` file

![inline-management](https://github.com/user-attachments/assets/d33d4083-5243-4b36-adab-72f12738c263)

VS Code MCP docs [here](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) for reference

## Tools

### dbt CLI

* `build` - Executes models, tests, snapshots, and seeds in dependency order
* `compile` - Generates executable SQL from models, tests, and analyses without running them
* `docs` - Generates documentation for the dbt project
* `ls` (list) - Lists resources in the dbt project, such as models and tests
* `parse` - Parses and validates the project’s files for syntax correctness
* `run` -  Executes models to materialize them in the database
* `test` - Runs tests to validate data and model integrity
* `show` - Runs a query against the data warehouse

> Allowing your client to utilize dbt commands through this MCP tooling could modify your data models, sources, and warehouse objects. Proceed only if you trust the client and understand the potential impact.


### Semantic Layer

* `list_metrics` - Retrieves all defined metrics
* `get_dimensions` - Gets dimensions associated with specified metrics
* `get_entities` - Gets entities associated with specified metrics
* `query_metrics` - Queries metrics with optional grouping, ordering, filtering, and limiting


### Discovery
* `get_mart_models` - Gets all mart models
* `get_all_models` - Gets all models
* `get_model_details` - Gets details for a specific model
* `get_model_parents` - Gets parent models of a specific model


## Contributing

Read `CONTRIBUTING.md` for instructions on how to get involved!
