dq-score-snapshot
Aggregates 4-axis score trend, today's Tier compliance, and lists most recent failing checks for a data quality snapshot.
Instructions
Aggregated 4-axis score trend + today's Tier compliance + most recent failing checks. Combines dq-score-trend + dq-tier-status + dq-list-checks(fail).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | ||
| includeFailing | No | Also include the most recent failing checks |
Implementation Reference
- src/tools/aggregations.ts:83-102 (handler)The main handler function for 'dq-score-snapshot'. Takes a 'days' param (1-90, default 7) and optional 'includeFailing' flag. Calls aggregate() to concurrently invoke dqScoreTrend, dqTierStatus, and dqListChecks (failing only), returning a combined snapshot with trend, tier, and failingTop results.
export const dqScoreSnapshotSchema = z.object({ days: z.coerce.number().int().min(1).max(90).default(7), includeFailing: z.boolean().default(true).describe("Also include the most recent failing checks"), }); export async function dqScoreSnapshot(args: z.infer<typeof dqScoreSnapshotSchema>): Promise<unknown> { const caveats: string[] = []; const { trend, tier, failing } = await aggregate( { trend: () => dqScoreTrend({ days: args.days }), tier: () => dqTierStatus({}), failing: () => args.includeFailing ? dqListChecks({ sinceHours: args.days * 24, status: "fail", limit: 10 }) : Promise.resolve(null), }, caveats, ); return { days: args.days, trend, tier, failingTop: failing, caveats }; } - src/tools/aggregations.ts:83-86 (schema)Zod schema defining the input for dq-score-snapshot: 'days' (coerced int, 1-90, default 7) and 'includeFailing' (boolean, default true) to control inclusion of recent failing checks.
export const dqScoreSnapshotSchema = z.object({ days: z.coerce.number().int().min(1).max(90).default(7), includeFailing: z.boolean().default(true).describe("Also include the most recent failing checks"), }); - src/index.ts:107-107 (registration)Registration of the 'dq-score-snapshot' tool with description, schema binding (dqScoreSnapshotSchema.shape), and handler (wrapToolHandler(dqScoreSnapshot)).
tool("dq-score-snapshot", "Aggregated 4-axis score trend + today's Tier compliance + most recent failing checks. Combines dq-score-trend + dq-tier-status + dq-list-checks(fail).", dqScoreSnapshotSchema.shape, wrapToolHandler(dqScoreSnapshot)); - src/index.ts:45-50 (registration)Import of dqScoreSnapshotSchema and dqScoreSnapshot from src/tools/aggregations.ts into the main server file where the tool is registered.
import { failedTestsSummarySchema, failedTestsSummary, freshnessStatusSchema, freshnessStatus, dqScoreSnapshotSchema, dqScoreSnapshot, incidentContextSchema, incidentContext, } from "./tools/aggregations.js"; - src/tools/utils.ts:33-64 (helper)wrapToolHandler utility (from @us-all/mcp-toolkit) that wraps all tool handlers with error handling, redaction patterns, and structured error extraction.
export const wrapToolHandler = createWrapToolHandler({ redactionPatterns: [ /PG_CONNECTION_STRING/i, /-----BEGIN[^-]+-----[\s\S]*?-----END[^-]+-----/, ], errorExtractors: [ { match: (error) => error instanceof WriteBlockedError, extract: (error) => ({ kind: "passthrough", text: (error as WriteBlockedError).message, }), }, { match: (error) => error instanceof ConfigMissingError, extract: (error) => ({ kind: "passthrough", text: (error as ConfigMissingError).message, }), }, { match: (error) => error instanceof DqStoreError, extract: (error) => { const err = error as DqStoreError; return { kind: "structured", data: { message: err.message, cause: String(err.cause) }, }; }, }, ], });