Skip to content

Commit 0a16772

Browse files
authored
Merge branch 'main' into devon/LangGraph_create_react_agent_example
2 parents 851c248 + 8f10da3 commit 0a16772

8 files changed

Lines changed: 85 additions & 7 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Bug Fix
2+
body: Fix the prompt to ensure grain is passed even for non-time group by"
3+
time: 2025-08-13T10:55:49.072094-04:00
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Enhancement or New Feature
2+
body: Add default --limit to show tool
3+
time: 2025-08-13T07:08:37.699907-07:00
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/dbt_cli/tools.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ def test(
117117

118118
def show(
119119
sql_query: str = Field(description=get_prompt("dbt_cli/args/sql_query")),
120-
limit: int | None = Field(
121-
default=None, description=get_prompt("dbt_cli/args/limit")
122-
),
120+
limit: int = Field(default=5, description=get_prompt("dbt_cli/args/limit")),
123121
) -> str:
124122
args = ["show", "--inline", sql_query, "--favor-state"]
125123
# This is quite crude, but it should be okay for now
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Limit the number of rows that the data platform will return. Use this in place of a `LIMIT` clause in the SQL query.
1+
Limit the number of rows that the data platform will return. Use this in place of a `LIMIT` clause in the SQL query. If no limit is passed, use the default of 5 to prevent returning a very large result set.

src/dbt_mcp/prompts/semantic_layer/query_metrics.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ Question: "What's our average order value by product category for orders over $1
8181
- I should first limit results to verify the query works
8282
Parameters (initial query):
8383
metrics=["average_order_value"]
84-
group_by=[{"name": "product_category", "type": "dimension"}]
84+
group_by=[{"name": "product_category", "type": "dimension", "grain":null}]
8585
where="{{ Dimension('order_value') }} > 100"
8686
limit=10
8787
Follow-up Query (after verifying results):
8888
metrics=["average_order_value"]
89-
group_by=[{"name": "product_category", "type": "dimension"}]
89+
group_by=[{"name": "product_category", "type": "dimension", "grain":null}]
9090
where="{{ Dimension('order_value') }} > 100"
9191
limit=None
9292
</example>
@@ -131,7 +131,7 @@ Question: "What's our customer satisfaction score by region?"
131131
If user agrees, then:
132132
Parameters:
133133
metrics=["net_promoter_score"]
134-
group_by=[{"name": "region", "type": "dimension"}]
134+
group_by=[{"name": "region", "type": "dimension", "grain":null}]
135135
order_by=[{"name": "net_promoter_score", "desc": true}]
136136
limit=10
137137
</example>

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)