-
Notifications
You must be signed in to change notification settings - Fork 92
Add tool to get the MCP server version #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
b-per
wants to merge
2
commits into
main
Choose a base branch
from
feat/tool-mcp-server-version
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
.changes/unreleased/Enhancement or New Feature-20250604-162749.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| kind: Enhancement or New Feature | ||
| body: Add new tool to get the MCP server version | ||
| time: 2025-06-04T16:27:49.547265+02:00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import logging | ||
| from importlib.metadata import version | ||
|
|
||
| from mcp.server.fastmcp import FastMCP | ||
|
|
||
| from dbt_mcp.prompts.prompts import get_prompt | ||
|
|
||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def register_meta_tools(dbt_mcp: FastMCP) -> None: | ||
| @dbt_mcp.tool(description=get_prompt("meta/get_dbt_mcp_server_version")) | ||
| def get_dbt_mcp_server_version() -> str: | ||
| return version("dbt-mcp") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| this tool returns the current version of the dbt MCP server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import unittest | ||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| from dbt_mcp.meta.tools import register_meta_tools | ||
|
|
||
|
|
||
| class TestMetaTools(unittest.TestCase): | ||
| def test_get_dbt_mcp_server_version(self): | ||
| # Create a mock FastMCP | ||
| mock_fastmcp = MagicMock() | ||
|
|
||
| # Capture the registered tools | ||
| tools = {} | ||
|
|
||
| # Patch the tool decorator to capture functions | ||
| def mock_tool_decorator(**kwargs): | ||
| def decorator(func): | ||
| tools[func.__name__] = func | ||
| return func | ||
|
|
||
| return decorator | ||
|
|
||
| mock_fastmcp.tool = mock_tool_decorator | ||
|
|
||
| # Register the tools | ||
| register_meta_tools(mock_fastmcp) | ||
|
|
||
| # Test the get_dbt_mcp_server_version function | ||
| with patch("dbt_mcp.meta.tools.version") as mock_version: | ||
| mock_version.return_value = "1.0.0" | ||
| result = tools["get_dbt_mcp_server_version"]() | ||
|
|
||
| # Verify the version function was called with correct package name | ||
| mock_version.assert_called_once_with("dbt-mcp") | ||
|
|
||
| # Verify the result | ||
| self.assertEqual(result, "1.0.0") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be behind an env var like the other tools,
DISABLE_META_TOOLS? By default, I think this should be disabled.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My opposite take 😄 is that
But those are just my opinions and if it doesn't change yours then I can add an env var 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still lean toward adding an env var, just to be consistent with the other tools. We can disable it by default, and we can document it in
CONTRIBUTING.mdinstead ofREADME.mdsince it is meant for debugging. So, it shouldn't add much confusion. I don't think Cursor allows you to disable individual tools.However, it is up to you, though. I think either approach works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think @reneruck-dbt?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of your arguments are valid.
It is for debugging, makes sense. And yes, we've been very deliberate and flexible about what tools should be enabled in the first place.
In what scenarios would we need this function?
The most likely scenario I can think of is helping an end-user figure out why a certain piece of functionality does not work or works differently than expected.
The first two questions I'd ask would be:
I'm wondering if that does not point to a different type of
print_debug_infokind of tool or maybe even a resource?For the time being the configuration is kinda manually crafted so the user knows where to find it.
oAuth will come around soon(-ish) and will hopefully wipe away most of this config overhead.
This makes a function like that more interesting.
Should that tool always be available?
Do we want an explicit "debug mode" which brings along this tool (+ others) and maybe more verbose logging?
In that case a
ENABLE_DEBUG_MODEflag does make sense, you don't want to confuse the AI and fill the prompt context with tools.If all we're providing is a
get_server_versionand end there, I'd see the overhead this tool adds as negligible.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think a tool to print out Cursor/Claude JSON config could be helpful. A tool to dump environment variables could also be helpful. In the near term, I don't think we need to add different logging levels, but that may come up.