Chapter 12 — Mirabelle AI¶
12.1 — What it is, and what it does¶
Mirabelle AI answers questions about your plan in plain language. Open the Mirabelle panel and ask something like "Which items have the lowest fill rate?" It reads planning data from your tenant and shows the result as a table, chart, or KPI cards. It reads the plan you already have; asking a question does not rerun the plan, change an order, or approve anything.
Which plan does Chat use?¶
By default, Chat uses only the pipeline selected in the left toolbar and its linked scenarios. An ordinary follow-up stays within that scope, even if the last answer compared other plans. To compare plans, ask explicitly, for example: "Compare projected shortages in pipelines 'Baseline' and 'Growth'." To use a different scenario within the selected pipeline, give its type and exact name, for example: "Show safety stock using MEIO scenario 'Growth Buffers'." The answer shows which pipeline or pipelines it used.
The same panel also answers a different kind of question: how does Mirabelle work? Switch it to Ask the guide and it answers from this user guide instead of from your data; see Ask the guide: how Mirabelle works.
Planners can use the panel with the configured model. Administrators choose the model for the tenant in Settings → AI. See Configure the connection for screenshots, example values, and where to get a key.
What you can ask¶
| Kind of question | Example |
|---|---|
| A direct lookup | “What is the current safety stock for item X at site Y?” |
| A ranking | “Show the top 20 items with the largest forecast error” |
| A trend | “Show the forecast accuracy trend over the last 12 weeks” |
| A comparison | “Compare inventory risk in pipelines 'Baseline' and 'Growth'” |
| A why-question | “Why did service level drop in Spain?” |
| A what's-at-risk | “What products are at risk of expiry next week?” |
| A follow-up | “…only for Spain” — it keeps recent context from the same planning scope |
The full catalogue — question types, sample prompts, the panel's tabs, resizing, and troubleshooting — lives on the Mirabelle AI Guide reference page.
12.2 — How an answer is made¶
The ontology tells Mirabelle what planning terms mean. The model drafts a database query. The database supplies the numbers. Changing the model does not change the ontology or give the model direct database access.
flowchart TD
accTitle: From a planning question to an answer
accDescr: Mirabelle adds planning context, asks the chosen model to draft a query, checks and runs the query, then presents the results.
Q["1. You ask a question"] --> C["2. Mirabelle adds the ontology<br/>and your planning context"]
C --> M["3. The chosen model drafts a query"]
M --> V["4. Mirabelle enforces the planning scope<br/>and runs the query read-only"]
V --> A["5. You get an explanation<br/>with a table, chart, or KPI cards"]
Where the ontology fits¶
Think of the ontology as a dictionary and a map. It links the words you use to definitions, tables, and examples. For instance, "fill rate" points the model toward inventory optimisation results; "projected shortage" points it toward the supply projection. For each question, Mirabelle selects relevant definitions, synonyms, schema details, and example queries. It adds the requested planning scope, planning dates, and recent context from that same scope before asking the model to draft SQL (a database query).
Mirabelle filters the results before running the query. A supply projection uses the pipeline's Supply scenario, while fill rate from inventory optimisation uses its MEIO scenario. If you compare two pipelines, each uses its own scenario links. Shared master data, such as item names and actual on-hand stock, is not copied per scenario. When you say "next week", the planning date is the business reference, which may differ from the real calendar date.
When the explanation is enabled and data is returned, Mirabelle gives the model a sample of the result and totals calculated over the returned rows. For example, if two weeks show shortages of 40 and 25 units and the other weeks show none, the four-week total is 65 units. The model explains the result; verify important numbers, filters, and units against the data it cites.
Your team can add to the ontology as it works: rate an answer with the thumbs-up or thumbs-down under it, and once an administrator approves the rating, similar questions in your tenant are answered with it in view. See Rate an answer, and teach Mirabelle.
Which models can use it?¶
Both supported connections get the same Mirabelle ontology and planning context for query generation. You do not upload the ontology or train the model again. Models can still differ in how accurately they draft queries or how clearly they explain the answer.
flowchart TD
accTitle: One ontology, two supported model connections
accDescr: Mirabelle sends the same planning context to one configured provider, either Ollama or OpenRouter.
C["Mirabelle's ontology + planning context"] --> G{"Which connection<br/>did the admin select?"}
G --> O["Ollama<br/>A model you host"]
G --> R["OpenRouter<br/>A model from its catalog"]
- Your own model: use Ollama and select a model installed on an Ollama server that Mirabelle can reach. Ollama is the default unless configured otherwise.
- Cloud models, including models from OpenAI: use OpenRouter and enter the model's exact
ID from its catalog, for example
openai/gpt-4o-mini. Use an OpenRouter key. There is no separate OpenAI provider setting for a direct connection to the OpenAI API.
Choosing a model in another chat or AI app does not set the model inside Mirabelle. Only the tenant's configured connection is used for each turn; Mirabelle does not automatically switch to the other provider if a call fails.
Configure the connection¶
As an administrator, open Configuration → Settings in the left menu, then select the AI tab. Chat LLM connection applies to the whole tenant, not just the selected pipeline. Changes save automatically. Use a test tenant to try a provider without changing the connection for other users.
Both providers use the same Model dropdown. To add a model, select Enter a new model..., paste its exact ID or tag, and press Enter. Once saved, it stays in that provider's list for the tenant, even after you sign out. If you change Provider, choose a model or Use deployment default to apply the switch.
Key at a glance: local Ollama needs no API key. OpenRouter needs an OpenRouter key, even for models from OpenAI or Anthropic. A separate Anthropic key is only needed if you use plain-English segment criteria.
The screenshots show the real Mirabelle interface with a fictional account and simulated
connection results. The .example Ollama host is a placeholder, and no real keys appear.

