Sandbox
@Astoriel/dbt-doctor

MCP server for dbt project audits and YAML updates

dbt-doctor connects an AI assistant to a dbt project and warehouse through MCP. It reads the manifest, profiles tables, detects schema drift, suggests dbt tests, and writes safe updates back to `schema.yml` files.

134 stars5 forksPythonUpdated 4mo ago
Who it's for

Builders who use an MCP-capable assistant to review dbt project health, profile models, and keep documentation current.

What it delivers

You can ask your assistant to audit dbt coverage, inspect data, and update model docs without switching tools.

What it does

Project auditing

Scores dbt projects by documentation, testing, and naming, and lists models that need coverage first.

Data profiling

Runs batched SQL to collect null rates, cardinality, min/max values, and uniqueness for model columns.

Schema drift detection

Compares warehouse columns with `manifest.json` to spot added, removed, or type-changed fields.

Test suggestions

Turns profiling results into dbt test suggestions such as `not_null`, `unique`, and `accepted_values`.

Non-destructive YAML writing

Uses `ruamel.yaml` to merge new docs and tests into `schema.yml` while keeping comments and formatting.

End-to-end doc generation

Lets an assistant profile a model, suggest tests, preview changes, and write documentation in one flow.

How to get it

  1. 1Run
    pip install dbt-doctor

README

dbt-doctor logo

AI-driven quality and governance MCP Server for dbt projects.

Audit coverage, profile data, detect schema drift, and auto-generate documentation—all through natural language with an AI assistant.

CI PyPI version Python 3.10+ MIT License


Project status

Active alpha. Snapshot date: 2025-12-25. See STATUS.md and KNOWN_LIMITATIONS.md for what is working today, what is planned, and what is not claimed.

What is dbt-doctor?

dbt-doctor is a Model Context Protocol (MCP) server that provides your AI coding assistant with deep context regarding your dbt project's health. Instead of manually running CLI commands and analyzing outputs, you can interact with your AI:

  • "What's the overall health of my dbt project?"
  • "Profile the fct_orders model and suggest appropriate tests."
  • "Auto-document the models that have the lowest test coverage."

The tool handles the heavy operations—reading the manifest, profiling your data warehouse, detecting schema drift, and writing back to schema.yml files—without requiring you to leave the chat.

Note: This tool is designed to complement the official dbt-labs/dbt-mcp. While dbt-labs/dbt-mcp focuses on running dbt commands, dbt-doctor focuses on auditing, profiling, and documentation.

Key Features

Project Auditing

Evaluate your project with a 0–100% score based on documentation, testing, and naming conventions. Access a ranked list of models lacking coverage to prioritize your efforts.

Data Profiling

Perform efficient single-pass column statistics—including NULL rates, cardinality, min/max values, and uniqueness—using one batched SQL query per table to avoid slow row-by-row scanning.

Schema Drift Detection

Compare the current state of your data warehouse against the definitions in your manifest.json. Instantly identify added, removed, or type-changed columns.

Intelligent Test Suggestions

Translate profiling statistics into actionable dbt test recommendations. For example, a uniquely populated column without nulls will prompt suggestions for not_null and unique tests, while low cardinality will suggest accepted_values with predefined options.

Non-Destructive YAML Writing

Update schema.yml files using ruamel.yaml to retain hand-written comments, existing tests, and formatting. The tool only appends missing information and preserves your manual configurations.

End-to-End Documentation Generation

Execute a complete workflow in a single conversational turn: profile a model, suggest tests, preview changes, and write to schema.yml.


Included MCP Tools

CategoryToolDescription
Contextlist_modelsOverview of all models and their coverage status
Contextget_model_detailsDetailed model information including SQL, columns, lineage, and tests
Auditaudit_projectProject health score and naming convention violations
Auditcheck_test_coverageModels ranked by their test coverage percentage
Auditanalyze_dagDetection of orphan models and high fan-out nodes
Auditget_project_healthSingle-call dashboard summarizing project status
Profilingprofile_modelBatched column statistics
Profilingexecute_queryRead-only SQL execution against your warehouse
Profilingdetect_schema_driftComparison of database columns against manifest definitions
Generationsuggest_testsTranslation of profile data into dbt test recommendations
Generationupdate_model_yamlSafe merging of documentation and tests to schema.yml
Generationgenerate_model_docsComplete end-to-end documentation workflow

Quick Start

Installation

pip install dbt-doctor

Configuration (Claude Desktop)

Add the following to your claude_desktop_config.json:

{
  "mcpServers": {
    "dbt-doctor": {
      "command": "dbt-doctor",
      "args": ["--project-dir", "/absolute/path/to/your/dbt/project"]
    }
  }
}

Configuration (Cursor)

Add the following to your .cursor/mcp.json:

{
  "mcpServers": {
    "dbt-doctor": {
      "command": "dbt-doctor",
      "args": ["--project-dir", "/absolute/path/to/your/dbt/project"]
    }
  }
}

Prerequisite: Run dbt compile prior to usage to ensure target/manifest.json is available for dbt-doctor to parse.


Architecture

dbt-doctor architecture

The application connects the AI Assistant with your dbt project and database through the MCP protocol. It features a read-only analysis layer combined with a secure generation toolkit that merges changes seamlessly into your existing YAML schemas.


Security Design

  • Read-only execution: All execute_query operations operate within a read-only transaction. Write processes are restricted at the database connector level.
  • SQL validation: Table and column identifiers are strictly validated against a whitelist to prevent injection.
  • Stateless connections: Data warehouse credentials are instantiated per connection and are never cached in memory.
  • Preview before commit: The document generation process provides a difference preview prior to rewriting schema.yml, ensuring you retain control over modifications.

Related Projects

ProjectDescription
dbt-labs/dbt-mcpOfficial MCP focused on dbt command execution
dbt-coverageCLI tool for coverage reporting without AI integration
dbt-project-evaluatordbt package for project evaluation, requiring installation per project

dbt-doctor uniquely consolidates auditing, profiling, drift detection, and AI-driven YAML updates into a single server interface.


License

MIT — see the LICENSE file.

Files in the repo

Repository payload15 top-level entries
  • .github
  • docs
  • src
  • tests
  • .gitignore
  • ARCHITECTURE_AND_PLAN.md
  • CHANGELOG.md
  • CONTRIBUTING.md
  • KNOWN_LIMITATIONS.md
  • LICENSE
  • logo.png
  • pyproject.toml
  • README.md
  • SECURITY.md
  • STATUS.md

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More connectors

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

43k

Universal provider proxy for OpenAI Codex & Claude Code — use any LLM (Claude, Gemini, Grok, DeepSeek, Ollama…) with Codex CLI, App, SDK, and Claude Code

14k
okf-memory/
okf-agent-memory

Git-native persistent memory for AI coding agents. Implements Google OKF v0.2 with sub-300µs in-memory BM25 search, embedded MCP server, and progressive disclosure. Slashes token bloat by 80% with zero external databases or dependencies. Built in pure Go.

547
tirth8205/
code-review-graph

Local-first code intelligence graph for MCP and CLI. Builds a persistent map of your codebase so AI coding tools read only what matters, with benchmarked context reductions on reviews and large-repo workflows.

31k
2akouwu/
reverify

Stop your AI from making things up — it proposes, deterministic tools decide, every claim checked against ground truth with evidence. Grounded facts and context survive resets. Reverse engineering is the proving ground. MCP server + CLI.

1.1k
t8y2/dbxConnectors

20 MB lightweight cross-platform database client for 90+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 90+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP Server。

19k