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

dbt-get-source

Retrieve a dbt source's metadata including freshness criteria, columns, and latest freshness result using its unique ID or source and table names.

Instructions

Get a single dbt source: freshness criteria, columns, latest freshness result from sources.json

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uniqueIdNodbt unique_id (e.g. 'source.proj.raw.users')
sourceNameNoSource group name (with tableName)
tableNameNoSource table name (with sourceName)

Implementation Reference

  • The main handler function for 'dbt-get-source'. It loads the manifest, resolves the source by uniqueId or (sourceName+tableName), fetches freshness results from sources.json, and returns a detailed object with columns, freshness criteria, and freshness result.
    export async function dbtGetSource(args: z.infer<typeof dbtGetSourceSchema>): Promise<unknown> {
      const manifest = loadManifest();
      let id = args.uniqueId;
      if (!id) {
        if (!args.sourceName || !args.tableName) {
          throw new Error("Provide uniqueId, or both sourceName and tableName");
        }
        const found = Object.values(manifest.sources).find(
          (s) => s.source_name === args.sourceName && s.name === args.tableName,
        );
        id = found?.unique_id;
      }
      if (!id) throw new Error(`Source not found: ${args.uniqueId ?? `${args.sourceName}.${args.tableName}`}`);
      const src = manifest.sources[id];
      if (!src) throw new Error(`Source not found in manifest: ${id}`);
    
      let freshnessResult: unknown = null;
      try {
        const sources = loadSources();
        const r = sources.results.find((res) => res.unique_id === id);
        if (r) {
          freshnessResult = {
            status: r.status,
            maxLoadedAt: r.max_loaded_at,
            snapshottedAt: r.snapshotted_at,
            ageInSeconds: r.max_loaded_at_time_ago_in_s,
            criteria: r.criteria,
            generatedAt: sources.metadata.generated_at,
          };
        }
      } catch {
        // sources.json may be absent
      }
    
      return {
        uniqueId: src.unique_id,
        sourceName: src.source_name,
        tableName: src.name,
        identifier: src.identifier ?? src.name,
        database: src.database,
        schema: src.schema,
        loader: src.loader,
        loadedAtField: src.loaded_at_field,
        description: src.description,
        sourceDescription: src.source_description,
        freshness: src.freshness,
        columns: src.columns ? Object.values(src.columns) : [],
        tags: src.tags ?? [],
        freshnessResult,
      };
    }
  • Zod schema for the 'dbt-get-source' tool, accepting optional uniqueId or both sourceName and tableName.
    export const dbtGetSourceSchema = z.object({
      uniqueId: z.string().optional().describe("dbt unique_id (e.g. 'source.proj.raw.users')"),
      sourceName: z.string().optional().describe("Source group name (with tableName)"),
      tableName: z.string().optional().describe("Source table name (with sourceName)"),
    });
  • src/index.ts:82-82 (registration)
    Registration of the 'dbt-get-source' tool with the MCP server, linking its description, schema, and handler via wrapToolHandler.
    tool("dbt-get-source", "Get a single dbt source: freshness criteria, columns, latest freshness result from sources.json", dbtGetSourceSchema.shape, wrapToolHandler(dbtGetSource));
  • Helper usage of dbtGetSource within the 'incident-context' aggregation tool to fetch source details when sourceName.tableName is provided.
      const { model, source, failedTests, dqChecks } = await aggregate(
        {
          model: () =>
            args.modelName
              ? dbtGetModel({ name: args.modelName, includeCompiledSql: false })
              : Promise.resolve(null),
          source: () =>
            sourceParts && sourceParts.length === 2
              ? dbtGetSource({ sourceName: sourceParts[0], tableName: sourceParts[1] })
              : Promise.resolve(null),
          failedTests: () => dbtFailedTests({ recentRuns: 3 }),
          dqChecks: () =>
            dqConfigured() && dataset
              ? dqListChecks({ sinceHours: args.sinceHours, dataset, limit: 50 })
              : Promise.resolve(null),
        },
        caveats,
      );
    
      if (!dqConfigured()) caveats.push("DQ_RESULTS_TABLE not configured — quality category skipped");
    
      return {
        anchor: args.modelName ? { kind: "model", name: args.modelName } : { kind: "source", fqn: args.sourceFqn },
        window: { sinceHours: args.sinceHours },
        model,
        source,
        failedTests,
        dqChecks,
        caveats,
        notes: [
          "If you also have @us-all/airflow-mcp installed, call airflow-list-runs for the loading DAG to add run-time context.",
        ],
      };
    }
  • src/index.ts:21-25 (registration)
    Import of dbtGetSourceSchema and dbtGetSource from the dbt-sources module.
    import {
      dbtListSourcesSchema, dbtListSources,
      dbtGetSourceSchema, dbtGetSource,
      dbtListExposuresSchema, dbtListExposures,
    } from "./tools/dbt-sources.js";
Behavior3/5

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

No annotations are provided, so the description carries full burden. It discloses that the tool returns freshness criteria, columns, and latest freshness result, indicating a read operation. However, it lacks details on auth requirements, rate limits, or edge cases.

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 front-loads key information: action, resource, and returned data. No wasted words.

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

Completeness3/5

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

Given three parameters (all optional) and no output schema, the description is minimally adequate but does not clarify the relationship between parameters (e.g., alternative identification methods) or the output format. More detail would improve completeness.

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?

Schema coverage is 100% with parameter descriptions. The description adds context about the tool's output but does not provide additional meaning for the parameters themselves (e.g., how to choose between uniqueId vs sourceName+tableName).

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 verb 'Get' and resource 'single dbt source', specifying the data returned: freshness criteria, columns, latest freshness result. It distinguishes from sibling tools like dbt-list-sources (list) and dbt-get-model (model vs source).

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 retrieving a single source but does not explicitly state when to use this tool versus alternatives like dbt-list-sources for multiple sources. No alternative names or exclusions are mentioned.

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