Example: the Northstar Planning demo tenant uses a model hosted on its own network.
- Ask your infrastructure administrator to install Ollama on the model server and download the model there if it is not already installed. The download commands are in the developer section.
- Set Provider to Ollama. In Ollama endpoint URL, replace the example
http://ollama.planning.example:11434with the address reachable from the Mirabelle server, not from your browser.http://localhost:11434applies only when Ollama listens on that port on the same host as Mirabelle. Leave the field blank to use the deployment's configured Ollama address. - In Model, choose the installed model or select Enter a new model... and enter its exact tag, for example
qwen2.5-coder:7b-instruct-q3_K_M. A standard local Ollama connection has no API key to create or paste.

Example: OpenRouter connects Mirabelle to DeepSeek V4.1 Flash. The dots represent a masked key, not a value to enter, and the green result shows reachability only.
- Sign in to your organisation's OpenRouter account. For a paid model, make sure the account has credits.
- Open OpenRouter → API Keys, create a standard API
key, and name it for its purpose, for example
Mirabelle Northstar Sandbox. Set a credit limit that matches your approved budget and copy the key when it is shown. See OpenRouter's key instructions. - In Mirabelle, set Provider to OpenRouter and use
https://openrouter.ai/api/v1as the OpenRouter endpoint URL for the standard service. -
In Model, choose a saved model or enter its exact ID from the model catalogue. For the DeepSeek V4.1 Flash example, use:
deepseek/deepseek-v4.1-flash-1017 -
Paste the key into OpenRouter API key. A key issued directly by OpenAI or Anthropic cannot replace the OpenRouter key in this field.
Verify the chat connection¶
- Wait for Saved, then click Test connection. Ollama checks that the server responds and can flag a model that is not installed. If the Ollama result also says no API key configured, that is expected for a standard local connection. OpenRouter checks that the service responds and whether a key is configured. It does not send the key or verify its validity, account credits, or access to the selected model.
- Select a pipeline with saved results, open Mirabelle → Chat, and ask "Which items have the lowest fill rate?" A grounded answer with supporting data confirms the setup in a way that a green Reachable message alone cannot.
- If the service is reachable but a question fails, check the exact model name. For OpenRouter, also check that the key is active, the account has credits, and the model is available to it.
Saved settings apply to the next question without restarting Mirabelle. Currently active shows the saved provider and model. To switch back to local inference, select Ollama again, choose a saved model, and verify the endpoint and model name.
Choose where your data goes
With Ollama hosted inside your infrastructure, the model calls can stay on your network. With OpenRouter, chat text and relevant schema and planning context go to the external service. For explanations, so do up to 25 result rows and the calculated aggregates. Mirabelle still runs the query on its server; the provider does not connect to the database. Check your organisation's data policy before enabling cloud inference. Hiding SQL in the chat does not stop the model calls.
Optional: Segment parsing with Anthropic¶
This setting is only for Segments → New Segment → Describe in plain English, which drafts filters for you to review. It is independent of the chat provider. If you build segments manually, you do not need this key. When you use the helper, Mirabelle sends your description and the available filter fields to Anthropic.

