configuring-dbt-mcp-server by dbt-labs/dbt-agent-skills
npx skills add https://github.com/dbt-labs/dbt-agent-skills --skill configuring-dbt-mcp-serverdbt MCP 服务器将 AI 工具连接到 dbt 的 CLI、语义层、发现 API 和管理 API。本技能将指导用户根据其使用场景进行正确的设置配置。
flowchart TB
start([用户想要 dbt MCP]) --> q1{本地还是远程?}
q1 -->|开发工作流,<br>需要 CLI 访问| local[本地服务器<br>uvx dbt-mcp]
q1 -->|仅用于消费,<br>无需本地安装| remote[远程服务器<br>HTTP 端点]
local --> q2{使用哪个客户端?}
remote --> q2
q2 --> claude_desktop[Claude Desktop]
q2 --> claude_code[Claude Code]
q2 --> cursor[Cursor]
q2 --> vscode[VS Code]
claude_desktop --> config[生成配置<br>+ 测试设置]
claude_code --> config
cursor --> config
vscode --> config
询问: "您想使用本地还是远程 dbt MCP 服务器?"
| 本地服务器 | 远程服务器 |
|---|---|
通过 uvx 在您的机器上运行 | 通过 HTTP 连接到 dbt 平台 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 开发(编写模型、测试、文档)所必需,但也可以连接到 dbt 平台进行消费(查询指标、探索元数据) | 最适合消费(查询指标、探索元数据) |
| 支持 dbt CLI 命令(run, build, test, show) | 不支持 CLI 命令(run, build, test) |
| 无需 dbt 平台账户即可工作,但也可以连接到 dbt 平台进行开发(编写模型、测试、文档) | 需要 dbt 平台账户 |
| 不消耗点数 | 消耗 dbt Copilot 点数 |
询问: "您正在使用哪个 MCP 客户端?"
询问: "您的使用场景是什么?"
| 仅 CLI | 仅平台 | 平台 + CLI |
|---|---|---|
| dbt Core/Fusion 用户 | 没有本地项目的 dbt Cloud | 完全访问两者 |
| 无需平台账户 | OAuth 或令牌认证 | 需要路径 + 凭据 |
询问: "您想启用哪些工具?"(显示默认值)
| 工具类别 | 默认 | 环境变量 |
|---|---|---|
| dbt CLI (run, build, test, compile) | 已启用 | DISABLE_DBT_CLI=true 以禁用 |
| 语义层 (metrics, dimensions) | 已启用 | DISABLE_SEMANTIC_LAYER=true 以禁用 |
| 发现 API (models, lineage) | 已启用 | DISABLE_DISCOVERY=true 以禁用 |
| 管理 API (jobs, runs) | 已启用 | DISABLE_ADMIN_API=true 以禁用 |
| SQL (text_to_sql, execute_sql) | 已禁用 | DISABLE_SQL=false 以启用 |
| 代码生成 (generate models/sources) | 已禁用 | DISABLE_DBT_CODEGEN=false 以启用 |
uv:https://docs.astral.sh/uv/getting-started/installation/DBT_PROJECT_DIR:包含 dbt_project.yml 的文件夹
pwdC:/Users/name/project)DBT_PATH:dbt 可执行文件的路径
which dbtwhere dbt有关获取令牌和 ID 的详细指导,请参阅如何查找您的凭据。
${DBT_TOKEN}),而不是在可能提交到版本控制的配置文件中使用字面令牌值.env 文件时,确保它们已添加到 .gitignore 中,以防止意外提交{
"mcpServers": {
"dbt": {
"command": "uvx",
"args": ["dbt-mcp"],
"env": {
"DBT_PROJECT_DIR": "/path/to/your/dbt/project",
"DBT_PATH": "/path/to/dbt"
}
}
}
}
{
"mcpServers": {
"dbt": {
"command": "uvx",
"args": ["dbt-mcp"],
"env": {
"DBT_HOST": "https://your-subdomain.us1.dbt.com",
"DBT_PROJECT_DIR": "/path/to/project",
"DBT_PATH": "/path/to/dbt"
}
}
}
}
{
"mcpServers": {
"dbt": {
"command": "uvx",
"args": ["dbt-mcp"],
"env": {
"DBT_HOST": "cloud.getdbt.com",
"DBT_TOKEN": "${DBT_TOKEN}",
"DBT_ACCOUNT_ID": "${DBT_ACCOUNT_ID}",
"DBT_PROD_ENV_ID": "${DBT_PROD_ENV_ID}",
"DBT_PROJECT_DIR": "/path/to/project",
"DBT_PATH": "/path/to/dbt"
}
}
}
}
{
"mcpServers": {
"dbt": {
"command": "uvx",
"args": ["--env-file", "/path/to/.env", "dbt-mcp"]
}
}
}
.env 文件内容:
DBT_HOST=cloud.getdbt.com
DBT_TOKEN=<set-via-env-or-secret-manager>
DBT_ACCOUNT_ID=<your-account-id>
DBT_PROD_ENV_ID=<your-prod-env-id>
DBT_DEV_ENV_ID=<your-dev-env-id>
DBT_USER_ID=<your-user-id>
DBT_PROJECT_DIR=/path/to/project
DBT_PATH=/path/to/dbt
{
"mcpServers": {
"dbt": {
"url": "https://cloud.getdbt.com/api/ai/v1/mcp/",
"headers": {
"Authorization": "Token ${DBT_TOKEN}",
"x-dbt-prod-environment-id": "${DBT_PROD_ENV_ID}"
}
}
}
}
用于 SQL/Fusion 工具的附加请求头:
{
"headers": {
"Authorization": "Token ${DBT_TOKEN}",
"x-dbt-prod-environment-id": "${DBT_PROD_ENV_ID}",
"x-dbt-dev-environment-id": "${DBT_DEV_ENV_ID}",
"x-dbt-user-id": "${DBT_USER_ID}"
}
}
配置位置:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json运行:
claude mcp add dbt -s user -- uvx dbt-mcp
这将服务器添加到您的用户范围/配置(在此系统上:~/.claude.json)。
对于项目特定的设置,运行:
claude mcp add dbt -s project -- uvx dbt-mcp
这将服务器添加到您项目根目录的 .mcp.json 中。
或者,您可以使用下面的手动配置。
手动配置: 编辑 ~/.claude.json(用户范围)或在项目根目录创建 .mcp.json(项目范围):
~/.claude.json:在所有项目中全局生效.mcp.json:项目特定,可以提交到版本控制以便团队共享。如果使用令牌认证,请使用环境变量引用——切勿提交字面令牌。对于项目特定的 dbt 设置,请使用 .mcp.json,以便您的团队共享相同的配置。
创建配置后,确保将 JSON 配置添加到 mcpServers 键下。
servers 而不是 mcpServers):{
"servers": {
"dbt": {
"command": "uvx",
"args": ["dbt-mcp"],
"env": {
"DBT_PROJECT_DIR": "/path/to/project",
"DBT_PATH": "/path/to/dbt"
}
}
}
}
WSL 用户: 在远程设置中配置,而不是本地用户设置:
/home/user/project,而不是 Windows 路径)推荐:使用 .env 文件
DBT_PROJECT_DIR=/path/to/project
DBT_PATH=/path/to/dbt
uvx --env-file .env dbt-mcp
替代方案:环境变量
# 临时测试(变量仅在此会话中有效)
export DBT_PROJECT_DIR=/path/to/project
export DBT_PATH=/path/to/dbt
uvx dbt-mcp
没有错误 = 配置成功。
设置完成后,询问 AI:
常见问题和修复方法,请参阅故障排除。
支持变量的完整列表,请参阅环境变量参考。
每周安装数
125
代码仓库
GitHub Stars
322
首次出现
2026年1月29日
安全审计
已安装于
github-copilot74
codex72
opencode72
gemini-cli71
amp69
kimi-cli69
The dbt MCP server connects AI tools to dbt's CLI, Semantic Layer, Discovery API, and Admin API. This skill guides users through setup with the correct configuration for their use case.
flowchart TB
start([User wants dbt MCP]) --> q1{Local or Remote?}
q1 -->|dev workflows,<br>CLI access needed| local[Local Server<br>uvx dbt-mcp]
q1 -->|consumption only,<br>no local install| remote[Remote Server<br>HTTP endpoint]
local --> q2{Which client?}
remote --> q2
q2 --> claude_desktop[Claude Desktop]
q2 --> claude_code[Claude Code]
q2 --> cursor[Cursor]
q2 --> vscode[VS Code]
claude_desktop --> config[Generate config<br>+ test setup]
claude_code --> config
cursor --> config
vscode --> config
Ask: "Do you want to use the local or remote dbt MCP server?"
| Local Server | Remote Server |
|---|---|
Runs on your machine via uvx | Connects via HTTP to dbt platform |
| Required for development (authoring models, tests, docs) but can also connect to the dbt platform for consumption (querying metrics, exploring metadata) | Best for consumption (querying metrics, exploring metadata) |
| Supports dbt CLI commands (run, build, test, show) | No CLI commands (run, build, test) |
| Works without a dbt platform account but can also connect to the dbt platform for development (authoring models, tests, docs) | Requires dbt platform account |
| No credit consumption | Consumes dbt Copilot credits |
Ask: "Which MCP client are you using?"
Ask: "What's your use case?"
| CLI Only | Platform Only | Platform + CLI |
|---|---|---|
| dbt Core/Fusion users | dbt Cloud without local project | Full access to both |
| No platform account needed | OAuth or token auth | Requires paths + credentials |
Ask: "Which tools do you want enabled?" (show defaults)
| Tool Category | Default | Environment Variable |
|---|---|---|
| dbt CLI (run, build, test, compile) | Enabled | DISABLE_DBT_CLI=true to disable |
| Semantic Layer (metrics, dimensions) | Enabled | DISABLE_SEMANTIC_LAYER=true to disable |
| Discovery API (models, lineage) | Enabled | DISABLE_DISCOVERY=true to disable |
| Admin API (jobs, runs) | Enabled | DISABLE_ADMIN_API=true to disable |
| SQL (text_to_sql, execute_sql) | Disabled | to enable |
uv: https://docs.astral.sh/uv/getting-started/installation/DBT_PROJECT_DIR: Folder containing dbt_project.yml
pwd from project folderC:/Users/name/project)DBT_PATH: Path to dbt executable
which dbtwhere dbtSee How to Find Your Credentials for detailed guidance on obtaining tokens and IDs.
${DBT_TOKEN}) instead of literal token values in configuration files that may be committed to version control.env files, ensure they are added to .gitignore to prevent accidental commits{
"mcpServers": {
"dbt": {
"command": "uvx",
"args": ["dbt-mcp"],
"env": {
"DBT_PROJECT_DIR": "/path/to/your/dbt/project",
"DBT_PATH": "/path/to/dbt"
}
}
}
}
{
"mcpServers": {
"dbt": {
"command": "uvx",
"args": ["dbt-mcp"],
"env": {
"DBT_HOST": "https://your-subdomain.us1.dbt.com",
"DBT_PROJECT_DIR": "/path/to/project",
"DBT_PATH": "/path/to/dbt"
}
}
}
}
{
"mcpServers": {
"dbt": {
"command": "uvx",
"args": ["dbt-mcp"],
"env": {
"DBT_HOST": "cloud.getdbt.com",
"DBT_TOKEN": "${DBT_TOKEN}",
"DBT_ACCOUNT_ID": "${DBT_ACCOUNT_ID}",
"DBT_PROD_ENV_ID": "${DBT_PROD_ENV_ID}",
"DBT_PROJECT_DIR": "/path/to/project",
"DBT_PATH": "/path/to/dbt"
}
}
}
}
{
"mcpServers": {
"dbt": {
"command": "uvx",
"args": ["--env-file", "/path/to/.env", "dbt-mcp"]
}
}
}
.env file contents:
DBT_HOST=cloud.getdbt.com
DBT_TOKEN=<set-via-env-or-secret-manager>
DBT_ACCOUNT_ID=<your-account-id>
DBT_PROD_ENV_ID=<your-prod-env-id>
DBT_DEV_ENV_ID=<your-dev-env-id>
DBT_USER_ID=<your-user-id>
DBT_PROJECT_DIR=/path/to/project
DBT_PATH=/path/to/dbt
{
"mcpServers": {
"dbt": {
"url": "https://cloud.getdbt.com/api/ai/v1/mcp/",
"headers": {
"Authorization": "Token ${DBT_TOKEN}",
"x-dbt-prod-environment-id": "${DBT_PROD_ENV_ID}"
}
}
}
}
Additional headers for SQL/Fusion tools:
{
"headers": {
"Authorization": "Token ${DBT_TOKEN}",
"x-dbt-prod-environment-id": "${DBT_PROD_ENV_ID}",
"x-dbt-dev-environment-id": "${DBT_DEV_ENV_ID}",
"x-dbt-user-id": "${DBT_USER_ID}"
}
}
Config location:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.jsonRun:
claude mcp add dbt -s user -- uvx dbt-mcp
This adds the server to your user scope/config (on this system: ~/.claude.json).
For a project-specific setup, run:
claude mcp add dbt -s project -- uvx dbt-mcp
This adds the server to .mcp.json in your project root.
Alternatively, you can use the manual configuration below.
Manual configuration: Edit ~/.claude.json (user scope) or create .mcp.json (project scope) in your project root:
~/.claude.json: Global across all projects.mcp.json: Project-specific, can be committed to version control for team sharing. If using token auth, use environment variable references — never commit literal tokens.For project-specific dbt setups, use .mcp.json so your team shares the same configuration.
Once the config is created, make sure to add the JSON configuration under the mcpServers key.
servers not mcpServers):{
"servers": {
"dbt": {
"command": "uvx",
"args": ["dbt-mcp"],
"env": {
"DBT_PROJECT_DIR": "/path/to/project",
"DBT_PATH": "/path/to/dbt"
}
}
}
}
4. Open Settings → Features → Chat → Enable MCP 5. Verify: Run "MCP: List Servers" from Command Palette
WSL Users: Configure in Remote settings, not local user settings:
/home/user/project, not Windows paths)Recommended: Use .env file
DBT_PROJECT_DIR=/path/to/project
DBT_PATH=/path/to/dbt
2. Test the server:
uvx --env-file .env dbt-mcp
Alternative: Environment variables
# Temporary test (variables only last for this session)
export DBT_PROJECT_DIR=/path/to/project
export DBT_PATH=/path/to/dbt
uvx dbt-mcp
No errors = successful configuration.
After setup, ask the AI:
See Troubleshooting for common issues and fixes.
See Environment Variable Reference for the full list of supported variables.
Weekly Installs
125
Repository
GitHub Stars
322
First Seen
Jan 29, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
github-copilot74
codex72
opencode72
gemini-cli71
amp69
kimi-cli69
Azure Data Explorer (Kusto) 查询技能:KQL数据分析、日志遥测与时间序列处理
130,600 周安装
DISABLE_SQL=false| Codegen (generate models/sources) | Disabled | DISABLE_DBT_CODEGEN=false to enable |