Skip to main content
Glama

dqsleuth

dqsleuth is an MCP server for investigating data quality problems. It gives Claude (or any MCP client) read-only tools to find out why the data is wrong, not just that a test failed.

Ask it things like:

  • "Revenue dropped 35% yesterday. Is that real?"

  • "Why does joining orders to customers give me more rows than orders has?"

  • "Our unique test on stg_orders is failing. Where did it break and what does it affect?"

It runs locally on DuckDB. It reads CSV, Parquet and NDJSON files, DuckDB databases (including a dbt-duckdb warehouse), an optional Postgres database, and dbt's target/ artifacts. It never writes to any of them.

Install

Claude Code (plugin)

/plugin install dqsleuth --marketplace tripleaceme/dqsleuth

On Claude Code older than 2.1.275, add the marketplace first:

/plugin marketplace add tripleaceme/dqsleuth
/plugin install dqsleuth@dqsleuth

The plugin bundles the MCP server and an /dqsleuth:investigate skill. The skill gives Claude a structured method: hypotheses, evidence, root cause, fix, prevention. It needs uv on your PATH, because the server runs through uvx.

Any other MCP client

{
  "mcpServers": {
    "dqsleuth": {
      "command": "uvx",
      "args": ["dqsleuth", "--root", "/path/to/your/project"]
    }
  }
}

Or install it with pip install dqsleuth and run dqsleuth --root ..

Related MCP server: mcp-duckdb-analyst

Try it on the demo data

The repo ships a small shop dataset with six planted faults. Clone it, open Claude Code in examples/shop, and ask:

/dqsleuth:investigate revenue on 30 Oct 2026 dropped. Is it real?

Claude should find that Paystack payments are completely missing that day. That makes it a feed problem, not lost sales. Along the way it should also find the 25 orders that were loaded twice and the two failing dbt tests. The faults are listed at the top of examples/make_demo.py, and tests/test_engine.py checks that dqsleuth finds each one.

Tools

Tool

What it answers

dq_list_sources

What can I read? Tables, where they came from, whether dbt artifacts were found.

dq_add_source

Register another file, glob (data/orders_*.parquet), folder or .duckdb file.

dq_profile_table

Row count and per-column nulls, distinct values, min/max. Flags constant columns, high null rates, and placeholder strings like 'N/A' that hide from NULL checks.

dq_check_nulls

Null counts per column. With a time column, null % per period, which shows when nulls started.

dq_check_duplicates

Is this key unique? If not, are the extra rows exact copies (a re-run or overlapping incremental load) or conflicting values (wrong grain or a fan-out)?

dq_check_freshness

Latest timestamp, lag from now, rows per period, empty periods and low-volume periods.

dq_check_relationship

Orphaned foreign keys (rows an INNER JOIN drops), NULL keys, and a non-unique parent key that makes a LEFT JOIN inflate totals.

dq_explain_metric_change

Compares a window with its baseline and attributes the change to segments. Flags segments that disappeared, which usually means a feed did not land.

dq_run_sql

One read-only SELECT to confirm a hypothesis.

dq_dbt_test_results

Failing, erroring and warning tests from the last run, worst first.

dq_dbt_test_detail

One test's definition, config, tested model and compiled SQL.

dq_dbt_lineage

Upstream and downstream of a node, marking every node with failing tests. Downstream includes exposures.

There is also an investigate MCP prompt for clients that support prompts.

Configuration

Setting

Flag

Environment variable

Project root to scan for data

--root

DQSLEUTH_ROOT

Extra files, globs or folders

--source (repeatable)

DQSLEUTH_SOURCES (:-separated)

dbt target/ directory

--dbt-target

DQSLEUTH_DBT_TARGET

Postgres connection URL

—

DQSLEUTH_POSTGRES_URL

Skip scanning the root

--no-discover

—

On start, dqsleuth scans the root up to four levels deep. It registers up to 60 data files and finds target/manifest.json. It skips .git, virtualenvs, node_modules and dbt_packages. dbt artifacts are re-read whenever dbt rewrites them, so a new dbt build shows up without a restart.

The Claude Code plugin sets the root to your project directory. To point it at Postgres, export DQSLEUTH_POSTGRES_URL before starting Claude Code. Use a read-only database role.

Safety

dqsleuth is built to be safe to hand to an agent:

  • No writes. Files are exposed as views. DuckDB databases and Postgres are attached READ_ONLY. dq_run_sql rejects anything that isn't a single SELECT.

  • No reads outside the project. After start-up, DuckDB's external access is switched off for everything except the project root and paths you passed with --source. A query like read_text('~/.ssh/id_rsa') fails, and the setting cannot be switched back on the live connection.

  • No SQL injection through names. Table and column names are checked against the catalog before they go into SQL.

  • No secrets in results. The Postgres password goes to libpq through PGPASSWORD, so it never appears in the connection string that a SELECT could see.

  • No network calls, except installing DuckDB's Postgres extension the first time you use Postgres.

Results are capped (limit on every listing tool) so a large table can't flood the agent's context.

Development

uv sync
uv run python examples/make_demo.py
uv run pytest

tests/test_stdio.py starts the real server over stdio and calls it through an MCP client, the same way Claude Code does.

Roadmap

  • Read Soda and Great Expectations results alongside dbt's.

  • OpenMetadata lineage and ownership, so an investigation can name who owns the broken table.

  • Snowflake and BigQuery through DuckDB community extensions.

  • Distribution checks: a numeric column whose mean or spread shifted between windows.

Contributions are welcome. New checks go in src/dqsleuth/engine.py with a planted fault in examples/make_demo.py and a test that finds it.

License

MIT

Available Tools

