Back to Browse

Metricview Lint MCP Server

Developer ToolsLow Risk10.0MCP RegistryLocal
Free

Server data from the Official MCP Registry

Offline linter for Databricks Unity Catalog metric view YAML. No workspace connection needed.

About

Offline linter for Databricks Unity Catalog metric view YAML. No workspace connection needed.

Security Report

10.0
Low Risk10.0Low Risk

Valid MCP server (1 strong, 2 medium validity signals). No known CVEs in dependencies. Package registry verified. Imported from the Official MCP Registry.

11 files analyzed · 1 issue found

Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.

Permissions Required

This plugin requests these system permissions. Most are normal for its category.

file_system

Check that this permission is expected for this type of plugin.

How to Install

Add this to your MCP configuration file:

{
  "mcpServers": {
    "metricview-lint": {
      "command": "uvx",
      "args": [
        "metricview-lint==0.1.1"
      ]
    }
  }
}

Some servers take additional arguments. See the repository for details.

Documentation

View on GitHub

From the project's GitHub README.

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 it

It 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.

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 --mcp

Tools exposed:

  • lint_metric_view(definition) takes YAML or a full CREATE VIEW ... WITH METRICS statement 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.json

The 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-lint

GitHub 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-errors

Rules

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.

CodeSeverityChecks
MV000errorthe YAML parses (with hints for backticks, : in expressions, unquoted *)
MV001errorno duplicate keys (YAML silently keeps the last one)
MV100errorthe document must be a YAML mapping
MV101errorversion is required
MV102errorversion must be a supported spec version
MV103errorsource is required
MV104errorat least one of fields or measures is required
MV105errorfields and dimensions are synonyms; use only one
MV106warningunknown key (likely a typo)
MV107errorvalue has the wrong type
MV108errorfeature requires spec version 1.1
MV109errorwindow is only allowed on measures
MV201warningfield/measure has no name (derived names need DBR 19+)
MV202errorname must not be empty
MV203errornames must be unique across fields and measures (case-insensitive)
MV204errorwildcard expressions can't have a name or metadata
MV205errordisplay_name/synonyms length limits
MV301errorfields and measures need an expr
MV302errormeasure expr must use an aggregate function
MV303warningfield expr should not aggregate
MV304errorwindow functions (OVER) are not allowed; use a window measure
MV305errorMEASURE() must reference an earlier measure
MV306warningaggregating a measure by name; use MEASURE(name)
MV307errora window measure can't reference another window measure
MV308errorfields can't reference columns of a one_to_many join
MV401errorjoins need name and source
MV402errorjoins need exactly one of on or using
MV403errorjoin names must be unique among siblings
MV404errorcardinality must be many_to_one or one_to_many
MV405errora join subtree can't mix cardinalities
MV406erroron compares an unqualified column with itself
MV501errorwindow must be a list of specs with order and range
MV502errorwindow range syntax
MV503errorwindow order must name a field defined in this view
MV504errorwindow semiadditive must be first or last
MV505errorwindow offset syntax
MV506errorwindow size parameters must be declared and integral
MV601errorformat spec is invalid
MV701errormaterialization mode and materialized_views are required
MV702errormaterialized view entries need a valid name and type
MV703errormaterialized views must reference existing fields and measures
MV704errormaterialization is incompatible with this definition
MV801errorparameters need name and data_type; defaults come last

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 order is 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 pyright

New 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.

Reviews

No reviews yet

Be the first to review this server!