Skip to main content
Glama
us-all
by us-all

dbt-coverage

Calculates per-column test coverage for a dbt model, identifying which columns have tests and table-level coverage percentage.

Instructions

Per-column test coverage for a dbt model (which columns have tests, table-level tests, coverage %)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uniqueIdNodbt unique_id
nameNoModel name (resolved if uniqueId not provided)

Implementation Reference

  • Main handler: loads the manifest, resolves the model by uniqueId or name, iterates its columns and tests, computes per-column and table-level test coverage, and returns coverage stats.
    export async function dbtCoverage(args: z.infer<typeof dbtCoverageSchema>): Promise<unknown> {
      const manifest = loadManifest();
      let model: DbtNode | undefined;
      if (args.uniqueId) model = manifest.nodes[args.uniqueId];
      else if (args.name) model = Object.values(manifest.nodes).find((n) => isModel(n) && n.name === args.name);
      if (!model) throw new Error(`Model not found: ${args.uniqueId ?? args.name}`);
    
      const columns = Object.values(model.columns ?? {});
      const tests = Object.values(manifest.nodes).filter(
        (n) => n.resource_type === "test" && (n.depends_on?.nodes ?? []).includes(model.unique_id),
      );
    
      const columnsCovered = new Set<string>();
      for (const t of tests) {
        if (t.column_name) columnsCovered.add(t.column_name);
      }
    
      const tableLevelTests = tests.filter((t) => !t.column_name).map((t) => t.name);
    
      return {
        model: { uniqueId: model.unique_id, name: model.name },
        totalColumns: columns.length,
        columnsWithTests: columnsCovered.size,
        coveragePct: columns.length === 0 ? 0 : Math.round((columnsCovered.size / columns.length) * 1000) / 10,
        columns: columns.map((c) => ({
          name: c.name,
          hasTests: columnsCovered.has(c.name),
          testCount: tests.filter((t) => t.column_name === c.name).length,
        })),
        tableLevelTests,
        totalTests: tests.length,
      };
    }
  • Input schema for dbt-coverage tool, accepts either uniqueId or name of the model.
    export const dbtCoverageSchema = z.object({
      uniqueId: z.string().optional().describe("dbt unique_id"),
      name: z.string().optional().describe("Model name (resolved if uniqueId not provided)"),
    });
  • src/index.ts:90-90 (registration)
    Registers the dbt-coverage tool with the MCP server, associating the schema and handler.
    tool("dbt-coverage", "Per-column test coverage for a dbt model (which columns have tests, table-level tests, coverage %)", dbtCoverageSchema.shape, wrapToolHandler(dbtCoverage));
  • src/index.ts:11-16 (registration)
    Import of the dbtCoverageSchema and dbtCoverage handler into the registration file.
    import {
      dbtListModelsSchema, dbtListModels,
      dbtGetModelSchema, dbtGetModel,
      dbtGraphSchema, dbtGraph,
      dbtCoverageSchema, dbtCoverage,
    } from "./tools/dbt-models.js";
  • Helper used by the handler to load the dbt manifest.json file (with caching) to access nodes, columns, and tests.
    export function loadManifest(): DbtManifest {
      return readWithCache<DbtManifest>("manifest", targetPath("manifest.json"));
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden for behavioral disclosure. It does not mention whether the tool is read-only, requires permissions, or how it handles missing models. The output behavior is partially described but safety and side effects are not addressed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that is concise, front-loaded with the core purpose, and provides key output details without extraneous information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, the description reasonably communicates the return structure (columns with tests, table-level tests, coverage %). It could be more precise about the format of the coverage percentage, but it is largely sufficient for the tool's purpose.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with both parameters (uniqueId, name) clearly described. The description does not add new semantic information beyond the schema, meeting the baseline of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool provides per-column test coverage for a dbt model, listing three specific outputs: which columns have tests, table-level tests, and coverage percentage. This distinguishes it from siblings like dbt-get-test (specific test details) and dbt-list-tests (list of tests).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for assessing test coverage of a dbt model, but does not explicitly state when to use this tool versus alternatives like dbt-get-test or dbt-slow-models. No guidance on prerequisites or exclusions is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/us-all/dbt-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server