add_metric
Define a reusable SQL aggregate metric (KPI) like revenue or default rate for quantitative analysis. Returns the metric's ID and name.
Instructions
Define a metric: a named, reusable SQL aggregate (a KPI).
Use for quantitative measures like revenue or default rate so grounding and generation can reuse them; for phrase-to-SQL mappings use add_glossary_term instead. Returns the new metric's id and name.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"connection": "<connection>",
"metric_name": "<metric_name>",
"display_name": "<display_name>",
"sql_expression": "<sql_expression>"
},
"name": "add_metric"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connection | Yes | Target database connection — its name or id (case-insensitive). List the available connections with list_connections. | |
| metric_name | Yes | Machine-friendly metric identifier (e.g. 'gross_revenue'). | |
| display_name | Yes | Human-friendly metric label (e.g. 'Gross Revenue'). | |
| sql_expression | Yes | SQL aggregate expression implementing the metric (e.g. SUM(amount)). | |
| description | No | Optional explanation of what the metric measures. | |
| related_tables | No | Optional list of table names the metric is computed from. | |
| dimensions | No | Optional dimensions to group the metric by (e.g. ['region','month']). |