dbt-get-run-results
Retrieve per-node results from any dbt run, filtered by status and limited to a maximum count. Use without an invocation ID to access the latest run results.
Instructions
Get per-node results from a specific dbt invocation (or the latest run if invocationId omitted)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| invocationId | No | invocation_id from a run; if omitted, the latest run_results.json in target/ is used | |
| status | No | Filter results by status (pass | error | fail | skipped | runtime error | success) | |
| limit | No |
Implementation Reference
- src/index.ts:87-87 (registration)Registration of the 'dbt-get-run-results' tool using the MCP server's tool() helper, with schema from dbtGetRunResultsSchema and handler via wrapToolHandler(dbtGetRunResults).
tool("dbt-get-run-results", "Get per-node results from a specific dbt invocation (or the latest run if invocationId omitted)", dbtGetRunResultsSchema.shape, wrapToolHandler(dbtGetRunResults)); - src/tools/dbt-runs.ts:29-39 (schema)Zod schema for dbt-get-run-results: optional invocationId, optional status filter, and limit (default 500, max 5000).
export const dbtGetRunResultsSchema = z.object({ invocationId: z .string() .optional() .describe("invocation_id from a run; if omitted, the latest run_results.json in target/ is used"), status: z .string() .optional() .describe("Filter results by status (pass | error | fail | skipped | runtime error | success)"), limit: z.coerce.number().int().min(1).max(5000).default(500), }); - src/tools/dbt-runs.ts:41-71 (handler)Main handler function dbtGetRunResults that loads run results by invocationId (looks up in run history) or from latest run_results.json, applies optional status filter, limits results, and returns metadata + mapped results.
export async function dbtGetRunResults( args: z.infer<typeof dbtGetRunResultsSchema>, ): 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, dbt_schema_version: "" }, results: match.results, }; } else { runFile = loadRunResults(); } let results = runFile.results; if (args.status) results = results.filter((r) => r.status === args.status); results = results.slice(0, args.limit); return { metadata: runFile.metadata, count: results.length, results: results.map((r) => ({ uniqueId: r.unique_id, status: r.status, executionTime: r.execution_time, failures: r.failures, message: r.message, adapterResponse: r.adapter_response, })), }; } - src/clients/dbt-artifacts.ts:171-173 (helper)loadRunResults() helper that reads and caches run_results.json from the dbt target directory.
export function loadRunResults(): DbtRunResultsFile { return readWithCache<DbtRunResultsFile>("runResults", targetPath("run_results.json")); } - src/clients/dbt-artifacts.ts:86-95 (helper)Type definition DbtRunResultsFile and DbtRunResult used by the tool for parsing run results data.
export interface DbtRunResultsFile { metadata: { dbt_schema_version: string; generated_at: string; invocation_id?: string; }; results: DbtRunResult[]; elapsed_time?: number; args?: Record<string, unknown>; }