12 tools
dq_add_sourceA
Read-onlyIdempotent

Register more data for investigation. Files become views; DuckDB databases are attached READ_ONLY.

Use for data outside the auto-discovered folders, or to read many partition files as one table via a glob.

Inputs: path (required), name. Returns: object

dq_check_duplicatesA
Read-onlyIdempotent

Check whether key_columns are unique, and diagnose what kind of duplication it is.

Separates exact duplicate rows (the same record loaded twice: a re-run or overlapping incremental window) from conflicting duplicates (same key, different values: wrong grain or a join fan-out).

Inputs: table (required), key_columns (required), sample. Returns: object

dq_check_freshnessA
Read-onlyIdempotent

Check how recent the data is and whether volume is steady: latest timestamp, lag from now, rows per period, empty periods (missing loads) and periods with under half the median volume.

Gaps and low-volume periods are computed over the whole range; only the latest 60 periods are listed row by row. To check one segment (e.g. a single provider), use dq_run_sql with a GROUP BY.

Inputs: table (required), time_column (required), grain, periods. Returns: object

dq_check_nullsA
Read-onlyIdempotent

Count NULLs per column, optionally broken down over time to pinpoint when a column started going null.

Inputs: table (required), grain, columns, periods, +1 more. Returns: object

dq_check_relationshipA
Read-onlyIdempotent

Test a join before trusting it: orphaned child keys (rows an INNER JOIN silently drops), NULL foreign keys, and a non-unique parent key (which makes a LEFT JOIN fan out and inflate totals).

Inputs: child_key (required), parent_key (required), child_table (required), parent_table (required), +1 more. Returns: object

dq_dbt_lineageA
Read-onlyIdempotent

Walk dbt lineage from a node, marking every upstream/downstream node that has failing tests.

Upstream answers "where did this break?"; downstream answers "what does this break?", including exposures (dashboards) that would show wrong numbers.

Inputs: node (required), depth, direction. Returns: object

dq_dbt_test_detailA
Read-onlyIdempotent

Everything needed to explain one dbt test: its definition, config (severity, where), the model it tests, and the compiled SQL that returns the failing rows.

Inputs: test (required). Returns: object

dq_dbt_test_resultsA
Read-onlyIdempotent

Summarise the last dbt test/build run from target/run_results.json: counts by status, and each failing test with its type, column, tested model and failure count, worst first.

Inputs: limit, statuses. Returns: object

dq_explain_metric_changeA
Read-onlyIdempotent

Explain why a metric moved: compare a window with its baseline, then attribute the change to segments.

For "revenue dropped 35% yesterday": gives the overall change and, per dimension, which segments account for it. A segment flagged 'missing in current window' usually means a feed did not load, which is a data problem rather than a business one.

Inputs: table (required), time_column (required), top, metric, +4 more. Returns: object

dq_list_sourcesA
Read-onlyIdempotent

List every table dqsleuth can read, where each came from, and whether dbt artifacts were found.

Call this first. Tables come from CSV/Parquet/NDJSON files and DuckDB databases discovered under the project root, sources added with dq_add_source, and an optional read-only Postgres attachment.

Inputs: no named parameters. Returns: object

dq_profile_tableA
Read-onlyIdempotent

Profile a table: row count, and per column the type, null %, distinct count, min/max and mean.

Also flags investigation leads: fully-null or constant columns, high null rates, placeholder strings ('N/A', 'null', '') that hide missing values from NULL checks, and likely key columns.

Inputs: table (required). Returns: object

dq_run_sqlA
Read-onlyIdempotent

Run one read-only SELECT to confirm a hypothesis. Any other statement type is rejected.

Inputs: sql (required), limit. Returns: object

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 12 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes: source discovery, profiling, null checks, duplicates, freshness, relationships, metric attribution, SQL, and dbt diagnostics. There is some overlap between dq_profile_table and dq_check_nulls, and dq_run_sql can be used broadly, but the descriptions make the intended boundaries reasonably clear.

    Naming Consistency5/5

    All tools consistently use snake_case with a dq_ prefix, and names are mostly verb_noun or clear resource-action phrases. The dbt tools form a consistent dq_dbt_* subgroup, so the set is predictable despite not every name being verb_noun.

    Tool Count5/5

    With 12 tools, the server is well-scoped for a data quality investigation toolkit. Each tool appears to earn its place by covering a distinct step in profiling, checking, diagnosing, and dbt triage.

    Completeness4/5

    The surface covers the core lifecycle well: source listing/addition, profiling, nulls, duplicates, freshness, relationships, metric change attribution, read-only SQL, and dbt test/lineage diagnostics. Minor gaps exist, such as removing registered sources or explicit schema/type drift checks, but dq_run_sql and profiling provide reasonable workarounds.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables language models to run data-quality checks and profiling on local files, using dbt-style assertions like not_null, unique, relationships, and accepted_values.
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables read-only analytical access to local CSV, Parquet, JSON files or a DuckDB database through MCP, with table discovery, column profiling, guarded SQL querying, and explain plans for safe use with Claude Desktop and Claude Code.
      8
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP clients like Claude Desktop, Claude Code and Cursor to safely explore local CSV, Excel, Parquet and SQLite files by running guarded read-only DuckDB SQL over a sandboxed data directory. It also supports data profiling, chart generation as image content, and exporting query results, without ever allowing writes or access outside the configured folder.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI assistants to explore and analyse local CSV, Parquet or JSON files through validated read-only SELECT queries, with schema discovery, profiling and query-plan tools. Results are capped, timed, PII-masked and audit-logged inside a locked DuckDB sandbox that cannot write, reach the network or read other files.
      MIT