Skip to content

Commit 8f10da3

Browse files
authored
Define toolsets (#285)
Just like `tools/tool_names.py` and `tools/policy.py`, it is helpful to statically define toolsets for them to be referenced.
1 parent 8fc2f80 commit 8f10da3

3 files changed

Lines changed: 74 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Under the Hood
2+
body: Define toolsets
3+
time: 2025-08-13T16:00:36.907595-05:00

src/dbt_mcp/tools/toolsets.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from enum import Enum
2+
3+
from dbt_mcp.tools.tool_names import ToolName
4+
5+
6+
class Toolset(Enum):
7+
SQL = "sql"
8+
SEMANTIC_LAYER = "semantic_layer"
9+
DISCOVERY = "discovery"
10+
DBT_CLI = "dbt_cli"
11+
12+
13+
toolsets = {
14+
Toolset.SQL: {
15+
ToolName.TEXT_TO_SQL,
16+
ToolName.EXECUTE_SQL,
17+
},
18+
Toolset.SEMANTIC_LAYER: {
19+
ToolName.LIST_METRICS,
20+
ToolName.GET_DIMENSIONS,
21+
ToolName.GET_ENTITIES,
22+
ToolName.QUERY_METRICS,
23+
ToolName.GET_METRICS_COMPILED_SQL,
24+
},
25+
Toolset.DISCOVERY: {
26+
ToolName.GET_MART_MODELS,
27+
ToolName.GET_ALL_MODELS,
28+
ToolName.GET_MODEL_DETAILS,
29+
ToolName.GET_MODEL_PARENTS,
30+
ToolName.GET_MODEL_CHILDREN,
31+
},
32+
Toolset.DBT_CLI: {
33+
ToolName.BUILD,
34+
ToolName.COMPILE,
35+
ToolName.DOCS,
36+
ToolName.LIST,
37+
ToolName.PARSE,
38+
ToolName.RUN,
39+
ToolName.TEST,
40+
ToolName.SHOW,
41+
},
42+
}

tests/unit/tools/test_toolsets.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from dbt_mcp.config.config import load_config
2+
from dbt_mcp.mcp.server import create_dbt_mcp
3+
from dbt_mcp.tools.toolsets import toolsets
4+
from tests.env_vars import default_env_vars_context
5+
6+
7+
async def test_toolsets_match_server_tools():
8+
"""Test that the defined toolsets match the tools registered in the server."""
9+
sql_tool_names = {"text_to_sql", "execute_sql"}
10+
11+
with default_env_vars_context():
12+
config = load_config()
13+
dbt_mcp = await create_dbt_mcp(config)
14+
15+
# Get all tools from the server
16+
server_tools = await dbt_mcp.list_tools()
17+
# Manually adding SQL tools here because the server doesn't get them
18+
# in this unit test.
19+
server_tool_names = {tool.name for tool in server_tools} | sql_tool_names
20+
defined_tools = set()
21+
for toolset_tools in toolsets.values():
22+
defined_tools.update({t.value for t in toolset_tools})
23+
24+
if server_tool_names != defined_tools:
25+
raise ValueError(
26+
f"Tool name mismatch:\n"
27+
f"In server but not in enum: {server_tool_names - defined_tools}\n"
28+
f"In enum but not in server: {defined_tools - server_tool_names}"
29+
)

0 commit comments

Comments
 (0)