Skip to content

Conversation

@hanslemm
Copy link

@hanslemm hanslemm commented Jun 12, 2025

This PR includes two main features:

  • Support to --target flag in dbt cli commands.
  • get_profiles tool, which parses the profiles.yml of the project and returns the available profiles + targets, including their target types (postgres, redshift, bigquery, etc.) and target database names.

Tested the tool call with the prompt: "Can you get the profiles of my project via dbt-mcp get_profiles tool?"
Also did requests with different targets and ran successfully.

How to test this MCP live (example for VSCode mcp.json file)

{
    "inputs": [],
    "servers": {
        "dbt": {
            "command": "uvx",
            "args": [
                "--from",
                "git+https://github.com/hanslemm/dbt-mcp@patch-1",
                "dbt-mcp"
            ],
            "env": {
                "DBT_PATH": <fill>,
                "DBT_PROJECT_DIR": <fill>,
                "DISABLE_SEMANTIC_LAYER": <fill>,
                "DISABLE_DISCOVERY": <fill>,
                "DISABLE_REMOTE": <fill>
            }
        }
    }
}

Add `--target` support to tools.
@hanslemm hanslemm requested review from a team, b-per and jasnonaz as code owners June 12, 2025 16:38
@hanslemm hanslemm changed the title Add --target support to tools Add --target argument support & get_profiles tool to dbt_cli Jun 12, 2025
@hanslemm hanslemm changed the title Add --target argument support & get_profiles tool to dbt_cli feat(dbt_cli): --target argument support and get_profiles tool Jun 12, 2025
Copy link
Collaborator

@DevonFulcher DevonFulcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I just had a few minor comments.

build
compile
docs
get_profiles
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@b-per should be able to help get the updated diagram uploaded so it appears in the README and pypi.

@hanslemm
Copy link
Author

Thanks @DevonFulcher for the feedback.

I've addressed the comments, please check latest changes.

@b-per
Copy link
Collaborator

b-per commented Jul 3, 2025

Hi @hanslemm !

I have been testing the PR, and it technically works 🚀 , but I am wondering what exactly you are trying to achieve/solve with it (and/or if we should slightly update the tool).

With this PR, we can

  • get the different profiles
  • for each profile get the targets
  • specify a target for the current project

What I think is missing though is that today we can't know what is the profile used for the current dbt project. So in my case, the LLM tells me that I have 10+ profiles and several targets for each, but most of those targets won't work for my current profile.

I can think of 2 ways to solve this:

  • update get_profiles to get_profiles_and_targets and allow the LLM to scope down the targets to the current profile only
  • or create a new tool called get_targets that would get the target for the current profile only

What do you think?

@hanslemm
Copy link
Author

hanslemm commented Jul 4, 2025

Good point, since I only have one profile in my case, I didn't think about multiple profiles + targets.

The main point of this PR is allowing the MCP to run on different targets. It is nice to have the chance to tell the LLM which target it should use when reaching the MCP to run the dbt related commands.

@b-per
Copy link
Collaborator

b-per commented Jul 4, 2025

Thanks!

In that case, is it OK to rename the tool to get_targets, as this reflects more what you are after, and update the logic it so that it gets the targets of the current profile?

And if it sounds good to you. Let me know if you want to take care of it, otherwise, I can give it a go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants