← Back to directory
S

SLayer

Community
An embeddable, expressive semantic layer for AI agents and humans
GitHub source repository ↗
★ 168 Stars Category · Database Popular
48FMRS · D

SLayer is a MIT-licensed open-source semantic layer maintained by the Motley team, focused on giving AI agents governed data access and querying. It supports MCP among several interfaces and has clear install steps, making it well suited to teams building analytical agents or APIs on a warehouse; its read-only connections and credential-passing approach warrant attention to security configuration.

Reliability
7/20
Security and permissions
9/20
Maintenance
10/20
Documentation
10/20
Setup experience
12/20
Read the FMRS scoring method →

SLayer is an embeddable, expressive semantic layer created and maintained by the Motley team, enabling AI-powered data analytics on top of your warehouse. It gives agents a governed, shared surface through which they access your data and metrics and deliver reliable answers. SLayer handles database connectivity (read-only), SQL translation, common data transformations, and row-level security, so LLMs and humans don't have to. It can be used as a standalone tool or imported as a Python library and embedded into any Python app — for powering analytical MCP servers or APIs, or simply querying databases semantically. Unlike traditional BI semantic layers where every metric and aggregation must be predefined, SLayer lets you define a column such as revenue once and query it using expressions like revenue:sum, revenue:avg, revenue:sum / *:count, or time_shift(revenue:sum, -1, 'year'), with multi-stage queries also supported. SLayer focuses on the common agentic search → inspect → query flow, offering a search tool for efficient discovery and a memory store for linking relevant business context. Agents, apps, and humans can talk to SLayer via MCP, REST API, CLI, Python client, Flight SQL, or a Postgres-based SQL API, and it provides importers for dbt, Cube, and Ossie configs.

Setup

Using uv is recommended. Run uv tool install 'motley-slayer[all]'; if slayer isn't found on PATH afterwards, run uv tool update-shell and reopen your terminal. With the demo dataset: claude mcp add slayer_demo -- slayer mcp --demo (preloaded Jaffle Shop demo, zero-config). With your own data: create a datasource, e.g. slayer datasources create 'postgresql://user:${DB_PASSWORD}@hostname/db_name' — the password is read at init time and is not saved to disk or exposed to Claude — then run claude mcp add slayer -- slayer mcp --ingest-on-startup. Launch Claude Code from a shell where DB_PASSWORD is exported, since the MCP subprocess inherits its environment from the launching process.

Fit and risk

Best for

  • Data teams wanting a governed data access surface for AI agents
  • Developers building analytical MCP servers or APIs on top of a warehouse
  • Teams with existing dbt, Cube, or Ossie semantic configs they want to reuse
  • Engineers embedding a semantic layer into Python apps

Not for

  • Scenarios requiring write access to the database (SLayer connections are read-only)
  • Simple cases where direct SQL is sufficient and no semantic layer is needed
  • Non-Python stacks that cannot run the CLI or an MCP subprocess

Required permissions

  • Read-only database access to configured datasources
  • Environment variables holding database credentials such as DB_PASSWORD
  • Permission to run the local CLI and the MCP subprocess
  • Permission to modify Claude Code MCP configuration

Risks and side effects

  • Database credentials are passed to the MCP subprocess via environment variables, so a compromised launching shell could expose them
  • Connections are read-only but can still read sensitive business data, so row-level security should be applied
  • Once connected via MCP, agents can run queries, so verify their query scope matches expectations
  • As a third-party project, availability and behavior depend on upstream maintenance

Troubleshooting

  1. slayer command not found after install: run `uv tool update-shell` and reopen your terminal
  2. MCP not showing up in Claude Code: confirm `claude mcp add` ran and restart Claude Code
  3. Database connection failures: verify the datasource string's database type, username, hostname, and db_name
  4. Password not read: confirm the client is launched from a shell where DB_PASSWORD and related variables are exported

Use cases

Let AI agents run governed analytical queries on your warehouse
Power analytical MCP servers or APIs with a semantic layer
Query databases semantically instead of writing SQL by hand
Embed a semantic layer inside a Python application
Import dbt, Cube, or Ossie configs and reuse existing metric definitions

Supported clients

Claude CodeFull support