feat(semantic-layer): add get_dimension_values tool#782
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a Semantic Layer get_dimension_values tool for discovering dimension filter values before calling query_metrics.
Changes:
- Registers the new Semantic Layer tool and adds parameter descriptions/prompt documentation.
- Adds
DimensionValuesResponseand fetcher logic using the Semantic Layer SDK. - Adds unit coverage for response creation and basic fetch/truncation behavior, plus README/changelog updates.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/dbt_mcp/semantic_layer/client.py |
Adds fetcher support for retrieving and truncating dimension values. |
src/dbt_mcp/semantic_layer/tools.py |
Exposes get_dimension_values as an MCP tool. |
src/dbt_mcp/semantic_layer/types.py |
Adds the structured response dataclass. |
src/dbt_mcp/semantic_layer/param_descriptions.py |
Adds descriptions for the new tool parameters. |
src/dbt_mcp/prompts/semantic_layer/get_dimension_values.md |
Adds tool usage guidance and examples. |
src/dbt_mcp/tools/tool_names.py |
Adds the new tool enum value. |
src/dbt_mcp/tools/toolsets.py |
Includes the new tool in the Semantic Layer toolset. |
src/dbt_mcp/tools/readme_mappings.py |
Adds the README description mapping. |
tests/unit/semantic_layer/test_client.py |
Adds unit tests for dimension values behavior. |
README.md |
Documents the new Semantic Layer tool. |
docs/diagram.mmd |
Adds a Mermaid architecture diagram including the new tool. |
.changes/unreleased/Enhancement or New Feature-20260519-141400.yaml |
Adds an enhancement changelog entry. |
.changes/unreleased/Bug Fix-20260519-142146.yaml |
Adds a bug-fix changelog entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add DimensionValuesResponse dataclass to semantic_layer/types.py with values list and truncated flag. Include tests to verify the type can be instantiated and used correctly.
The SDK's dimension_values returns a pa.Table, not a list[str]. Extract the first column via .column(0).to_pylist() before slicing. Update protocol stub return type and tests to use real pa.Table mock return values.
…validation - DimensionValuesResponse.values widened from list[str] to list[Any] to handle non-string dimension types (integers, dates, etc.) - get_dimension_values now wraps body in try/except, re-raising as RuntimeError via _format_semantic_layer_error for clean error propagation - limit param gains ge=1 validation to prevent empty/negative-slice bugs - Add boundary test: N items with limit=N yields truncated=False - Add get_dimension_values to docs/diagram.mmd Semantic Layer subgraph
… to empty string Null values are not valid filter values and would produce invalid where clauses if returned. Also adds a test covering null omission and corrects the changelog entry describing the list[str] fix.
4392825 to
b685479
Compare
jairus-m
reviewed
May 20, 2026
…sion_values to multi-project mode - Fix dimension column lookup to be case-insensitive; the SDK returns column names in uppercase which caused a KeyError when the caller passed the dimension name in lowercase - Add get_dimension_values tool to tools_multiproject.py so it is available in multi-project mode alongside the other Semantic Layer tools
…ts, remove diagram - Wrap the five get_dimension_values tests in TestGetDimensionValues with shared mock_sl_client, sl_config, and dim_fetcher fixtures to eliminate repeated setup boilerplate - Remove docs/diagram.mmd; diagram automation will be handled in a separate PR rather than as a manually maintained file
…_values The Protocol must keep Any to match the SDK stubs (which incorrectly type dimension_values as list[str] despite returning a pa.Table at runtime), but the local variable in the method body can be typed as pa.Table to preserve mypy coverage for all downstream attribute accesses.
jairus-m
approved these changes
Jun 3, 2026
Comment on lines
+946
to
+956
| @pytest.mark.asyncio | ||
| async def test_truncates_at_limit(self, dim_fetcher, mock_sl_client, sl_config): | ||
| mock_sl_client.dimension_values.return_value = pa.table( | ||
| {"status": ["a", "b", "c", "d", "e"]} | ||
| ) | ||
| result = await dim_fetcher.get_dimension_values( | ||
| config=sl_config, dimension="status", limit=3 | ||
| ) | ||
| assert result.values == ["a", "b", "c"] | ||
| assert result.truncated is True | ||
|
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
get_dimension_valuestool to the Semantic Layer toolsetlimit(default 100); atruncatedflag signals when more values exist beyond the limitquery_metricsto discover valid filter values forwhereclausesImplementation notes
SyncSemanticLayerClient.dimension_values(ADBC / Arrow Flight SQL), which is lightweight — no metric aggregationDimensionValuesResponse(values: list[str], truncated: bool); all column values are stringified for consistent handling regardless of the underlying dimension type (dates, integers, etc.)limitis validated asge=1to prevent empty-but-non-truncated responses_format_semantic_layer_error)Test plan
uv run pytest tests/unit/semantic_layer/test_client.py -k "dimension_values" -vuv run pytest tests/unit/ -x -qtask check