The dbt MCP server implements the Model Context Protocol to provide interaction tools for dbt, enabling AI assistants to access and control dbt functionality through standard interfaces.
Before installing the dbt MCP server, you'll need:
git clone https://github.com/dbt-labs/dbt-mcp.git
cd dbt-mcp
task install
cp .env.example .env
.env
file to configure your environment variables according to your needs.You can enable or disable specific tool groups with these environment variables:
Name | Default | Description |
---|---|---|
DISABLE_DBT_CLI |
false |
Set to true to disable dbt Core and dbt Cloud CLI tools |
DISABLE_SEMANTIC_LAYER |
false |
Set to true to disable dbt Semantic Layer objects |
DISABLE_DISCOVERY |
false |
Set to true to disable dbt Discovery API objects |
DISABLE_REMOTE |
true |
Set to false to enable remote MCP objects |
Name | Default | Description |
---|---|---|
DBT_HOST |
cloud.getdbt.com |
Your dbt Cloud instance hostname |
MULTICELL_ACCOUNT_PREFIX |
- | Your account prefix if using Multi-cell |
DBT_TOKEN |
- | Your personal access token or service token (service token required for Semantic Layer) |
DBT_PROD_ENV_ID |
- | Your dbt Cloud production environment ID |
Name | Description |
---|---|
DBT_DEV_ENV_ID |
Your dbt Cloud development environment ID |
DBT_USER_ID |
Your dbt Cloud user ID |
Name | Description |
---|---|
DBT_PROJECT_DIR |
Path to your local dbt project repository |
DBT_PATH |
Path to your dbt Core or dbt Cloud CLI executable |
After installation, you can connect your MCP server to various clients using the following configuration pattern:
{
"mcpServers": {
"dbt-mcp": {
"command": "<path-to-mcp-executable>",
"args": [
"run",
"<path-to-this-directory>/src/dbt_mcp/main.py"
]
}
}
}
The path to your MCP executable depends on your operating system:
<path-to-this-directory>/.venv/bin/mcp
<path-to-this-directory>/.venv/Scripts/mcp
To use with Claude Desktop:
claude_desktop_config.json
fileClaude Desktop logs can be found at ~/Library/Logs/Claude
on Mac.
mcp.json
filesettings.json
file:{
"mcp": {
"inputs": [],
"servers": {
"dbt": {
"command": "<path-to-mcp-executable>",
"args": ["run", "<path-to-this-directory>/src/dbt_mcp/main.py"]
}
}
}
}
MCP: List Servers
command from the Command Palettesettings.json
filebuild
- Executes models, tests, snapshots, and seeds in dependency ordercompile
- Generates executable SQL from models, tests, and analysesdocs
- Generates documentation for the dbt projectls
- Lists resources in the dbt projectparse
- Parses and validates project filesrun
- Executes models to materialize them in the databasetest
- Runs tests to validate data and model integrityshow
- Runs a query against the data warehouselist_metrics
- Retrieves all defined metricsget_dimensions
- Gets dimensions associated with specified metricsget_entities
- Gets entities associated with specified metricsquery_metrics
- Queries metrics with optional grouping, ordering, filtering, and limitingget_mart_models
- Gets all mart modelsget_all_models
- Gets all modelsget_model_details
- Gets details for a specific modelget_model_parents
- Gets parent nodes of a specific modelget_model_children
- Gets children modes of a specific modelThere are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.