Skip to main content
Glama

dbt-mcp

Official
by dbt-labs

query_metrics

Query the dbt Semantic Layer to analyze business data by grouping, ordering, and filtering metrics, dimensions, and entities for precise insights.

Instructions

This tool allows ordering and grouping by dimensions and entities. To use this tool, you must first know about specific metrics, dimensions and entities to provide. You can call the list_metrics, get_dimensions, and get_entities tools to get information about which metrics, dimensions, and entities to use.

When using the order_by parameter, you must ensure that the dimension or entity also appears in the group_by parameter. When fulfilling a lookback query, prefer using order_by and limit instead of using the where parameter. A lookback query requires that the order_by parameter includes a descending order for a time dimension.

The where parameter should be database agnostic SQL syntax, however dimensions and entity are referenced differently. For categorical dimensions, use {{ Dimension('<name>') }} and for time dimensions add the grain like {{ TimeDimension('<name>', '<grain>') }}. For entities, use {{ Entity('<name>') }}. When referencing dates in the where parameter, only use the format yyyy-mm-dd.

Don't call this tool if the user's question cannot be answered with the provided metrics, dimensions, and entities. Instead, clarify what metrics, dimensions, and entities are available and suggest a new question that can be answered and is approximately the same as the user's question.

For queries that may return large amounts of data, it's recommended to use a two-step approach:

  1. First make a query with a small limit to verify the results are what you expect

  2. Then make a follow-up query without a limit (or with a larger limit) to get the full dataset

Input Schema

NameRequiredDescriptionDefault
group_byNo
limitNo
metricsYes
order_byNo
whereNo

Input Schema (JSON Schema)

{ "$defs": { "GroupByParam": { "properties": { "grain": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Grain" }, "name": { "title": "Name", "type": "string" }, "type": { "$ref": "#/$defs/GroupByType" } }, "required": [ "name", "type", "grain" ], "title": "GroupByParam", "type": "object" }, "GroupByType": { "description": "The type of a group_by, i.e a dimension or an entity.", "enum": [ "dimension", "time_dimension", "entity" ], "title": "GroupByType", "type": "string" }, "OrderByParam": { "properties": { "descending": { "title": "Descending", "type": "boolean" }, "name": { "title": "Name", "type": "string" } }, "required": [ "name", "descending" ], "title": "OrderByParam", "type": "object" } }, "properties": { "group_by": { "anyOf": [ { "items": { "$ref": "#/$defs/GroupByParam" }, "type": "array" }, { "type": "null" } ], "default": null, "title": "Group By" }, "limit": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Limit" }, "metrics": { "items": { "type": "string" }, "title": "Metrics", "type": "array" }, "order_by": { "anyOf": [ { "items": { "$ref": "#/$defs/OrderByParam" }, "type": "array" }, { "type": "null" } ], "default": null, "title": "Order By" }, "where": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Where" } }, "required": [ "metrics" ], "title": "query_metricsArguments", "type": "object" }

Other Tools from dbt-mcp

Related Tools

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dbt-labs/dbt-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server