metricview-lint
Provides offline linting of Databricks Unity Catalog metric view definitions (YAML bodies and CREATE VIEW ... WITH METRICS / ALTER VIEW AS $$ statements), validating sources, fields, measures, joins, window measures, formats, parameters and materialization against the metric view YAML spec, with rule-coded diagnostics, line numbers, JSON/GitHub output formats and configurable rule disabling.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
metricview-lint
Catch mistakes in Databricks Unity Catalog metric view definitions before you deploy them, in your editor, in CI, or while a coding agent like Claude Code writes them.
$ metricview-lint examples/invalid
examples/invalid/common-mistakes.yaml:8: error MV406 join 'customer' 'on' compares customer_id = customer_id; unqualified columns resolve to the joined table, so this is always true. Write source.customer_id = customer.customer_id or use 'using: [customer_id]'
examples/invalid/common-mistakes.yaml:20: error MV302 measure 'margin' has no aggregate function (SUM, COUNT, AVG, MEASURE, ...); a non-aggregated expression belongs in 'fields'.
examples/invalid/common-mistakes.yaml:22: error MV305 MEASURE(orders) references a measure defined later; move 'orders' above 'aov'
examples/invalid/common-mistakes.yaml:31: error MV502 measure 'revenue_7d': invalid range 'last 7 days'; expected current, cumulative, all, or 'trailing|leading <n> [day|month|year] [inclusive|exclusive]'
...Metric views are defined in YAML inside CREATE VIEW ... WITH METRICS LANGUAGE YAML AS $$ ... $$. Today the only way to find a mistake is to run the statement against a warehouse and read the error. Some mistakes don't error at all: an unqualified on: id = id join condition is always true. metricview-lint checks the definition offline, in milliseconds, with no Databricks connection or credentials.
Install
uvx metricview-lint path/to/metric_views # run without installing
pip install metricview-lint # or install itIt reads .yaml / .yml metric view bodies and .sql files containing CREATE VIEW ... WITH METRICS or ALTER VIEW ... AS $$. Line numbers always point into the original file. YAML files without a top-level source, fields or measures key are skipped, so you can point it at a whole repo.
metricview-lint [PATH ...] [--format text|json|github] [--disable MV201,MV303]
[--warnings-as-errors] [--all-yaml] [--list-rules] [--mcp]It exits with 1 if there are errors (or warnings, with --warnings-as-errors), and 0 otherwise.
Related MCP server: deepbom
Use it from Claude Code (MCP)
metricview-lint ships an MCP server. With it, an agent validates every metric view it writes and fixes the errors before showing you the result.
claude mcp add metricview-lint -- uvx --from 'metricview-lint[mcp]' metricview-lint --mcpTools exposed:
lint_metric_view(definition)takes YAML or a fullCREATE VIEW ... WITH METRICSstatement and returns the diagnostics.lint_metric_view_file(path)lints a file on disk.list_rules()returns every rule with its code, severity and summary.
The same command works in any MCP client (Claude Desktop, Cursor, ...).
Editor autocompletion (JSON Schema)
Name your files *.metric_view.yaml (or *.metric-view.yaml). VS Code (with the Red Hat YAML extension), JetBrains IDEs and Neovim then pick up the schema from SchemaStore and give you key completion, hover docs and type checks while you type. For any other file name, add this first line:
# yaml-language-server: $schema=https://raw.githubusercontent.com/1yangsh/metricview-lint/main/schemas/databricks-metric-view.jsonThe schema is lenient on purpose: it helps you write the file, and metricview-lint checks it. metricview-lint --print-schema prints it.
pre-commit
repos:
- repo: https://github.com/1yangsh/metricview-lint
rev: v0.1.0
hooks:
- id: metricview-lintGitHub Actions
This annotates the pull request diff at the offending lines.
- uses: actions/checkout@v4
- uses: 1yangsh/metricview-lint@v0.1.0
with:
paths: metric_views/
args: --warnings-as-errorsRules
Errors are things Databricks rejects, or that silently compute the wrong number. Warnings are likely mistakes that are valid in some setups. Run metricview-lint --list-rules for the live list, and disable any rule with --disable.
Code | Severity | Checks |
| error | the YAML parses (with hints for backticks, |
| error | no duplicate keys (YAML silently keeps the last one) |
| error | the document must be a YAML mapping |
| error |
|
| error |
|
| error |
|
| error | at least one of |
| error |
|
| warning | unknown key (likely a typo) |
| error | value has the wrong type |
| error | feature requires spec version 1.1 |
| error |
|
| warning | field/measure has no |
| error |
|
| error | names must be unique across fields and measures (case-insensitive) |
| error | wildcard expressions can't have a name or metadata |
| error |
|
| error | fields and measures need an |
| error | measure |
| warning | field |
| error | window functions (OVER) are not allowed; use a |
| error | MEASURE() must reference an earlier measure |
| warning | aggregating a measure by name; use MEASURE(name) |
| error | a window measure can't reference another window measure |
| error | fields can't reference columns of a one_to_many join |
| error | joins need |
| error | joins need exactly one of |
| error | join names must be unique among siblings |
| error |
|
| error | a join subtree can't mix cardinalities |
| error |
|
| error |
|
| error | window |
| error | window |
| error | window |
| error | window |
| error | window size parameters must be declared and integral |
| error |
|
| error | materialization |
| error | materialized view entries need a valid name and type |
| error | materialized views must reference existing fields and measures |
| error | materialization is incompatible with this definition |
| error | parameters need |
The rules follow the metric view YAML reference for spec versions 0.1 and 1.1, including joins (many_to_one / one_to_many, snowflake nesting), window measures, semantic metadata (display_name, format, synonyms), parameters and materialization. Every example in the Databricks docs lints clean, apart from intentional fragments.
What it can't check
metricview-lint works offline, so it can't check anything that needs the catalog:
whether tables and columns exist
column types (e.g. that a window
orderis a date)row-level security that blocks materialization
Treat it as a fast first gate, and keep CREATE VIEW on a dev warehouse as the final check.
Development
uv sync --all-extras
uv run pytest && uv run ruff check . && uv run pyrightNew rules live in src/metricview_lint/rules/. Each rule is a generator registered with @rule(code, severity, summary) that yields (message, path). Add a failing case to tests/test_rules.py first.
License
Apache-2.0. This is an independent project, not affiliated with or endorsed by Databricks.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Statically audits MCP tool surfaces for token cost, schema quality, and design issues.
SQL validation, formatting, parsing, metadata extraction, linting, and security analysis.
Validate Mermaid syntax and get error details your coding agent can use to correct a diagram. Check the source again before adding it to your documentation. Validation works without saving a diagram. Render SVG, PNG, or PDF, save diagrams privately, and publish selected snapshots. Your existing agent writes and corrects the source; MermaidDesk checks and renders it. Validation checks syntax, not whether a diagram accurately describes a system. Connect through MCP with Streamable HTTP and a scoped bearer API key. Enable MERMAID_RENDER for validation and rendering. A REST API is also available. MCP setup: https://www.mermaiddesk.com/developers/mcp REST API guide: https://www.mermaiddesk.com/developers/api
Deterministic validation for AI-generated artifacts: JSON Schema, OpenAPI response, SQL syntax.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceStatic audit of Kubernetes manifests via MCP, powered by kube-linter. Returns structured reports with severity, check ID, category, message, and remediation hints.-
- AlicenseNot gradedqualityBmaintenanceEnables local static analysis of deployed AI model artifacts over MCP, exposing audit, diff, capabilities, and rule-explanation tools without uploading model bytes.2Apache 2.0
- AlicenseNot gradedqualityBmaintenanceExposes an offline data-contract runtime to MCP-capable agents, enabling them to lint ODCS contracts and validate CSV datasets against them via stdio.MIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients to evaluate text or local files for LLM-output quality issues, returning 0-100 scores, grades, and precise line/column findings. It also lets clients list all available lint rules and severities.MIT