Example: a workspace-scoped Anthropic API key is set and the Claude model is claude-haiku-4-5.
- Sign in to your organisation's Claude Console → API Keys
and select Create key. Name it, for example
Mirabelle Northstar Segments, and scope it to a workspace with API billing and model access. For a shared deployment, use an approved service account key where available. See Anthropic's key instructions. - In Settings → AI, expand Other AI features. Paste the key into Anthropic API key
and enter the exact Claude model ID for your workspace, for example
claude-haiku-4-5if available. Check the Claude model catalogue for available models. This field takes a direct Claude model ID, without the OpenRouteranthropic/prefix. - Wait for Saved, then try "Items with a unit price above 500" under Describe in plain English → Build criteria. Review the filters before creating a segment. Test connection checks the chat provider, not Anthropic segment parsing.
Keep provider keys private
Paste keys only into their matching settings fields, never into Chat, screenshots, or a support ticket. Leave a masked field unchanged to keep its key. To replace one, select the whole masked value and paste a new key. Clearing the field removes the tenant's stored key, but a key configured by the deployment may still apply. If a key is exposed, revoke it at the provider and replace it in Mirabelle.
Use and verify the answer¶
- Set the context. Select the pipeline in the left toolbar. Open Mirabelle (the right edge on desktop, the toolbar on mobile) and choose Chat.
- Ask a focused question. Name the metric, the item or site if known, and the time window. Click OK or press Ctrl+Enter (Cmd+Enter on Mac). You can also start with a quick prompt.
- Follow up and verify. Start with "Which items have the lowest fill rate at [site name]?" Then ask "For [item name] at that site, show the projected shortage in units for each of the next four planning weeks and the total." Check the total against the rows. No matching rows do not prove that the shortage is zero.
Other controls in the panel:
- Explain: choose brief, standard, or detailed. Speed → fast skips the model's written explanation and returns a short summary instead; thorough allows more attempts to generate a valid query than std does with the default settings.
- Show data opens the data behind a chart. Click a result row with a drill-down arrow to open the relevant planning view. How was this answered? shows the reported tables and concepts.
- View SQL, above the results, shows the exact query sent to the database after Mirabelle applied the planning scope. It is available even when a query returns no rows. If execution fails, it shows the last query Chat tried to run. If there is no saved query, Chat says so. SQL is visible to everyone by default; administrators can restrict it in Settings → AI → Assistant behaviour → SQL visibility without changing what Chat reads.
- Glossary lets you browse concepts, tables, and examples. Clear conversation starts fresh; use it when switching pipelines or testing a different model.
- Exceptions is a separate tab for reviewing alerts, with manual approve/reject buttons. Asking a question in Chat never performs those actions.
- Thumbs-up and thumbs-down under an answer rate it for an administrator to review; see Rate an answer, and teach Mirabelle.
Rate an answer, and teach Mirabelle¶
Press the thumbs-up or thumbs-down under an answer, and an administrator decides whether it should change future answers. Nothing changes by itself: your rating waits in a review list with your question and the answer you saw, and only an approved rating helps Mirabelle answer similar questions for your whole tenant.
flowchart LR
accTitle: From a rating to a better answer
accDescr: A planner rates an answer, an administrator reviews it, and approved feedback is offered to the model for similar questions.
A["1. You rate an answer<br/>thumbs-up, or thumbs-down<br/>with a reason"]
B["Review list<br/>Settings → AI → Ontology<br/>→ Chat feedback"]
C["2. An administrator reads it,<br/>adds a note or a corrected query,<br/>approves or rejects"]
D["Approved feedback<br/>(examples and notes<br/>of your tenant)"]
E["3. A similar question<br/>is answered with it in view"]
A --> B --> C --> D --> E
classDef io fill:#e7f6f0,stroke:#10b981,color:#1b4332;
classDef proc fill:#eef2ff,stroke:#6366f1,color:#312e81;
class B,D io;
class A,C,E proc;
-
Rate the answer. Press the thumbs-up when the answer matched your question. Press the thumbs-down when it did not, choose what was wrong (wrong numbers, wrong table or measure, wrong filter or scope, did not understand the question or something else) and add a few words if you like. Press the same thumb again to take the rating back, or the other thumb to change it, until an administrator has reviewed it. Example: you asked "Which allocations are causing shortages?" and the table lists allocations that are fully served; you press the thumbs-down and choose wrong filter or scope.

The thumbs under an answer, with the reason list open (illustrative data).
-
An administrator reviews it. In Settings → AI → Ontology → Chat feedback every rating appears with who asked, when, the question, the answer that was shown and the query that ran. The administrator writes what Mirabelle should learn, then approves or rejects the rating:
- for a liked answer, the query behind it (with the pipeline, scenario and planning date replaced by placeholders) becomes a worked example;
- for a flagged answer, only what the administrator writes helps: a short note and/or the corrected query. The query that produced the wrong answer is never shown to the model as an example.
Example: the administrator opens your thumbs-down, writes the note "Unmet allocation demand is in the unfulfilled-allocations table, not in the allocation results" and presses Approve.
-
Similar questions are answered with it in view. From then on, when someone asks a question that shares most of its meaningful words with the rated one, Mirabelle gives the model the approved example or note together with the usual context. How was this answered? then reads Informed by N approved ratings from your team. Example: a colleague asks "Which allocations cause shortages?" and sees that line. Mirabelle compares words, not meaning: "Which allocations are short?" shares too few words to count.
What an administrator can do¶

The review list: filter by status or rating, search by question or person, open a row (illustrative data).
A row opens a window covering 80 % of the screen. The left side is the context: who asked and when, the question, the answer that was shown and the query that ran. The right side, What this teaches Mirabelle, holds the example query and the note; both save automatically.

