Skip to main content

Wren Engine

engine

Wren Engine is the open context engine behind Wren AI. It gives AI agents and data applications a structured way to understand business data, instead of working only from raw tables, columns, and ad hoc prompts.

In practice, Wren Engine sits between your data sources and the agent or application that needs to query them. It provides a modeled, governed, and execution-aware layer so agents can reason over business concepts such as customers, revenue, relationships, and reusable calculations.

What problem Wren Engine solves

Modern data systems are full of useful information, but they are rarely organized in a way that AI agents can use reliably. Raw schemas often contain:

  • many overlapping tables
  • inconsistent naming
  • business logic hidden in SQL or dashboards
  • unclear join paths and metric definitions

engine before

Giving an agent direct database access does not solve those problems. The missing piece is context: a machine-readable description of what the data means and how it should be used.

Wren Engine is designed to provide that context.

What Wren Engine does

Wren Engine combines modeling, context packaging, and query execution foundations in one open system.

1. Models business context with MDL

Wren Engine uses Modeling Definition Language (MDL) to describe:

  • models that map to tables or query results
  • relationships between datasets
  • calculated fields and reusable logic
  • views and business-facing abstractions

This turns warehouse structure into a layer that is easier for both humans and AI agents to understand.

2. Gives agents structured context instead of raw schema alone

Wren Engine is built around the idea that agents need more than semantics alone. They need context: trusted definitions, reusable logic, and a consistent way to navigate business data.

That context helps agents:

  • choose the right datasets
  • follow approved join paths
  • reuse shared calculations
  • generate more reliable SQL

3. Connects context to execution

Wren Engine is not only a metadata layer. It also serves as the execution foundation for modeled queries. Once data is described in MDL, Wren Engine can use that model to plan and generate queries against supported data sources.

This is what makes the project useful both for interactive analytics and for AI workflows that need grounded text-to-SQL behavior.

4. Supports MCP and agent-oriented workflows

Wren Engine is designed to work well with MCP clients and AI agents. It exposes business context in a form that can be shared with agent systems, so they can operate on governed data definitions instead of rediscovering logic from scratch on every request.

How Wren Engine fits into the Wren stack

Wren AI includes multiple services with different responsibilities:

  • Wren UI provides the interface for connecting data, modeling, and asking questions.
  • Wren AI Service handles retrieval, prompting, SQL generation, and validation with LLMs.
  • Wren Engine provides the context and modeling foundation those workflows depend on.

You can think of the relationship like this:

  1. Wren Engine defines the business layer.
  2. Wren AI Service uses that layer to retrieve context and generate better SQL.
  3. Wren UI lets teams interact with the system.

This is why Wren Engine is a core part of Wren AI, but is also meaningful as its own open project.

Key ideas behind the project

Open context engine

Wren Engine is described as an open context engine because its job is to make business context portable, inspectable, and usable by different agentic systems. Instead of locking meaning inside one application, it provides a reusable foundation that other tools and workflows can build on.

Business-first modeling

The project focuses on modeling data the way people ask questions about it, not only the way the warehouse stores it. That makes it easier to define entities, metrics, and relationships in a form that aligns with business usage.

Better reliability for AI

Text-to-SQL systems fail when they guess incorrectly about definitions, joins, or source-of-truth tables. Wren Engine improves reliability by making those assumptions explicit in the model.

Versionable and maintainable definitions

Wren Engine projects can be managed as files, which makes modeling logic easier to review, version, and improve over time. See the project structure guide for how MDL projects are organized.

Typical workflow

A common Wren Engine workflow looks like this:

  1. Connect a supported data source.
  2. Define or generate an MDL project.
  3. Model datasets, relationships, and calculations.
  4. Deploy the compiled MDL.
  5. Use that modeled context from applications, MCP clients, or AI services.

From there, agents can query with more grounding, and teams can maintain one shared business layer instead of repeating logic across prompts and SQL.

When to use Wren Engine

Wren Engine is especially useful when you want to:

  • build an agent or MCP workflow on top of business data
  • create a reusable business layer across analytics tools
  • improve text-to-SQL reliability with explicit modeling
  • separate business logic from raw warehouse structure
  • keep modeling definitions under version control

Learn more