Skip to main content
Glama

sqlmesh-mcp

MCP server for SQLMesh — exposes data transformation operations as tools for AI agents (Claude, GPT-4, and any MCP-compatible client).

Python 3.10+ MCP License: MIT GitHub


What is this?

sqlmesh-mcp lets an AI agent interact with a SQLMesh project through the Model Context Protocol (MCP). The agent can inspect models, generate and apply plans, run tests and audits, explore column-level lineage, manage environments, and execute SQL — all without leaving the AI chat interface.

This is particularly powerful because SQLMesh's column-level lineage (a key advantage over dbt) becomes directly queryable: ask an AI "where does the revenue column in finance.daily_summary come from?" and get a traced answer across the full DAG.


Related MCP server: mendix-mcp-server

Tools

Tool

Description

sqlmesh_model_list

List all models with kind, cron, grain, tags

sqlmesh_model_info

Detailed metadata for a single model (columns, audits, query preview)

sqlmesh_model_render

Render fully-expanded SQL for a model

sqlmesh_plan

Read-only — preview what would change in an environment

sqlmesh_apply

Apply a plan to an environment (plan + auto-apply)

sqlmesh_run

Execute scheduled models whose cron interval is due

sqlmesh_test

Run SQLMesh unit tests (fixture-based, no warehouse)

sqlmesh_audit

Run data quality audits against the warehouse

sqlmesh_dag

Traverse the model DAG (upstream/downstream)

sqlmesh_lineage

Column-level lineage — trace column provenance across hops

sqlmesh_environment_list

List all environments and their state

sqlmesh_diff

Diff an environment against prod

sqlmesh_table_diff

Row-level data diff between two environments

sqlmesh_fetchdf

Execute SQL and return results as JSON

sqlmesh_invalidate_environment

Expire a dev/feature environment


Installation

git clone https://github.com/arthursherman/sqlmesh-mcp
cd sqlmesh-mcp
pip install -e ".[dev]"

From PyPI (once published)

pip install sqlmesh-mcp

Configuration

The server is configured through environment variables:

Variable

Description

Default

SQLMESH_PROJECT_PATH

Absolute path to your SQLMesh project

Current working directory

SQLMESH_GATEWAY

Named gateway defined in config.yaml (optional)

Default gateway


Usage

With Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "sqlmesh": {
      "command": "python",
      "args": ["-m", "sqlmesh_mcp.server"],
      "env": {
        "SQLMESH_PROJECT_PATH": "/path/to/your/sqlmesh/project"
      }
    }
  }
}

With Claude Code

claude mcp add sqlmesh -- python -m sqlmesh_mcp.server

Set the project path via:

export SQLMESH_PROJECT_PATH=/path/to/your/project
SQLMESH_PROJECT_PATH=/path/to/project \
  npx @modelcontextprotocol/inspector python -m sqlmesh_mcp.server

Open http://localhost:6274 in your browser to interactively test every tool.


Example interactions

Once connected to Claude or another MCP client, you can ask:

"List all models in my SQLMesh project"
"What columns does db.orders have and what are their types?"
"Show me a plan for the dev environment"
"Where does the revenue column in finance.daily_summary come from?"
"Run tests for the orders model"
"What's the difference between prod and dev right now?"
"Execute: SELECT COUNT(*) FROM db.orders WHERE status = 'complete'"

Development

Running tests

pytest tests/

Linting

ruff check src/

Testing against a real SQLMesh project

The fastest way to get started is with SQLMesh's built-in DuckDB quickstart:

mkdir sqlmesh-demo && cd sqlmesh-demo
pip install sqlmesh
sqlmesh init duckdb
# Then point this server at it:
SQLMESH_PROJECT_PATH=$(pwd) npx @modelcontextprotocol/inspector python -m sqlmesh_mcp.server

Security considerations

  • This server executes SQLMesh operations with the permissions of the process user.

  • The sqlmesh_apply and sqlmesh_run tools modify data — consider wrapping with a governance layer (see Castellan) if deploying in a shared or production context.

  • The sqlmesh_fetchdf tool executes arbitrary SQL — restrict access accordingly.

  • Bind the MCP Inspector proxy only to localhost; do not expose it publicly.


Roadmap

  • dbt-to-SQLMesh migration assistant tool

  • Semantic model / metric exposure via MCP resources

  • CI/CD integration (GitHub Actions plan summary)

  • Multi-project support (monorepo)

  • MCP sampling for agentic backfill decision-making



License

MIT — see LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to query live schema, lineage, and query-context across data warehouses, dbt projects, orchestration systems, and BI tools via MCP tools.
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to read and modify Mendix application models through MCP tools for creating modules, entities, pages, microflows, deploying, and querying runtime data.
      1
      ISC
    • A
      license
      B
      quality
      B
      maintenance
      Enables LLM agents to interact with a SQLMesh project, providing model metadata, column-level lineage, plan previews, audits/tests, and environment diffs, with optional apply/run actions.
      27
      2
      MIT