The review window (illustrative data).
- The Chat feedback tab carries the number of ratings that are waiting. Filter by status (Waiting, Approved, Rejected, All) and by liked or flagged, or search by question or person.
- Approve is available when the rating can teach something: a liked answer needs its example query, a flagged one needs a note or a corrected query. The example must pass the same checks as any query and be at most 2,000 characters; the screen says what is missing.
- Reject keeps the rating as a record and never uses it. Reopen returns an approved or rejected rating to Waiting; an approved rating must be reopened before it is edited. Delete removes it for good.
- Export approved downloads the approved examples, notes and confirmed mistakes as a file, to review before anything is added to the ontology that ships with Mirabelle.
What it can and cannot do¶
- A thumbs-up means this matched my question, not the numbers are right: check the answer before approving it.
- Approved feedback guides the model; it cannot force it. Examples and notes apply to every pipeline of your tenant and never leave it.
- You can rate an answer for 60 minutes after it was given, and a reply that ended in an error can be flagged but not liked. After that, or after the server restarted, the thumbs say the answer can no longer be rated.
- A rating stores your name and e-mail, the question, the answer text and the query, never the rows of the result. Nothing expires by itself; administrators can delete ratings.
- The thumbs are in the desktop panel. The phone assistant does not have them yet.
Ask the guide: how Mirabelle works¶
Switch the chat to Ask the guide and ask how Mirabelle works: it shows the sections of this user guide that answer your question, with a link to each. It never reads your plan and never uses a model unless an administrator switches summaries on, so a question about how something works costs no data access. Use Ask my data for questions about your items, sites and orders.
flowchart LR
accTitle: From a question about Mirabelle to the sections of the guide
accDescr: The question is compared with every section of the published guide; the three closest sections are shown with links, or the panel says the guide does not cover it.
Q["1. You switch to Ask the guide<br/>and ask a question"] --> M["2. Mirabelle compares it with<br/>every section of the guide"]
M -->|"close enough"| S["3. The three best sections<br/>with a link to each"]
M -->|"nothing close"| N["3. 'Not covered'<br/>and a hint what to try"]
classDef proc fill:#eef2ff,stroke:#6366f1,color:#312e81;
classDef io fill:#e7f6f0,stroke:#10b981,color:#1b4332;
class Q,M proc;
class S,N io;
-
Switch to the guide. At the top of the Chat tab press Ask the guide (the other button is Ask my data). The panel remembers your choice in this browser. A line under the buttons says Guide ready and how many pages it holds. Example: the placeholder of the question box now reads Ask the guide… and the four suggestions are about the guide.

The panel after switching (illustrative).
-
Ask in your own words. Press OK or Ctrl+Enter (Cmd+Enter on Mac). Example: "How do I approve an order on my phone?" returns three sections of chapter 15, the best one open, each with its place in the guide.

An answer: the sections that match best, with the passage that matched (illustrative).
-
Read the passage, then open the page. A … at the start or the end of a passage means the section continues there. Open in the guide opens the published page at that section in a new tab. Example: open the second section, 15.7 — The cart and the final approval, for the full description of the cart.
-
If it says Not covered, change the words. The panel shows The guide does not cover this closely enough instead of sections that only look similar. Example: "What is the weather in Madrid?" is not documented and shows no sections. Rephrase with the words the guide uses, or switch to Ask my data if the question is about your own plan.

