sqlmesh-mcp

v0.3.0
sqlmesh-mcp Checked 11 hours ago Published 1 month ago

MCP server exposing a SQLMesh project (models, plans, column-level lineage, audits) to LLM agents

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_models

List every model in the SQLMesh project with its kind, columns, owner, and description.

get_model

Full detail for one model: rendered query, columns, kind, owner, tags, description.

ParameterTypeDescription
model_name *string

get_model_dependencies

Return the direct upstream and downstream model dependencies.

ParameterTypeDescription
model_name *string

fetch_model_data

Fetch a bounded, optionally column-filtered preview of model data.

ParameterTypeDescription
model_name *string
columns
limitinteger
mask_sensitiveboolean

server_info

Return server, project, safety, and capability metadata.

start_plan

Start a plan preview in the background and return a job ID.

ParameterTypeDescription
environment
select_models

start_run

Start a scheduled model run in the background. Requires confirm=true.

ParameterTypeDescription
confirmboolean
end
environment
start

get_job_status

Return the current status and result of an asynchronous plan or run.

ParameterTypeDescription
job_id *string

cancel_job

Cancel a queued job. Running SQLMesh operations cannot be interrupted safely.

ParameterTypeDescription
job_id *string

model_impact

Return all transitive upstream and downstream models affected by a change.

ParameterTypeDescription
model_name *string

environment_health

Summarize environment existence, snapshots, and current project drift.

ParameterTypeDescription
environment *string

audit_history

Return recent dataveil audit events without exposing cell values.

ParameterTypeDescription
limitinteger

plan

Preview what a plan against an environment would change. Does not apply anything. Returns a plan_id -- pass it to apply_plan to actually apply this exact plan.

ParameterTypeDescription
environment
select_models

apply_plan

Apply a previously-previewed plan. THIS CHANGES REAL DATA in the target warehouse. Requires confirm=true. plan_id must come from a plan() call in this same session -- plans aren't kept across server restarts.

ParameterTypeDescription
plan_id *string
confirmboolean

lineage

Column-level lineage: which upstream models/columns does this column depend on.

ParameterTypeDescription
column *string
model_name *string

run_audit

Run audits for a model (or all models if omitted). start/end bound the data checked.

ParameterTypeDescription
end
model_name
start

run_test

Run unit tests for a model (or all tests if omitted).

ParameterTypeDescription
model_name

diff_environment

Diff the current context against a target environment.

ParameterTypeDescription
environment *string

list_environments

List every environment that exists in this project's state (e.g. prod, dev, ...).

table_diff

Compare two tables or environments and return structured schema/row differences. When comparing environments, pass select_models to choose the models to compare. SQLMesh's console output is suppressed because MCP clients receive the JSON result.

ParameterTypeDescription
source *string
target *string
limitinteger
on
select_models
skip_columns
where

format

Check or format SQLMesh model and audit files. The default check mode is read-only. Writing formatted files requires confirm=true and is never performed accidentally by an agent.

ParameterTypeDescription
checkboolean
confirmboolean
paths

run

Execute scheduled/due model runs for an environment. THIS CHANGES REAL DATA. Distinct from plan/apply_plan: this runs already-promoted models for their due intervals (what a cron trigger would do), rather than previewing or promoting structural changes. Requires confirm=true.

ParameterTypeDescription
confirmboolean
end
environment
start

profile_model

Aggregate-only profile of a model's columns: null rates, distinct counts, numeric stats, generalized string format signatures (e.g. 'ddd-dd-dddd'). Returns no raw rows or samples; see dataveil's README for its known limits. The model must already be applied (see plan/apply_plan) -- dataveil reads from its current physical snapshot table.

ParameterTypeDescription
model_name *string

propose_cleansing_plan

Everything an agent needs to propose a data-cleansing plan for a model: the aggregate-only profile, a local sensitivity classification per column (PII:EMAIL, PII:SSN, PII:PHONE, ... or "none", each with a match_rate), and the closed operation vocabulary apply_cleansing_plan will accept. This tool does not call an LLM or propose a plan itself -- it's the documented contract an agent (you) reasons over to build one. A plan is a list of {"operation", "column", "params", "rationale"} objects; "operation" must be a key in operation_vocabulary, and only the params li…

ParameterTypeDescription
model_name *string

register_cleansing_plan

Register a cleansing plan for later approval, instead of applying it directly. Only useful when this server requires plan approval (DATAVEIL_REQUIRE_PLAN_APPROVAL=true) -- otherwise apply_cleansing_plan already accepts a plan directly and this tool isn't needed. Validates the plan against the operation vocabulary and the model's schema immediately -- a reviewer should never approve something that would fail at execution time. Read-only: nothing is applied here. Returns a plan_id; pass it to approve_cleansing_plan, then to apply_cleansing_plan.

ParameterTypeDescription
model_name *string
plan *array

approve_cleansing_plan

Mark a plan registered via register_cleansing_plan as approved. This only records who approved it -- apply_cleansing_plan still requires confirm=true on top of this. Approval and confirm=true are two separate gates, not a substitute for each other.

ParameterTypeDescription
approved_by *string
plan_id *string

apply_cleansing_plan

Validate and apply a data-cleansing plan. THIS CHANGES REAL DATA in the model's current physical snapshot table. Requires confirm=true. Default mode: pass `plan` directly, built from propose_cleansing_plan's output -- validated against the operation vocabulary and the model's schema before any step runs, same as always. If this server requires plan approval (DATAVEIL_REQUIRE_PLAN_APPROVAL= true): pass `plan_id` instead, from a plan that was registered (register_cleansing_plan) and then approved (approve_cleansing_plan) by someone else. confirm=true is still re…

ParameterTypeDescription
model_name *string
confirmboolean
plan
plan_id