StackMap
Subscribe
Explore / slayer
MotleyAI

slayer

Embeddable semantic layer for AI agents: define metrics once, compose them with expressions and time shifts, row-level security and read-only SQL, over MCP, REST, CLI, Python or a Postgres facade.

227 31 Python MITupdated today
View on GitHubDispute this mapping →
Curator's take

Reach for SLayer when agents keep writing plausible-but-wrong SQL against your warehouse: define columns and metrics once, and agents compose them (ratios, time shifts, alternate aggregations, multi-stage queries) through a search, inspect, query flow instead of free-hand joins, with read-only connections and row-level security handled for them. It imports dbt and Cube definitions, embeds as a Python library, and speaks MCP, REST, Flight SQL and the Postgres wire protocol, so BI tools hit the same definitions. It is the core of Motley's product and still young (a few hundred stars, six contributors). Skip it if you want dashboards out of the box (wrenai) or a layer that builds itself from your existing BI assets (ktx).

Mapped by ShipWithAI editors · links verified

Continue your stack

What teams reach for next — and why each earns a place beside slayer. Ranked by curator confidence.

pairs wellalternativealternativealternativealternativeoperational-ontologyktxWrenAIEvoOntologyneocartaslayer
pairs wellalternativebuilt withpick a node for the why · open it from the panel
Weekly digest
README.md2 min read

SLayer — AI agent operating a semantic layer

PyPI Python Docs License GitHub stars Discord

SLayer

An expressive, embeddable semantic layer for AI agents and humans.

SLayer enables AI-powered data analytics on top of your warehouse. Agents get a governed, shared surface through which they access your data and metrics and give you 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. Adapt it to your workflows, not the other way around. Manage definitions easily with an agent or by yourself.

SLayer can be used as a standalone tool or imported as a Python library, easily embeddable into any Python app. Use it for powering analytical MCP servers or APIs or simply to query databases semantically.

SLayer is at the core of Motley and is maintained with ♡ by the same team.

How SLayer is different

Traditionally, semantic layers were a part of the BI stack, where every metric and its aggregation had to be predefined. Agents need more flexibility because users ask questions that involve metric combinations (like ratios), transforms (like time shifts), or different aggregations of the same metric (like average instead of sum).

SLayer allows to define a column revenue once and query it using expressions like sum(revenue), avg(revenue), sum(revenue) / count(*), time_shift(sum(revenue), -1, 'year') etc.; multi-stage queries are also supported.

SLayer is focused on the common agentic search → inspect → query flow. It has a search tool for efficient discovery and a memory store for linking the relevant business context.

Agents, apps and humans can talk to SLayer via MCP, REST API, CLI, Python, Flight SQL, or Postgres-based SQL API. SLayer supports most popular databases.

SLayer fits next to your existing data stack. It also provides importers for dbt, Cube, and Ossie configs.

See docs for more.

Example

Question (run on the built-in demo Jaffle Shop database): "show monthly revenue by store, with month-over-month % change"

Side by side, here's LLM-generated SQL and the equivalent SLayer query.

Example SQL vs SLayer query

Quickstart

We recommend using uv, especially if you don't work in a Python project.

u