> ## Documentation Index
> Fetch the complete documentation index at: https://docs.credibledata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Context Engine Overview

> How Credible delivers your data and its meaning as trusted context to every surface

The **Credible Context Engine** delivers your data *and its meaning* — the definitions, relationships, business rules, and access controls captured in your semantic models — as context, at query time, to every surface.

You've already built that context. [Publishing](/how-to/modeling/publishing) a model hands it to the engine, which **materializes and indexes** it — distilling your data and its context into an efficient representation, ready to serve — and serves it everywhere: one model, every surface, consistent answers.

## Choose Your Surface

<CardGroup cols={2}>
  <Card title="Analyze Data" icon="browser" color="#5C7A93" href="/how-to/analyzing/workspaces">
    Chat with your data in governed workspaces in the Credible App.
  </Card>

  <Card title="Build Data Apps" icon="window-maximize" color="#5C7A93" href="/how-to/analyzing/data-apps">
    Build and use interactive dashboards and applications shipped with your packages.
  </Card>

  <Card title="Connect your Agent" icon="message-bot" color="#B8902E" href="/how-to/analyzing/connect-your-llm">
    Connect Claude, ChatGPT, Gemini, or any MCP-compatible chat client to your semantic models.
  </Card>

  <Card title="Connect with Slack" icon="slack" color="#B8902E" href="/how-to/analyzing/slack-integration">
    Ask data questions from any channel or DM with the `@CredibleData` bot.
  </Card>
</CardGroup>

Building your own? The developer surfaces — [MCP tools](/how-to/analyzing/ai-assistants-mcp) for custom agents and the [REST APIs](/how-to/integrating/apis) — live in the Developers section.

Every surface runs on the same engine, the same two MCP tools — `get_context` and `execute_query` — and the same [open-source agent skills](/introduction#one-set-of-skills-every-surface) that encode how to use them well. The only difference is where the agent runs: inside Credible, inside your agent, or inside your application.

## How It Works

The engine works in three stages: **distill** your published models into an efficient, servable form, **retrieve** the right context for each question, and **generate** a grounded query.

### Distill

When you publish, the engine distills your model — the data and its context — into a representation built for serving:

* **It indexes meaning.** Everything your model declares — the sources, dimensions, measures, and views; the business definitions in your `#(doc)` descriptions; and the actual data values of every `#(index)`-tagged dimension — becomes a searchable index. This is the metadata you added in [Discovery](/how-to/modeling/metadata-tags).
* **It materializes data.** Every `#@ persist` source is built into a managed physical table, so queries serve from a fast, cheap copy instead of re-scanning your warehouse. This is the optimization you added in [Performance & Cost](/how-to/modeling/persistence).

The engine keeps both fresh automatically, so what's served is always ready — no pipelines to run, no caches to manage.

### Retrieve

When a question comes in, embedding-based semantic search matches it to governed entities **by meaning, not by exact names**. Ask about "soccer games" and the engine finds a program titled "World Cup Finals" through its indexed values and a "Sports" genre through its documentation — no exact string match, no prior knowledge of the schema.

Just as important is what the engine *doesn't* do: it doesn't dump the entire model into every request. It retrieves the context that matches the question's intent, so the agent gets the relevant definitions, relationships, and rules — and nothing to get lost in.

### Generate

The engine returns more than matches: it suggests a Malloy query addressing the question, built from governed views and matched entities. From there the agent does the querying — running, refining, and building on that grounded starting point as the conversation develops, guided by Credible's [open-source agent skills](/introduction#one-set-of-skills-every-surface).

## Why Retrieval-First?

This design mirrors how people actually approach data. A business user rarely arrives with a query in hand — they have a **goal** ("understand customer churn"), a **question** ("why did revenue drop?"), or a **hunch** ("I think returns are up"). The traditional path forces them to learn the schema first; the Context Engine inverts it:

1. **Understand the question** — interpret what the user is trying to learn
2. **Discover relevant data** — find governed entities that can help, even with imprecise terminology
3. **Suggest an approach** — hand the agent not just data, but a way to analyze it
4. **Iterate naturally** — follow up, refine, and explore in conversation, letting each answer and the model's related dimensions suggest where to look next

The result is trustworthy by construction: every answer is grounded in your governed definitions, your [access rules](/how-to/modeling/fine-grained-acls) are enforced on every query, and the retrieval itself is inspectable — `get_context` shows exactly which entities matched and why.

## Optimizing for Retrieval

Beyond trust, a retrieval-based architecture has two big advantages:

1. **It's token-efficient.** The agent receives the context that matches the question — not the whole model — so answers are faster, cheaper, and don't degrade as your models grow.
2. **It's measurable.** You optimize what you measure — and you can't optimize what you can't measure. Retrieval quality is directly measurable, and semantic model quality with it: every question is a test of whether the model surfaced the right entities.

That measurability makes quality a feedback loop, not a one-way pipe. When the agent can't find something or matches the wrong field, the miss is a signal — add or refine the `#(doc)` and `#(index)` tags, republish, and every surface improves at once. And you're not on your own: Credible's [open-source skills](/introduction#one-set-of-skills-every-surface) and our solutions engineers help you measure and optimize your models as your business and data evolve.

See [Discovery](/how-to/modeling/metadata-tags) for the full guide to documenting and indexing your models.
