contextlift

Semantic layers, compilation, and MCP

Enterprise analytics stacks rarely store business definitions in one place. Metric logic drifts across Markdown agent instructions, dbt schema.yml / manifest.json, Snowflake Semantic Views, Apache Ossie models, and LookML views. contextlift lints all five together at $0, compiles proven definitions back into your semantic layer, and serves the exact verified context over MCP.

Zero-LLM Cross-Layer Conflict Radar (lint)

Pass your Markdown spec/ alongside any combination of semantic layer sources:

contextlift lint \
  --spec spec/ \
  --dbt dbt_project/ \
  --snowflake-semantic semantic_views/finance.yaml \
  --ossie models/ossie.yaml \
  --lookml looker_repo/ \
  --db warehouse.duckdb

Without calling a single LLM, lint normalizes metric formulas, filter predicates, and accepted enum values across every supplied layer and refuses on contradictions:

Supported semantic layer inputs

LayerFlagFiles readExtra required
Markdown spec--spec DIRrules/*.md, schema/, authored/, vocabulary/, examples/, relationships.yamlcore (.json) or [yaml]
dbt--dbt PATHdbt_project.yml directory, schema.yml / MetricFlow YAML, or target/manifest.json[yaml] (or core for manifest.json)
Snowflake Semantic View--snowflake-semantic PATHSemantic View YAML or JSON (tables, metrics, relationships, verified_queries)[yaml] (or core for .json)
Apache Ossie--ossie PATHOssie semantic model YAML or JSON[yaml] (or core for .json)
LookML--lookml PATHLookML project directory (*.model.lkml, *.view.lkml, *.explore.lkml)[lookml]

Bidirectional compilation (compile)

Once a round proves your spec/ works on held-out SQL, compile it into your downstream semantic layer with verification metadata stamped into the header:

# Snowflake Semantic View YAML
contextlift compile \
  --spec spec/ \
  --target snowflake-yaml \
  --attestation .contextlift/attestation.json \
  --out semantic_views/finance.yaml

# dbt schema & MetricFlow YAML
contextlift compile --spec spec/ --target dbt-yaml --out models/metrics.yml

# Apache Ossie YAML (or .json when --out ends in .json)
contextlift compile --spec spec/ --target ossie --out semantic_model.yaml

Honest certification headers: compile checks BOTH the attestation's HMAC integrity AND whether the spec matches the attested arm hash, the verdict is REAL GAIN, and any merge policy passed.

Serving certified context over MCP (serve-mcp)

Run the zero-dependency JSON-RPC 2.0 stdio MCP server so production agents and coding assistants read the exact Arm that CI tested:

contextlift serve-mcp \
  --spec spec/ \
  --attestation .contextlift/attestation.json

serve-mcp speaks strictly over local stdin/stdout (supports both LSP Content-Length framing and newline-delimited JSON-RPC 2.0), binds no network port, and exposes six tools:

ToolPurpose
search_schemaSearch table and column descriptions by keyword.
get_metricLook up a business metric or glossary term definition.
get_join_pathFind join relationships involving one or two tables.
list_rulesList business reporting rules, optionally filtered by topic.
lookup_verified_exampleMatch a natural-language question against verified SQL examples.
get_attestation_statusReturn arm_id, spec_sha256, attested_spec_sha256, attestation_verified, attestation_arm_matches, certified, certification_reason, verdict, and safety.

Claude Code configuration (.mcp.json)

{
  "mcpServers": {
    "contextlift": {
      "command": "contextlift",
      "args": [
        "serve-mcp",
        "--spec", "spec/",
        "--attestation", ".contextlift/attestation.json"
      ]
    }
  }
}

Cursor configuration (.cursor/mcp.json)

{
  "mcpServers": {
    "contextlift": {
      "command": "contextlift",
      "args": [
        "serve-mcp",
        "--spec", "spec/",
        "--attestation", ".contextlift/attestation.json"
      ]
    }
  }
}