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

dbt-slow-models

Identifies the top N slowest dbt models by execution time, including bytes processed where available, to help optimize performance.

Instructions

Top N slowest models in a dbt run by execution_time, with bytes_processed when available

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
topNNo
invocationIdNoUse a specific run; default is latest

Implementation Reference

  • The main handler function for dbt-slow-models. It loads run results (either from the latest run or a specific invocationId), filters to model nodes with execution_time, sorts descending, slices to topN, and returns invocation metadata plus model execution details.
    export async function dbtSlowModels(args: z.infer<typeof dbtSlowModelsSchema>): Promise<unknown> {
      let runFile;
      if (args.invocationId) {
        const all = listRunHistory(200);
        const match = all.find((r) => r.invocationId === args.invocationId);
        if (!match) throw new Error(`Run not found for invocation_id=${args.invocationId}`);
        runFile = { metadata: { generated_at: match.generatedAt, invocation_id: match.invocationId }, results: match.results };
      } else {
        const data = loadRunResults();
        runFile = { metadata: data.metadata, results: data.results };
      }
      const models = runFile.results
        .filter((r) => r.unique_id.startsWith("model."))
        .filter((r) => typeof r.execution_time === "number")
        .sort((a, b) => (b.execution_time ?? 0) - (a.execution_time ?? 0))
        .slice(0, args.topN);
      return {
        invocation: runFile.metadata,
        count: models.length,
        models: models.map((r) => ({
          uniqueId: r.unique_id,
          status: r.status,
          executionTimeSec: r.execution_time,
          bytesProcessed: r.adapter_response?.bytes_processed,
          rowsAffected: r.adapter_response?.rows_affected,
        })),
      };
    }
  • Zod schema for dbt-slow-models: accepts topN (1-100, default 20) and optional invocationId to target a specific run.
    export const dbtSlowModelsSchema = z.object({
      topN: z.coerce.number().int().min(1).max(100).default(20),
      invocationId: z.string().optional().describe("Use a specific run; default is latest"),
    });
  • src/index.ts:89-89 (registration)
    Registration of the dbt-slow-models tool with the MCP server, binding the schema and handler.
    tool("dbt-slow-models", "Top N slowest models in a dbt run by execution_time, with bytes_processed when available", dbtSlowModelsSchema.shape, wrapToolHandler(dbtSlowModels));
  • src/index.ts:34-34 (registration)
    Import of dbtSlowModelsSchema and dbtSlowModels from the dbt-runs module.
    dbtSlowModelsSchema, dbtSlowModels,
  • loadRunResults() helper that reads run_results.json from the dbt target directory, used by the handler when no invocationId is specified.
    export function loadRunResults(): DbtRunResultsFile {
      return readWithCache<DbtRunResultsFile>("runResults", targetPath("run_results.json"));
    }
Behavior3/5

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

No annotations provided, so description must cover behavioral traits. It accurately notes that the tool lists models sorted by execution_time and includes bytes_processed when available. However, it does not mention that it is read-only or any potential side effects. Given the simplicity, this is adequate but not exemplary.

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?

Single sentence, no redundancy. Every word adds value: 'Top N slowest models', 'by execution_time', 'with bytes_processed when available'.

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

Completeness5/5

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

For a simple list tool with only two optional params and no output schema, the description is complete. It explains what the tool does, the ordering, and the optional extra field. No additional details are necessary.

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

Parameters4/5

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

Schema coverage is 50% (invocationId has description, topN only constraints). The description adds meaning by linking topN to the 'Top N' concept and invocationId to a specific run. Together with the schema, parameters are well explained.

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?

Description clearly states it returns top N slowest models by execution_time, with optional bytes_processed. This distinguishes it from sibling tools like dbt-get-model (single model) or dbt-graph (dependencies).

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?

Description implies use for performance analysis but does not explicitly state when to use versus alternatives or provide exclusion criteria. No guidance on prerequisites or context.

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