Skip to main content
Glama

dbt_test

Validate data quality and integrity by running tests defined in a dbt project to ensure data transformations meet business rules before analysis.

Instructions

Run dbt tests. An AI agent should use this tool when it needs to validate data quality and integrity by running tests defined in a dbt project. This helps ensure that data transformations meet expected business rules and constraints before being used for analysis or reporting.

    Returns:
        Output from the dbt test command as text (this command does not support JSON output format)
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelsNoSpecific models to test, using the dbt selection syntax
selectorNoNamed selector to use
excludeNoModels to exclude
project_dirNoABSOLUTE PATH to the directory containing the dbt project (e.g. '/Users/username/projects/dbt_project' not '.').
profiles_dirNoDirectory containing the profiles.yml file (defaults to project_dir if not specified)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the MCP 'dbt_test' tool. Decorated with @mcp.tool(), it defines input parameters using Pydantic Field (serving as schema), constructs the 'dbt test' command with optional selectors/excludes, executes it via execute_dbt_command, and processes the result.
    @mcp.tool()
    async def dbt_test(
        models: Optional[str] = Field(
            default=None,
            description="Specific models to test, using the dbt selection syntax"
        ),
        selector: Optional[str] = Field(
            default=None,
            description="Named selector to use"
        ),
        exclude: Optional[str] = Field(
            default=None,
            description="Models to exclude"
        ),
        project_dir: str = Field(
            default=".",
            description="ABSOLUTE PATH to the directory containing the dbt project (e.g. '/Users/username/projects/dbt_project' not '.')"
        ),
        profiles_dir: Optional[str] = Field(
            default=None,
            description="Directory containing the profiles.yml file (defaults to project_dir if not specified)"
        )
    ) -> str:
        """Run dbt tests. An AI agent should use this tool when it needs to validate data quality and integrity by running tests defined in a dbt project. This helps ensure that data transformations meet expected business rules and constraints before being used for analysis or reporting.
    
        Returns:
            Output from the dbt test command as text (this command does not support JSON output format)
        """
        command = ["test"]
    
        if models:
            command.extend(["-s", models])
    
        if selector:
            command.extend(["--selector", selector])
    
        if exclude:
            command.extend(["--exclude", exclude])
    
        # The --no-print flag is not supported by dbt Cloud CLI
        # We'll rely on proper parsing to handle any print macros
    
        result = await execute_dbt_command(command, project_dir, profiles_dir)
    
        # Use the centralized result processor
        return await process_command_result(result, command_name="test")
  • src/server.py:88-89 (registration)
    Registration of all MCP tools (including 'dbt_test') by calling register_tools(mcp) on the FastMCP server instance.
    # Register tools
    register_tools(mcp)
  • src/tools.py:25-25 (registration)
    The register_tools function where all @mcp.tool() decorated handlers, including dbt_test, are defined and thus registered with the MCP server.
    def register_tools(mcp: FastMCP) -> None:
  • Import of helper functions used by dbt_test handler: execute_dbt_command (executes the dbt command), process_command_result (formats output).
    from src.command import execute_dbt_command, parse_dbt_list_output, process_command_result
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the core behavior (running tests to validate data quality) and importantly discloses that the output is 'text (this command does not support JSON output format)', which is valuable behavioral information not captured elsewhere. It doesn't mention execution time, error handling, or side effects, but provides solid core behavioral context.

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 efficiently structured with three focused sentences: purpose statement, usage guidance, and output format disclosure. Every sentence adds value without redundancy. The information is front-loaded with the core purpose, followed by usage context, and ending with important behavioral detail about the output format.

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?

For a testing tool with 5 parameters, 100% schema coverage, and an output schema, the description provides good contextual completeness. It explains the purpose, when to use it, and importantly discloses the text-only output format. While it doesn't cover all possible behavioral aspects (like execution characteristics or error conditions), it provides sufficient context given the rich schema documentation.

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 schema description coverage is 100%, with all 5 parameters well-documented in the schema. The description adds no specific parameter information beyond what's already in the schema, so it meets the baseline of 3. The description focuses on the tool's purpose and output format rather than parameter details.

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 specific action ('run dbt tests'), the resource ('tests defined in a dbt project'), and the purpose ('validate data quality and integrity'). It distinguishes this tool from siblings by focusing specifically on testing rather than building, compiling, running, or other dbt operations.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool: 'when it needs to validate data quality and integrity by running tests defined in a dbt project.' It also explains the value: 'helps ensure that data transformations meet expected business rules and constraints before being used for analysis or reporting.' This gives clear context for when this testing tool should be selected over other dbt operations.

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/MammothGrowth/dbt-cli-mcp'

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