No sections are shown when nothing is close enough (illustrative).
What it can and cannot do¶
- It answers only from the pages published on the documentation site. Internal reports and test plans that are not published are not searched.
- It compares meaning, not exact words, so a question phrased differently from the guide is usually found; a question about something the guide does not describe is turned away. Occasionally a documented topic is turned away too: try other words.
- The first start takes about a minute, while the guide is prepared (and the very first time on a server it needs internet access once to download a small language model). The panel says Preparing the guide; you can type your question meanwhile and press OK once it is ready.
- Nothing you ask is stored: the audit log keeps who asked, when, how many sections matched and how long it took, never the question or the text. Twenty questions a minute per person is the limit.
- A question about your own data ("which items are short?") belongs in Ask my data.
What an administrator can do¶
In Settings → AI → Ask the guide - answers choose what an answer is made of:
- Sections of the guide with links (the default): no language model is used and nothing leaves the server.
- Sections plus a short summary written by the chat model: the question and the matching guide text go to the provider of the tenant's chat model, as for any other question. The summary is checked: it is withheld when it contains a number that is not in the matched sections, when it is too long, or when the model says the guide does not cover the question. The sections are always shown. A small local model is cautious and sometimes says not documented for a documented topic, which is the safe direction; a strong cloud model writes better summaries.
Connect AI to Mirabelle, and Mirabelle to other AI (MCP)¶
Two directions, one standard
Model Context Protocol (MCP) is a standard way for an AI app to use tools in another system. With Mirabelle it works in both directions: into Mirabelle, so your own AI app can read planning data — and, if you grant it, act on your review queue exactly like your phone; and out of Mirabelle, so the Chat assistant and jams can call tools on MCP servers your administrator registers. The inbound connection does not use the model chosen in Settings → AI: the AI app uses its own.
How the connections fit together¶
flowchart LR
accTitle: The two MCP connection directions around Mirabelle
accDescr: On the left, an external AI app is approved by the planner on a consent page, then calls the Mirabelle MCP server with a read-only or read-and-write authorization and receives planning data within the planner's scope. On the right, Mirabelle's Chat assistant and jam steps call tools on MCP servers an administrator registered in Settings AI, and the gathered context is used in the answers. Both directions are checked and audited.
subgraph IN["INTO Mirabelle — your AI app"]
APP["Your AI app<br/>(its own model)"]
CONSENT["Consent page<br/>Approve: read-only<br/>or read + write"]
GATE["Every call is checked:<br/>who, scope, segments,<br/>rate limits"]
DATA["Planning data<br/>within your scope"]
APP -->|"1. asks to connect"| CONSENT
CONSENT -->|"2. one Approve click<br/>in your browser"| APP
APP -->|"3. tool calls<br/>with its own token"| GATE
GATE --> DATA
DATA -->|"4. answers"| APP
end
subgraph MIR["Mirabelle"]
MCP["The Mirabelle MCP server<br/>10 read tools + 7 write tools"]
CHAT["The Chat assistant<br/>and jam steps"]
MCP --- GATE
end
subgraph OUT["OUT of Mirabelle — other people's servers"]
REG["Settings → AI → MCP Connections<br/>(an administrator registers servers)"]
EXT["External MCP servers<br/>(their tools)"]
CTX["Gathered context,<br/>used in the answer"]
REG --> EXT
CHAT -->|"Chat tool-calling switched on:<br/>may call their tools first"| EXT
EXT --> CTX --> CHAT
end
classDef io fill:#e7f6f0,stroke:#10b981,color:#1b4332;
classDef proc fill:#eef2ff,stroke:#6366f1,color:#312e81;
class APP,DATA,EXT,CTX io;
class CONSENT,GATE,MCP,CHAT,REG proc;
Into Mirabelle — what an approved app can do. The ten read tools cover the planning context, the review queue and one order's full detail, item stock and overview, the supply orders, a series' forecast, the weekly demand basis (netting), the safety-stock results and the supply exceptions. The seven write tools mirror your phone app: accept an order into the approval cart (with an optional quantity or date edit), edit or remove a cart line, cancel an order, put a cancel back, and submit the final approval of the cart. A write runs exactly the same rules as your phone — production pipelines only, your segments only, the same limits — and lands in the same audit trail with your name on it, whichever door was used.
Who does what
- A developer or administrator sets up the AI app's side of the connection — in this release that is done with a login helper described in the reference. The planner's own part is to sign in and approve.
- A signed-in planner approves or denies the connection on the consent page, which names the planner and the tenant and lists exactly what the app may do: read-only, or read plus the write powers. An approval lasts at most 90 days and can be ended at any time. Disabling the planner's account or changing their password ends it too; the reference page gives the exact rules.
- Mirabelle checks the connection on every call and records every tool call in the audit log — who called which tool and whether it worked, never what was asked or returned.
- An administrator registers the outbound servers (Settings → AI → MCP Connections), switches Chat tool-calling on or off, and holds the tenant's MCP on/off switch on the Security page.
How to set it up and test it — an AI app reading (or acting) for you¶
⚙ Process: your administrator runs the login helper for the app (the exact command is on the reference page); you approve it in your browser; you test it on the console page.
- Ask for the connection. Your administrator starts the login helper for the AI app — read-only by default, or with the write powers when the app should be able to act. A browser tab opens on the consent page.
- Approve it. Check that the page names you and your tenant, and that the powers listed are what the app should have (read-only, or read + the write powers, which the page spells out: the cart, cancels, the final approval). Click Approve.
- Test it. Open the console page (Settings → AI → Connectivity → MCP test console; any signed-in user can): paste the access token the helper printed, and the page can run every tool for you — start with the planning context, then the review queue, and, with a write authorization, try the cart tools on a test order.
- See what is connected. The same console page lists your agent authorizations — what was approved, when the app last used it, and a Revoke button that ends it at once (every token of that app dies with it). Administrators see every planner's authorizations on the Security page's Agent Access tab.
How to set it up and test it — Mirabelle calling other servers¶
⚙ Process: an administrator registers the server in Settings → AI → MCP Connections, presses Test, and switches Chat tool-calling on in Settings → AI → Connectivity.
- Register the server. Settings → AI → MCP Connections → Add an MCP server: a name (the name jam steps will declare), the server's address, and — if it needs one — the authentication header, whose value is kept secret and masked.
- Test it. Press Test on the same tab: Mirabelle connects and lists the tool names the agent would see. A failure says why.
- Switch it on. Settings → AI → Connectivity → Chat tool-calling → On.
- Test it. Ask the Chat panel a question that needs the outside world, and read the answer: the tools it used are listed with the answer (names only). A jam's model step can also declare the servers it needs — an approved jam that no longer finds its server refuses to run and says so, it never guesses.
The bundled mailbox connector. The first connector ships with Mirabelle, in two shapes. Your administrator can connect the company mailbox on Settings → AI → Mailbox (IMAP, Microsoft 365 or Gmail) — then the assistant and jam steps can list, search, read, send and mark-read mail through five tools with nothing else to run; or run the standalone connector process and register it on the MCP Connections tab, for teams that prefer the mailbox credentials to live outside the platform entirely. Both shapes serve the same five tools, keep the credentials masked, and are covered by the same bounds and audit trail — the reference page has the exact steps.
Limits to keep in mind
- Writes are your writes. Whatever an approved app accepts, cancels or approves carries your name and your segment scope — treat an approval with the write powers like handing over your phone.
- Production pipelines only, and only the segments the planner is allowed to see: the same rules the phone app applies.
- The data leaves Mirabelle. An AI app receives what its tools return, so that product's data handling must be approved too, whichever model Mirabelle's own Chat uses.
- Few clients tested. Only the login helper that ships with Mirabelle and the official MCP Python SDK have been verified. Mirabelle has one fixed connection identity, sends the approval back only to the planner's own computer and offers no self-registration, so AI products that register themselves, or that need the approval sent to a web address, cannot connect yet. Claude Code, Claude Desktop, Cursor and MCP Inspector have not been tried.
- Outbound calls are bounded. At most a handful of tool calls per chat answer, every result size-capped, every call audited — and the secret header value never appears in a log, an audit row or a prompt.
See the MCP server reference for the tools in detail, the exact commands to authorize and test a connection, the security rules and the known limits. To ask questions inside Mirabelle, keep using the in-app Chat panel: the inbound connection is for other AI apps.
12.3 — Why you can trust the answer¶
| Guardrail | What it protects you from |
|---|---|
| Schema checks | The validator checks table names and qualified column references. A wrong unqualified column can still fail at the database. |
| Planning scope | The server applies the requested pipeline and matching scenario before the query can combine or total rows. A different ID in the model's draft cannot broaden the request. |
| Read-only queries | The application validates the query before execution, and the ClickHouse query runs in read-only mode. |
| Bounded retry | Mirabelle can try to fix a failed query. An exhausted attempt is shown as an error, not a zero; a successful query can still return no matching rows. |
| Guide answers come from the guide | Ask the guide shows passages of the published user guide with a link to each, and says Not covered instead of guessing. A generated summary is withheld when it contains a number the guide does not. |
| Evidence behind the summary | The data and calculated aggregates are the evidence. The model's prose can still be wrong or overstate what the data explains. |
12.T — Step-by-step test walkthrough¶
Mirabelle AI — the NL → SQL assistant.
| # | Where to look / what to click | You should see |
|---|---|---|
| 1 | Select a pipeline with saved results and open the Mirabelle chat panel | The empty state offers quick prompts. |
| 2 | Ask "Which items have the lowest fill rate at [site name]?" and open View SQL above the results | The query uses the selected pipeline and its MEIO scenario. If your role cannot see SQL, Chat explains the restriction. |
| 3 | Follow up with the four-week shortage question above | The query uses the Supply scenario and planning date. Check the weekly rows and total against the Supply view. |
| 4 | Name two pipelines explicitly in a comparison, then ask an ordinary question without naming either | The first answer names both pipelines. The next answer uses only the selected pipeline and its linked scenarios. |
| 5 | If your test tenant permits both providers, clear the conversation and repeat with the other model | The data scope stays the same for the same question. Compare the actual filters, result, and wording rather than expecting identical answers. |
| 6 | Ask a question in the Mirabelle panel, then press the thumbs-up under the answer | The thumb is highlighted and the note reads Liked - sent for review. Press it again: the rating is taken back. |
| 7 | Press the thumbs-down under an answer | Five reasons appear and Send stays disabled until one is chosen. After Send the note reads Flagged: … - sent for review. |
| 8 | As an administrator open Settings → AI → Ontology → Chat feedback | The tab shows the number waiting; your ratings are listed as Waiting with your name. |
| 9 | Click the liked row | A window covering 80 % of the screen shows the question, the answer, who asked and when, and the query that ran. The example query is prefilled with placeholders. |
| 10 | Press Approve, then ask a question with much the same words | How was this answered? reads Informed by 1 approved rating from your team. Press Reopen and ask again: the line is gone. |
| 11 | Open the flagged row and look at Approve | It is disabled and says what to add. After you write a note it works. |
| 12 | In the Mirabelle panel press Ask the guide | The placeholder reads Ask the guide…, the Explain / Speed bar disappears, and a line says Guide ready with the page count (or Preparing the guide during the first minute after a restart). |
| 13 | Press the suggestion about approving on the phone | Three sections of the mobile chapter appear, the first open, under Sections of the guide. Press Open in the guide: the published page opens at that section. |
| 14 | Ask "What is the weather in Madrid?" | Not covered, no sections, and a hint to rephrase or switch to Ask my data. |
| 15 | Switch back to Ask my data and ask a data question | The data chat answers as before; the guide's line is gone. |
| 16 | As an administrator open Settings → AI and look at Ask the guide - answers | Two choices: sections only (default) or sections plus a model-written summary. |
For repeatable offline checks and live model comparisons, use the Mirabelle AI Testing Guide. A small passing fixture set does not establish model reliability.

The Mirabelle panel on the planning workspace, shown with a local Ollama connection.

The Help tab includes example prompts. Use Settings → AI to verify where your deployment's model actually runs.
12.D — For developers — API, model & internals¶
In-app API: POST /api/mirabelle/chat takes the selected pipeline_id, a question, and
display options. It resolves scenario links server-side and returns an answer, data, chart hints,
planning_scope, and the executed SQL if permitted.
GET /api/mirabelle/status reports the configured model and index health; GET /glossary,
GET /history, POST /clear, and POST /index (admin) are under the same /api/mirabelle
prefix. These application endpoints (/api/mirabelle/...) are not the MCP interface. The MCP server
is a separate, read-only endpoint (/api/mcp) that accepts agent tokens only, not the browser session
the app uses; see the MCP server reference.
Configuration and audit: files/mirabelle/gateway.py resolves the tenant ai settings over
deployment defaults for each turn. chat_model is the single editable chat model ID, and the
server saves recently selected IDs per provider in chat_model_history. The legacy second model
field is converted on read and removed from storage the next time AI settings are saved.
PUT /api/ai-settings and POST /api/ai-settings/test
require an admin; the probe sends no provider key. The Anthropic fields for segment parsing are
separate from Chat. The mirabelle_chat audit entry records the selected provider and model,
attempt count, latency, outcome, and token usage when reported, not the question, SQL, or key.
The SQL repair loop and provider retries are separate. See the
Testing Guide for settings and defaults.
Chat feedback (likes and dislikes of answers): the chat answer carries turn_id (an opaque
handle to the server's own copy of the turn, kept in memory for 60 minutes) and learned_used (the
ids of the approved ratings that informed the prompt). A rating names the turn; the question, the
answer and the SQL come from the server's copy, never from the request. Ratings are stored in
interact_chat_feedback (created by files/DDL/migrations/add_chat_feedback.sql and ensured at
startup) and steer answers only once approved.
| Call | Purpose | Permission |
|---|---|---|
POST /api/mirabelle/feedback |
rate a turn: turn_id, verdict (up or down), reason (for a down), comment |
chat.use |
DELETE /api/mirabelle/feedback/turn/{turn_id} |
take a rating back while it is unapproved | chat.use |
GET /api/mirabelle/feedback/items |
the review list (status, verdict, q, limit, offset; counts per status) |
settings.ai.write |
GET /api/mirabelle/feedback/items/{id} |
one rating with its full context | settings.ai.write |
PUT /api/mirabelle/feedback/items/{id} |
write the note (lesson) and/or the example (sql_template) |
settings.ai.write |
POST /api/mirabelle/feedback/items/{id}/review |
action: approve, reject or reopen, with an optional note |
settings.ai.write |
DELETE /api/mirabelle/feedback/items/{id} |
delete a rating | settings.ai.write |
GET /api/mirabelle/feedback/export |
approved examples, notes and confirmed mistakes, as a file | settings.ai.write |
At most 30 rating changes a minute per person. Every change writes a chat_feedback audit row
(ids, verdicts, statuses and field names, never the question, the answer or the SQL).
MIRABELLE_LEARNED_EXAMPLES (default 1), MIRABELLE_LEARNED_NOTES (2), MIRABELLE_LEARNED_MIN_SCORE
(0.4) and MIRABELLE_LEARNED_MAX_ROWS (400) tune retrieval: an approved row matches when it shares at
least two meaningful words with the question and their overlap reaches the minimum score. Code:
files/mirabelle/turns.py, files/mirabelle/feedback.py, files/api/chat_feedback_router.py;
frontend ChatFeedbackBar.jsx, ChatFeedbackPanel.jsx, OntologyTab.jsx and utils/chatFeedback.js.
Ask the guide (retrieval over the published docs): GET /api/mirabelle/guide/status reports the
index state (idle, building, ready, failed, unavailable), the number of pages, sections and
windows, the model and the tenant's answer mode; POST /api/mirabelle/guide takes {question} and returns
status (matched or not_documented), sources (title, chain, url, excerpt, more_before,
more_after, score), mode, top_score, the gate and, in generate mode, summary,
summary_status and llm. Both need chat.use. An index that is not ready answers 409
guide_not_ready (state, reason, retry_after_s), not 503, because the web client retries a 503 on its
own and would hide the reason. More than 20 questions a minute per person: 429 with Retry-After; in
generate mode one question at a time per person. The audit row (mirabelle_guide / ask) carries the
mode, verdict, scores, durations and provider, model and usage, never the question or the answer.
The index is built from docs/**/*.md minus the patterns of exclude_docs in mkdocs.yml (the same
files the site publishes; another form of that setting fails loudly). Each section is cut into windows of
about 900 characters, wrapped source lines are joined into the paragraph a reader sees, and each window is
embedded with its place in the guide (Chapter > Section: text) by sentence-transformers/all-MiniLM-L6-v2
on the CPU. Vectors are cached in files/mirabelle/guide_cache/ under a key made of the parser version, the
model and every text, so an edited page re-embeds on its own. The best window of each of the three best
sections is shown; the answer is not_documented unless the best window reaches 0.45 cosine (measured
on 23 documented, 6 undocumented and 4 data questions: 22 of 23 documented ones pass, all undocumented are
turned away; tests/test_guide_golden.py re-measures it). Links are the section's id as python-markdown
gives it (a parity test compares every heading of the real docs tree).
| Setting | Default | Meaning |
|---|---|---|
MIRABELLE_GUIDE_DOCS_DIR, MIRABELLE_GUIDE_MKDOCS_YML |
the repository's docs/ and mkdocs.yml |
where the pages and the publishing rules live |
MIRABELLE_GUIDE_BASE_URL |
https://mirabelle.es/docs/ |
where the pages are published (the links of an answer) |
MIRABELLE_GUIDE_CACHE_DIR |
files/mirabelle/guide_cache |
cached vectors (an optimisation) |
MIRABELLE_GUIDE_MIN_SCORE, MIRABELLE_GUIDE_TOP_K |
0.45, 3 |
the gate and the number of sections |
MIRABELLE_GUIDE_DEVICE |
cpu |
where it embeds (the GPU belongs to the chat model) |
MIRABELLE_GUIDE_WARMUP |
1 |
build the index in the background when the API starts |
ai.guide_answer_mode |
extract |
extract or generate (Settings → AI); anything else is a loud error |
pip install "sentence-transformers<6" on the server (version 6 pulls transformers 5, which
chronos-forecasting does not support); the first start downloads the model (about 87 MB). Code:
files/mirabelle/guide.py, files/api/guide_router.py; frontend GuideAnswer.jsx, utils/guideChat.js
and the switch in MirabellePanel.jsx.
Prepare the local Ollama example¶
On the machine that runs Ollama, download the example model and verify its exact tag:
The guardrail layers (the honest list):
| Layer | Meaning |
|---|---|
Schema metadata (schema_metadata.json) |
Gives the model table and column definitions to work from. |
Synonym map (SYNONYM_TABLE_MAP) |
Points the model toward relevant tables: for example, “service level” suggests PIPE_meio_results. |
Column validator (sql_validator.py) |
Checks hallucinated alias.column references before execution. |
Deterministic fixers (service.py) |
Correct common syntax and column mistakes, and resolve planning-date placeholders for single-pipeline questions. |
Planning scope (query_scope.py) |
Parses the ClickHouse query and applies server-owned filters to each table source, including joins, subqueries, CTEs and unions. Netting uses the series scenario; indirect demand and the repair forecast are pipeline-level products. If the request is a comparison, the filter pairs each pipeline with its own scenario IDs. |
Read-only enforcement (executor.py) |
SELECT/WITH-only blocklist + server-side readonly=2 — a surviving write/DDL attempt dies at ClickHouse. |
Ollama context window (num_ctx 8192 by default) |
Gives the system prompt, ontology context, and recent turns room. This setting does not control the context window of a hosted OpenRouter model. |
The known failure modes (documented, not hidden):
| Failure mode | The guard |
|---|---|
unique_id used on a table that does not have it |
The fixer rewrites known legacy expressions to item_id and site_id. |
forecast_accuracy column hallucinated |
The schema metadata says it doesn't exist; the prompt says “use smape or mape” |
consumed column hallucinated |
The prompt says: “use stat_consumed_qty + maint_consumed_qty + causal_consumed_qty” |
| Missing or incorrect scope filters | The server constrains each table independently and corrects stale numeric equality filters in single-pipeline queries. Unsupported query shapes are retried or rejected, never run without verified scope. |
| Bare column names in aggregates | The validator catches alias.column but bare names pass and fail at CH — the known gap |
| Dropping complex expressions when copying long SQL | Keep the example SQL short and single-purpose |
Key files: files/mirabelle/ — service.py (orchestration + fixers), sql_generator.py
(system prompt + context window), sql_validator.py, query_scope.py (planning scope),
executor.py (read-only), retriever.py
(hybrid keyword + LanceDB retrieval), explainer.py + chart_advisor.py, schema_metadata.json /
sql_examples.json / glossary.json (the ontology), config.py (model/env). Frontend:
files/frontend/src/components/MirabellePanel.jsx (tabs, rendering, _navTarget row-click
routing).