Skip to content

[Feature]: Add support for common dbt-core flags (--exclude, --favor-state, etc.) #573

@aidancorrell

Description

@aidancorrell

Problem

The dbt-core(and CLI) tools (build, run, test, compile, etc.) currently support a limited set of flags:

  • --select, --full-refresh, --vars, --resource-type

Common flags used in local development are missing:

  • --defer / --state (slim CI, defer to production)
  • --exclude
  • --target
  • --fail-fast
  • --threads

This makes workflows like this impossible through MCP, especially ones leveraging only dbt-core:

dbt run -s my_model --defer --state /path/to/prod/manifest                                            
dbt build -s state:modified+ --defer --state ./target-prod                                            
dbt run -s +my_model --exclude my_other_model --target dev                                            
                                                                                                      


### Describe the solution you'd like



Proposed Solution                                                                                     
                                                                                                      
Add typed parameters for these flags to the tool functions:         

```bash                                  
                                                                                                      
async def build(                                                                                      
    selector: str | None = None,                                                                      
    exclude: str | None = None,           # NEW                                                       
    defer: bool = False,                   # NEW                                                      
    state: str | None = None,              # NEW                                                      
    target: str | None = None,             # NEW                                                      
    fail_fast: bool = False,               # NEW                                                      
    threads: int | None = None,            # NEW                                                      
    ...                                                                                               
)                                                                                                     
                                                                                                      
Also add environment variables for defaults:                                                          
- DBT_MCP_STATE_PATH - default state path for --defer                                                 
- DBT_MCP_TARGET - default target profile                                                             
                                                                                                      
Priority                                                                                              
┌─────────────┬────────────────────────────────────┬──────────┐                                       
│    Flag     │              Use Case              │ Priority │                                       
├─────────────┼────────────────────────────────────┼──────────┤                                       
│ --defer     │ Slim CI, local dev against prod    │ High     │                                       
├─────────────┼────────────────────────────────────┼──────────┤                                       
│ --state     │ Required for defer, state:modified │ High     │                                       
├─────────────┼────────────────────────────────────┼──────────┤                                       
│ --exclude   │ Fine-grained selection             │ High     │                                       
├─────────────┼────────────────────────────────────┼──────────┤                                       
│ --target    │ Multi-environment workflows        │ Medium   │                                       
├─────────────┼────────────────────────────────────┼──────────┤                                       
│ --fail-fast │ Quick feedback loops               │ Medium   │                                       
├─────────────┼────────────────────────────────────┼──────────┤                                       
│ --threads   │ Performance tuning                 │ Low      │                                       
└─────────────┴────────────────────────────────────┴──────────┘                                       
Happy to contribute a PR for this. 

### Describe alternatives you've considered

Simply using dbt-core commands and instructing Claude(or agent of choice) to just leverage these through claude skills - however every user has a slightly different workflow and these can be overhead to try to "share" throughout the team

### Additional context

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions