ecommerce-oltp
This server exposes MCP tools for fraud-case evidence, Genie fraud-agent listings, OLTP data generation, star-schema ETL, and constrained dataset queries.
Fraud cases and agents –
list_fraud_casesreturns the 15 named fraud evidence packs;list_fraud_agentslists the 10 Genie fraud specialists;run_fraud_caseruns one case (01–15) returning at most 50 evidence rows;run_fraud_agent_casesruns all cases owned by one specialist.Historical OLTP generation –
generate_historical_oltpwrites customers, addresses, orders, lines, shipments, andentity_linkrows, with configurable customer count, years, and orders per year, optionally as a Databricks job.Realtime/CDC order generation –
generate_realtime_ordersappends 100–10,000 new OLTP orders for a selected year window, optionally as a job.Star-schema ETL –
etl_star_historicalrebuilds dims andfact_salesfrom OLTP (overwrite);etl_star_cdcapplies the Delta change feed fromcustomer_orderintofact_sales(append).Controlled data access –
query_datasetruns a single SELECT against dims, facts, or OLTP with a forcedLIMIT 50, preventing full-table dumps.
Provides tools for triggering Databricks-based Ecommerce Genie Ontology workflows, including OLTP historical/realtime data generation, CDC ETL into the star schema, and fraud evidence pack runs.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ecommerce-oltp Generate 5,000 realtime OLTP orders"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Databricks Genie Ontology
Governed customer sales and funds-movement data: Unity Catalog, OLTP, star schema, and fraud-ready MCP. Portal teams call LangGraph, Google ADK, or AWS Strands through FastAPI. Provision, load, and tear down with GitHub Actions — no notebook import.
All data management is currently managed in Databricks and Databricks Genie and its AI Agents.
Table of Contents
Related MCP server: OrderOps MCP
Running Agentic Fraud Analytics - Start To Finish
Use Actions → Run workflow. Time is the last measured GitHub Actions job duration (19 Sep 2026 Step 100 unless noted). Look at the GitHub run first, then the Databricks account and workspace pages.
Template URLs only — replace the {placeholders}:
Account workspace:
https://accounts.cloud.databricks.com/workspaces/{WORKSPACE_ID}?account_id={ACCOUNT_ID}Workspace home:
https://{WORKSPACE_HOST}Catalog:
https://{WORKSPACE_HOST}/explore/data/{CATALOG}Genie:
https://{WORKSPACE_HOST}/genieGenie MCP (one space):
https://{WORKSPACE_HOST}/api/2.0/mcp/genie/{SPACE_ID}Apps:
https://{WORKSPACE_HOST}/appsCustom MCP App:
https://{WORKSPACE_HOST}/apps/mcp-ecommerce-oltpDiscover:
https://{WORKSPACE_HOST}/search/discoverThis run:
https://github.com/{OWNER}/{REPO}/actions/runs/{RUN_ID}
Fresh start: run 01 - Setup - Step 100 - Create All Together. It chains 01 → 02 → 03 → 04 → 06 → 07. Atomic steps stay 01–10 so we can insert 11, 12, … in the middle later; 100+ stays the composite.
S. No | GitHub workflow name | Time | What to look at | Comments |
0 | 01 - Setup - Step 100 - Create All Together | 16 min | Same checks as Steps 01, 02, 03, 04, 06, 07 | Measured 15 min 51 s (19 Sep 2026, run 35472667395). Wall clock 01+02+03+04+06+07. One Run workflow. Skips Step 05 and Step 08. |
1 | 01 - Setup - Step 01 - Create Databricks stack | 5 min | GitHub job green; workspace RUNNING; SQL warehouse up; catalog empty tables | Measured 4 min 53 s (same Step 100). Workspace 42 s, warehouse 18 s, catalog 3 min 3 s, deploy jobs 42 s. Account page |
2 | 01 - Setup - Step 02 - Create all Genie agents | 1 min | 11 Genie spaces (Retail Analytics + 10 fraud specialists) | Measured 1 min 4 s. Genie |
3 | 01 - Setup - Step 03 - Publish ecommerce-oltp MCP App | 4 min | App mcp-ecommerce-oltp on Apps | Measured 3 min 30 s. |
4 | 01 - Setup - Step 04 - Publish Discover domains | 20 s | Discover cards for Sales, Customer, Supply Chain, Finance are Published | Measured 20 s. Domain API |
5 | 01 - Setup - Step 05 - Invoke Retail Analytics Genie | 3 min | Sample questions return SQL + a short answer | Measured 3 min 14 s (not in Step 100). Confirms Genie MCP on the retail space. Optional question input. |
6 | 01 - Setup - Step 06 - Populate next 100000 OLTP rows | 3 min |
| Measured 2 min 34 s for 100,000 rows on a warm cluster. Catalog |
7 | 01 - Setup - Step 07 - Populate next N months of dims and facts | 3 min |
| Measured 3 min 10 s for 3 months. Same catalog. Months 1–12 (default 3). Fraud reads |
8 | 01 - Setup - Step 08 - Pipeline next 100000 OLTP and next N months star | 6 min | Step 06 then Step 07 in one run | Last measured pieces: 2 min 34 s + 3 min 10 s. Use this instead of running 06 and 07 separately. |
9 | 02 - Fraud Agent - 01 - Fraud Velocity Agent | 3–10 min | Space Fraud Velocity Agent | Genie MCP for velocity bursts and split orders. |
10 | 02 - Fraud Agent - 02 - Fraud Address Link Agent | 3–10 min | Space Fraud Address Link Agent | Shared-address / duplicate-account hops. |
11 | 02 - Fraud Agent - 03 - Fraud Ship-to Bill-to Agent | 3–10 min | Space Fraud Ship-to Bill-to Agent | Ship-to ≠ bill-to. |
12 | 02 - Fraud Agent - 04 - Fraud Returns Agent | 3–10 min | Space Fraud Returns Agent | High / rapid returns. |
13 | 02 - Fraud Agent - 05 - Fraud First-Order Agent | 3–10 min | Space Fraud First-Order Agent | High-value first orders. |
14 | 02 - Fraud Agent - 06 - Fraud Address Surge Agent | 3–10 min | Space Fraud Address Surge Agent | New address + expedite / surge. |
15 | 02 - Fraud Agent - 07 - Fraud Promo Agent | 3–10 min | Space Fraud Promo Agent | Promo and discount abuse. |
16 | 02 - Fraud Agent - 08 - Fraud Inventory Agent | 3–10 min | Space Fraud Inventory Agent | Orders vs stock mismatch. |
17 | 02 - Fraud Agent - 09 - Fraud Cancel Agent | 3–10 min | Space Fraud Cancel Agent | Cancel / abort shipment. |
18 | 02 - Fraud Agent - 10 - Fraud Geo Agent | 3–10 min | Space Fraud Geo Agent | Default system prompt is the Case 15 notes. system_prompt overrides it. Five starter-question checkboxes ask those prompts. additional_prompt is comma-separated customer ids. |
19 | 01 - Setup - Step 09 - Destroy Databricks stack | 1 min | Workspace gone from account console; cleanup email | Measured 1 min 7 s (19 Sep 2026, run 35472183222). Type |
Historical generate / realtime CDC Actions are retired (z_retired_*). Use Step 100 for a full recreate, or Step 06 + 07 (or 08) for data only.
Screenshots
Catalog —
docs/images/catalog-explorer.pngCatalog
retail_oltpafter Step 01 — 13 source tables (analytics_log, customers, orders, postings, ingest). 2b. Catalogretail_starafter Step 01 — dims, facts, metric views.Genie Agents after Step 02 — Retail Analytics plus the ten fraud specialists.
Apps after Step 03 — mcp-ecommerce-oltp Active on
/apps-v2.




Business Context
Customer behavior
Customer behavior is how a person buys, pays, ships, and moves money over time: orders and lines, the addresses they use, channel, status, and — once funds movement is in scope — wires, cash, book transfers, CDs, brokerage, demand drafts, and cards. Most of that activity is legitimate. What matters is the baseline per customer: typical amount, velocity, counterparties, and whether a new address or a sudden outflow sits outside changing transaction behaviors.
Purpose
The purpose of this context is fraud detection: pick out abnormal behaviors and rare fraud cases in real time, while keeping false alarms down. Fixed thresholds and rule-based checks miss identity theft and automated attacks, and they raise false-positives when fraudulent transactions are extremely rare compared with legitimate ones. Amount, sudden loss of balance, and type of movement are the high-ranking signals; agents should use them for risk analysis without dumping ten years of rows into a model.
Fraud Detection behavior
Fraud judgment is the LLM fraud agent, not PySpark.
Each specialist has its own system prompt (amount vs baseline, sudden drain, transaction type, shared-address network, velocity, changing behavior, rare event, explain the why).
The agent writes one outcome per customer, not one verdict for a list.
A customer list is only for paging the work. Do not ask the model to judge thousands of IDs in one shot.
Outcome values:
fraud_foundornot_found.Persist on
analytics_log_customer:analytics_outcomeplusanalytics_log_info(JSON: the why — amount, velocity, address, type).Session table
analytics_log: requesting user, customer count, date range, requested datetime, analytics start/end, statusIn ProgressorCompleted.initiate_fraud_analytics(from_date, to_date)finds customer IDs on the server. It does not dump IDs into the LLM.That call creates
analytics_logand oneanalytics_log_customerrow per customer, with dim/fact counts for the same window.PySpark / SQL only prepare: customers in range, counts, optional evidence pack (named case, max 50 rows) as signals.
PySpark does not set
fraud_found. SparkHAVING/ dollar thresholds are a rule engine — they miss changing behavior and raise false positives.MCP never returns 300,000 postings or 15 million orders. Hydrate one customer at a time (max 50 evidence rows).
Agents stay customer-scoped. Loop sequential or parallel with a small concurrency cap.
Databricks Genie specialists run in the workspace on the same warehouse.
Portal agents (LangGraph, Google ADK, AWS Strands) call MCP through FastAPI — not raw tables.
Same customer and date explain both a velocity flag and a wire-outflow flag.
Sales fraud and funds-movement fraud share only
dim_customeranddim_date.Network hops use
entity_link(has_address,shared_address). No graph database for these cases.Generate / ETL / next-100k / next-N-months jobs load data. They do not classify fraud.
close_analyticssets statusCompletedwhen the agent says the run is done.
Customer Data Capacity Considered
Capacity is planned from 18 September 2016 through 18 September 2026 (ten years ending 18 September 2026). Agents never load this volume; they hydrate one customer at a time.
Item | Planned | Notes |
Customers | 100,000 | One person is one customer |
Accounts per customer | 4 | Checking, certificate of deposit, credit card, brokerage |
Transactions per customer per year | 30,000 | Sales lines and funds-movement postings in that year |
Years of history | 10 | End date 18 September 2026; start 18 September 2016 |
Transactions per customer | 300,000 | 30,000 × 10 years |
Postings in the warehouse | about 30 billion | 100,000 × 300,000 — design ceiling, not a generate job |
Create / Generate Historical never writes 30 billion rows. That load would run for days on a large warehouse and blow the 3-hour stack window. Default generate is 200 customers, 3 years, 500 postings per customer per year (about 300,000 postings) plus sales orders. Orders are also capped at 20 million rows per run.
OLTP and Star Schema Models
Sales and funds movement live in OLTP (customer, customer_address,
customer_account, customer_order, customer_order_line,
customer_order_shipment, customer_transaction, ingestion_tracker,
ingestion_log, analytics_log, analytics_log_customer) plus conformed dimensions
and facts (dim_account, dim_transaction_type, dim_counterparty,
fact_transaction with the sales stars). Design volume is the capacity above.
Agents are customer-scoped: initiate_fraud_analytics keeps IDs on the
server; the agent pages, hydrates one customer, and writes the outcome.
Databricks Genie agents run in the workspace. Non-Genie agents
(LangGraph, Google ADK, AWS Strands) come through the portal via FastAPI and
MCP. The LangGraph and Google ADK packages are conformance clients so the MCP
tools stay honest.
Business Data Architecture
DataWarehouse
A data warehouse turns ten years of customer activity into a place agents and people can ask the same question and get the same answer. Facts hold the numbers. Each fact row is one event (one sale line, one return, one money movement). Dimensions hold the who, when, what, and where. That is what makes amount, velocity, segment, and type comparable across 100,000 customers without each team rewriting joins on raw OLTP.
The Architecture behind MCP
The architecture behind MCP is what makes agentic AI fraud detection safe at this volume. Other teams build functional agents — amount vs baseline, sudden drain, type of movement, shared-address network, changing behavior, rare events. MCP does not scan 300,000 postings per customer. It answers those questions for one customer at a time from star facts (baselines, peers, type mix) or OLTP (the supporting orders and postings). Genie agents and portal agents call the same warehouse, so a velocity flag and a wire-outflow flag can be explained from the same customer and date.
Sales fraud and funds-movement fraud share dim_customer and dim_date only.
Do not hang wire transfers or card dues off customer_order / fact_sales.
Add a second fact table: one row per posting (customer_transaction /
fact_transaction) with account, type, counterparty, amount, and balance
before/after.


Fraud idea | Functional agent |
Amount + sudden origin-balance drain | Amount vs baseline — spend far above this customer's recent median; sudden drain |
Transaction type as a signal | Transaction-type — wire, cash, card, cancel, expedite, promo |
Graph / network features | Shared-address network — hops on |
Behavioral vs transactional vs network | Velocity, returns, geo, and first-order specialists |
Adaptive / changing fraud | Changing-behavior — realtime CDC windows, not a static snapshot |
Rare events + fewer false positives | Rare-event — peer baselines, not a blanket dollar threshold |
Feature importance / explainability | Explain the why — amount, velocity, address; not a black box |
Order-event star (current, fraud) — each row is one customer_order with hour-level order_ts, billing/shipping dim_address, and dim_region. Use this for velocity, ship-to≠bill-to, and Case 15 impossible geo (mv_order_event).
Sales star (STALE) — each row is one sales line (one product on one order). Kept for Retail Analytics merchandising history only. No hour, no shipping region. Do not use for fraud.

Returns star — each row is one return, tied to the same customer, date, and product as sales.

Inventory star (STALE) — monthly product/store snapshot. Kept so mv_inventory_health still answers stock questions. Not a customer-fraud grain. Case 11 is the only fraud agent that may still join it.

Funds-movement star — each row is one money movement. Customer and date match sales; account, type, and counterparty are new.

MCP contract (customer first)
initiate_fraud_analytics(from_date, to_date)— server finds IDs; writesanalytics_log+analytics_log_customerAgent pages customers; hydrates one customer (counts + max 50 evidence rows)
record_customer_outcome—fraud_found/not_found+ JSON whyclose_analytics— statusCompletedGenie in the workspace; LangGraph / Google ADK / AWS Strands via FastAPI → MCP, not raw tables
Dims (conformed)
Dim | Why |
| Home / billing / shipping geography for Case 15 |
| Ship-to vs bill-to and far-region ( |
| Type signal for funds-movement agents |
| Same vs other account; product (checking / CD / card / brokerage) |
| Other bank, other person, brokerage |
| Already present |
Do not add dim_wire, dim_cash, or dim_credit_card. Those are rows in
dim_transaction_type.
dim_transaction_type
type_code | class | direction | same_bank | same_account |
wire_transfer | transfer | out | no | no |
cash_deposit | cash | in | yes | yes |
cash_withdrawal | cash | out | yes | yes |
bank_transfer_other | transfer | out | no | no |
bank_transfer_same_acct | transfer | book | yes | yes |
intra_bank_same_accts | transfer | book | yes | no |
cd_withdraw | term | out | yes | no |
cd_deposit | term | in | yes | no |
brokerage_in | securities | in | no | no |
brokerage_out | securities | out | no | no |
demand_draft_request | instrument | out | yes | no |
demand_draft_issue | instrument | out | yes | no |
card_purchase | card | out | no | no |
card_payment | card | in | yes | no |
card_due | card | obligation | yes | no |
OLTP posting row: transaction_id, customer_id, account_id,
counterparty_id, type_code, txn_ts, amount, balance_before,
balance_after, status. Partition facts by date and cluster on
customer_id / account_id. Refresh fact_transaction incrementally; do not
overwrite 10 years on every run.
Each of api, workflows, and adapter_databricks has an ObjectsFactory
that looks up named components and caches singleton instances.
src/ecommerce_genie_ontology/
api/ # FastAPI + CliApp
objects_factory.py # ApiObjectsFactory
workflows/
objects_factory.py # WorkflowsObjectsFactory
orchestrator.py # WorkflowRunner
provision|create_agents|invoke_agents|cleanup/
workflow.py
workspace_facade/{interface,impl}.py
tasks/
adapter_databricks/
objects_factory.py # AdapterDatabricksObjectsFactory
daos/ # SDK / REST
facades/ # SqlFacade, GenieFacade, GovernanceFacade, JobsFacade
common/
interfaces/ # Protocols used for DI
dtos/ constants/ utils/Workflow | Job name | Tasks |
provision |
|
|
create_agents |
|
|
invoke_agents |
| one task per sample question |
cleanup |
|
|
generate_historical |
| PySpark OLTP history ( |
generate_realtime |
| Append 100–10,000 new OLTP orders for CDC |
etl_historical |
| Overwrite star-schema dims/facts from OLTP |
etl_cdc |
| Apply Delta change feed into |
generate_next_oltp |
| Append next 100,000 OLTP rows plus |
etl_next_months |
| Append |
Default generate is 200 customers, 3 addresses, 4 accounts, 25,000 orders per customer per year, 500 postings per customer per year, 3 years ending this month (about 15 million orders and 300,000 postings). That is per year, not per day. Dims/facts are rebuilt from those OLTP tables so they match. Do not set Generate to 100,000 × 30,000 × 10 — that is the design ceiling, not a GitHub Action.
Prerequisites
A Databricks workspace with Unity Catalog and a SQL warehouse
Permission to create a catalog/schema, metric views, and Genie agents
uv(this project does not use pip)
Setup
cp .env.example .envFill in at least:
DATABRICKS_HOST=https://your-workspace.cloud.databricks.com
DATABRICKS_TOKEN=dapiXXXXXXXXDATABRICKS_WAREHOUSE_ID is optional. Catalog provision looks up warehouse ecommerce-genie-ontology by name. Genie uses the same host/token unless you set GENIE_HOST / GENIE_TOKEN.
uv syncGitHub Actions (no local CLI)
Use Actions → Run workflow. Create starts a 3-hour timer; a later Create cancels the previous timer. Destroy can be run by hand any time before that. Pipeline workflows are also manual (workflow_dispatch only).
01 - Setup — 01–99 are atomic (rerun one, or insert a new number in the middle). 100+ is a composite.
01 - Setup - Step 01 - Create Databricks stack — workspace, SQL warehouse, catalog, deploy jobs
01 - Setup - Step 02 - Create all Genie agents — Retail Analytics + 10 fraud specialists
01 - Setup - Step 03 - Publish ecommerce-oltp MCP App — Databricks App
mcp-ecommerce-oltpfor LangGraph / ADK / Playground01 - Setup - Step 04 - Publish Discover domains — Sales, Customer, Supply Chain, Finance via
/api/discover/v1/domains01 - Setup - Step 05 - Invoke Retail Analytics Genie
01 - Setup - Step 06 - Populate next 100000 OLTP rows
01 - Setup - Step 07 - Populate next N months of dims and facts
01 - Setup - Step 08 - Pipeline next 100000 OLTP and next N months star
01 - Setup - Step 09 - Destroy Databricks stack
01 - Setup - Step 10 - Destroy Databricks stack in 3 hours
01 - Setup - Step 100 - Create All Together — 01 → 02 → 03 → 04 → 06 → 07. Fresh start after Destroy.
02 - Fraud Agent (each Action creates that specialist’s Genie space; Databricks hosts Genie MCP at /api/2.0/mcp/genie/{space_id})
02 - Fraud Agent - 01 - Fraud Velocity Agent
02 - Fraud Agent - 02 - Fraud Address Link Agent
02 - Fraud Agent - 03 - Fraud Ship-to Bill-to Agent
02 - Fraud Agent - 04 - Fraud Returns Agent
02 - Fraud Agent - 05 - Fraud First-Order Agent
02 - Fraud Agent - 06 - Fraud Address Surge Agent
02 - Fraud Agent - 07 - Fraud Promo Agent
02 - Fraud Agent - 08 - Fraud Inventory Agent
02 - Fraud Agent - 09 - Fraud Cancel Agent
02 - Fraud Agent - 10 - Fraud Geo Agent
Destroy deletes App mcp-ecommerce-oltp, drops the catalog, deletes the warehouse and workspace, then emails CLEANUP_NOTIFY_EMAIL that this codebase’s Databricks demo stack is gone and should not keep billing.
Repo Settings → Secrets and variables → Actions:
Secret | Purpose |
| Account API |
| OAuth M2M service principal |
| OAuth M2M secret |
| Users who can open the workspace UI |
| Inbox for the “stack cleaned” email |
| SMTP server (for example |
|
|
| SMTP login |
| SMTP password or app password |
| Optional From address; defaults to |
Optional: DATABRICKS_ACCOUNT_HOST, DATABRICKS_TOKEN, DATABRICKS_HOST, DATABRICKS_WORKSPACE_NAME, DATABRICKS_AWS_REGION, DATABRICKS_WAREHOUSE_NAME, DATABRICKS_CATALOG, DATABRICKS_SCHEMA, DATABRICKS_OLTP_SCHEMA.
Run locally (uses .env, talks to Databricks APIs)
Optional if you skip Actions → Run workflow. Same Databricks APIs; you run them from a machine with .env.
uv run genie-ontology run provision
uv run genie-ontology run create_agents
uv run genie-ontology run publish_mcp
uv run genie-ontology run publish_domains
uv run genie-ontology run invoke_agentsOr all three in order:
uv run genie-ontology run alluv run genie-ontology run invoke_agents --question "What was total revenue last quarter by product category?"
uv run genie-ontology run cleanup --confirm DELETE
uv run genie-ontology run truncate --confirm DELETECreate the Databricks workspace
Account-admin credentials in .env: DATABRICKS_ACCOUNT_ID plus DATABRICKS_TOKEN or OAuth client id/secret.
npm run ecommerce:workspace:databricks-setupEach ecommerce:*:databricks-setup command restarts local FastAPI so it always loads current code, then POSTs, then stops the server. No need to start ecommerce:api:run first or Ctrl+C afterward.
That calls POST /api/v1/ontology/provision-workspace and creates or reuses the serverless workspace named ecommerce-genie-ontology. Set DATABRICKS_WORKSPACE_ADMIN_EMAILS in .env (comma-separated) so those account users are assigned workspace ADMIN and can open the UI. The OAuth service principal is also assigned ADMIN; without a human email, only the SP can call APIs and you will see “You do not have permission to access this page”.
Create the SQL warehouse
After the workspace is RUNNING, create a serverless SQL warehouse (PRO + serverless compute, 2X-Small) named ecommerce-genie-ontology:
npm run ecommerce:warehouse:databricks-setupThat restarts FastAPI, POSTs WhReq to /api/v1/ontology/provision-warehouse, then stops the server. The warehouse is found later by name; copying warehouse_id into .env is optional.
Create the catalog, schema, and star tables
This is the reference-repo provision workflow: CREATE CATALOG / CREATE SCHEMA, star-schema tables, metric views, tags, and pages. Catalog defaults to ecommerce_genie_ontology; schemas default to retail_oltp (source) and retail_star (dims/facts) (DATABRICKS_CATALOG / DATABRICKS_OLTP_SCHEMA / DATABRICKS_SCHEMA in .env).
npm run ecommerce:catalog:databricks-setupThat restarts FastAPI, POSTs WfReq { "workflow": "provision" } to /api/v1/ontology/workflows/run, then stops the server.
Drop the catalog
Runs as the service principal (so you do not need MANAGE in the SQL Editor). Drops DATABRICKS_CATALOG with CASCADE and trashes the Genie agent. Workspace, warehouse, and metastore stay.
npm run ecommerce:catalog:databricks-truncateThen recreate with npm run ecommerce:catalog:databricks-setup.
HTTP interface
npm run ecommerce:api:runGET /healthGET /api/v1/ontology/workflowsPOST /api/v1/ontology/workflows/runbody:WfReqPOST /api/v1/ontology/workflows/deploybody:DpReqPOST /api/v1/ontology/provision-workspacebody:PwReqPOST /api/v1/ontology/provision-warehousebody:WhReqPOST /api/v1/ontology/truncatebody:TcReq(confirmmust beDELETE)POST /api/v1/ontology/destroybody:DyReq(confirmmust beDELETE; drops catalog, warehouse, and workspace)POST /api/v1/ontology/oltp/historicalbody:OhReqPOST /api/v1/ontology/oltp/realtimebody:OdReq(count100–10000,year_windowlatest|last_2|last_3|all)POST /api/v1/ontology/etl/historicalbody:EhReqPOST /api/v1/ontology/etl/cdcbody:EcReqPOST /api/v1/ontology/oltp/nextbody:NxReq(row_countdefault 100000)POST /api/v1/ontology/etl/next-monthsbody:EmReq(months1–12, default 3)GET /api/v1/ontology/fraud/casesPOST /api/v1/ontology/fraud/runbody:FcReq(case_id01–15)GET /api/v1/ontology/fraud/agentsPOST /api/v1/ontology/fraud/analytics/initiatebody:AnInitReqPOST /api/v1/ontology/fraud/analytics/getbody:AnIdReqPOST /api/v1/ontology/fraud/analytics/customersbody:AnListReqPOST /api/v1/ontology/fraud/analytics/customerbody:AnCustomerReqPOST /api/v1/ontology/fraud/analytics/customer/oltpbody:AnCustomerReqPOST /api/v1/ontology/fraud/analytics/customer/starbody:AnCustomerReqPOST /api/v1/ontology/fraud/analytics/outcomebody:AnOutcomeReqPOST /api/v1/ontology/fraud/analytics/closebody:AnIdReqPOST /api/v1/ontology/chatbody:ChReq(backendlanggraph|google_adk|genie)
Historical generate and ETL should run as Databricks jobs (as_job: true, the default) because 15 million orders need Spark. The local process only triggers the job.
How Genie Agent Works
Start with a Genie Agent (a Genie space). This is Databricks Genie on
/genie, not App mcp-ecommerce-oltp.
Genie Agent intro
Eleven spaces. Create all of them with GitHub Action 01 - Setup - Step 02 - Create all Genie agents (or Step 100, which calls Step 02). Recreate one specialist with that row’s 02 - Fraud Agent - NN GitHub Action. Nobody types the right-hand Configure tabs in the UI.
Space | Assigned cases | GitHub Action that creates / upserts it |
Retail Analytics Genie | merchandising (metric views) | 01 - Setup - Step 02 - Create all Genie agents |
Fraud Velocity Agent | 01, 07 | 01 - Setup - Step 02 or 02 - Fraud Agent - 01 - Fraud Velocity Agent |
Fraud Address Link Agent | 02, 06, 13 | 01 - Setup - Step 02 or 02 - Fraud Agent - 02 - Fraud Address Link Agent |
Fraud Ship-to Bill-to Agent | 03 | 01 - Setup - Step 02 or 02 - Fraud Agent - 03 - Fraud Ship-to Bill-to Agent |
Fraud Returns Agent | 04, 12 | 01 - Setup - Step 02 or 02 - Fraud Agent - 04 - Fraud Returns Agent |
Fraud First-Order Agent | 05 | 01 - Setup - Step 02 or 02 - Fraud Agent - 05 - Fraud First-Order Agent |
Fraud Address Surge Agent | 08, 09 | 01 - Setup - Step 02 or 02 - Fraud Agent - 06 - Fraud Address Surge Agent |
Fraud Promo Agent | 10 | 01 - Setup - Step 02 or 02 - Fraud Agent - 07 - Fraud Promo Agent |
Fraud Inventory Agent | 11 | 01 - Setup - Step 02 or 02 - Fraud Agent - 08 - Fraud Inventory Agent |
Fraud Cancel Agent | 14 | 01 - Setup - Step 02 or 02 - Fraud Agent - 09 - Fraud Cancel Agent |
Fraud Geo Agent | 15 | 01 - Setup - Step 02 or 02 - Fraud Agent - 10 - Fraud Geo Agent |
Open a space → Configure. Same mapping for every fraud specialist (Retail is the last column only):
Configure tab | Who writes it | Which GitHub Action | Code |
About title + description | This repo | Step 02 or that space’s 02 - Fraud Agent - NN |
|
About → Common questions | This repo | same | Plain English in |
About → Warehouse | This repo | 01 - Setup - Step 01 - Create Databricks stack (name); Step 02 attaches it | warehouse |
About → Agent ID | Databricks | none (assigned at create) |
|
Sources | This repo | Step 02 or 02 - Fraud Agent - NN | Fraud: |
Instructions | This repo | Step 02 or 02 - Fraud Agent - NN ( | Geo: Case 15 notes. Others: default “investigate only these cases”. Retail: |
Examples (join list) | Databricks, from keys we created | 01 - Setup - Step 01 ( | We do not send example SQL on fraud spaces |
The prompt used in this workspace for Fraud Geo is:
Which customers had orders shipped to two different regions within one hour?That is the first sample question on the space and the first checkbox on
02 - Fraud Agent - 10 - Fraud Geo Agent. Type it in the chat (or check
the box on that GitHub Action). Do not start from Retail Analytics for this
question. MCP run_fraud_case still uses ids 01–15; those ids are not sent
to Genie.
Fraud Geo Agent
What it is. A Databricks Genie space titled Fraud Geo Agent. Step 02
(or GitHub Action 02 - Fraud Agent - 10 - Fraud Geo Agent) creates it with create_agents --agent-id geo. In this repo that means case_ids: ("15",) — this space is assigned to investigate Case 15 only (impossible geography: the same customer has two shipping regions within one hour). That is a routing label in fraud_agents.py, not an AI “ownership” concept. It answers questions; it does not run Spark load jobs and it does not call mcp-ecommerce-oltp.
Structure (serialized space version: 2 from serialized_fraud_space):
Title:
Fraud Geo AgentDescription: Impossible geography: two regions on the same customer in a short window
Warehouse:
ecommerce-genie-ontology(author compute)Catalog:
{CATALOG}(Unity Catalogecommerce_genie_ontology)data_sources.tables: theSHARED_TABLESlist — fully qualified{CATALOG}.retail_oltp.*and{CATALOG}.retail_star.*only. Genie does not search other catalogs or schemas. Session/ETL tables (analytics_log,analytics_log_customer,ingestion_tracker,ingestion_log) are omitted so every fraud space skips them.instructions.text_instructions: Case 15 notes (overridable with system_prompt on GitHub Action 02 - Fraud Agent - 10 - Fraud Geo Agent)config.sample_questions: the five starters belowRegistry row:
{CATALOG}.retail_star._genie_agent_registry(title,space_id,warehouse_id)
URLs (copy space_id from the registry or from Step 02 logs):
Surface | URL |
All agents |
|
This agent (chat) |
|
Settings / Monitor | same room → Settings or Monitor |
Genie MCP |
|
Query History |
|
What it does. For the Case 15 prompt it should self-join
retail_star.fact_order_event on customer_key where
shipping_region_key differs and order_ts is at most 60 minutes apart.
Prefer mv_order_event only when you need counts. Seeded customers use
address_id *-AGEO (West vs Northeast) and two orders 25 minutes apart.
What it outputs. Generated read-only SQL, a result table, and a short
English answer. Expected columns: customer_key, both order ids, both
regions, both timestamps, minutes_apart. LIMIT 50. It must not say the
tables are empty after Step 06 + 07 (or Step 100).
What happened on this agent (simple)
You opened Fraud Geo Agent and typed
Which customers had orders shipped to two different regions within one hour?
(or the older wording Run fraud case 15 Impossible geo two regions one hour).
We already taught the space (GitHub Actions, not the chat):
Step 01 created the tables and wrote comments + primary/foreign keys. That is the metadata (names, meanings, how tables join).
Step 02 (or 02 - Fraud Agent - 10 - Fraud Geo Agent) attached those tables, pasted the Case 15 instructions, and the five sample questions.
Step 06 (inside Step 100) wrote the rows: 200 customers and a Case 15 seed — first 20 people, two orders 25 minutes apart (
10:00/10:25), ship regions that cannot both be true (*-AGEO).
Genie read the metadata, not the 200k rows. It looked at instructions (“join
fact_order_event…”), table comments, column names, and the join keys. Then its managed LLM wrote SQL. It did not scan every order in its head.The SQL warehouse ran that SQL and sent back a small table.
You saw 20 rows — customers
1–20, ordersO000000070001–O000000070040,minutes_apart = 25, West vs another region. That is the seed, not a live crime ring. Five region pairs × 4 customers is how we generated the addresses.Genie wrote the English / PDF (
Case 15 Fraud Detection_ .pdf) from those 20 rows. Spark created the seed. Genie created the story. The warehouse created the query run. Nobody typed thatSELECTinto the room.This chat is not Genie MCP. You will not see
genie_askhere. Same SQL appears on warehouse Monitoring / Query History. Export PDF is the answer text, not a tool log.
Earlier, before fact_order_event and the seed, the same prompt returned
no rows. After Step 100 + data, the same prompt returns these 20 pairs.
Prompts on this agent
Kind | Text |
Use this |
|
Starter (schema smoke) |
|
Starter (schema smoke) |
|
Starter (schema smoke) |
|
GHA extra | same question plus |
Context we provide (what Genie sees before the LLM writes SQL):
General instructions (Case 15 notes quoted in
fraud_agents.py)Unity Catalog comments on the attached tables
Table/column descriptions from
SHARED_TABLESSample questions on the space
Published Discover pages only if they actually exist in Discover (see below)
The current chat thread
How it knows which schemas and tables to use
Genie only considers objects listed on the space. It does not browse the whole workspace.
Use | Do not use for Case 15 |
Schema | Other catalogs, |
Schema | |
|
|
|
|
|
|
| Full-table dumps; inventing load steps |
SQL shape for the Case 15 prompt:
WITH pairs AS (
SELECT
a.customer_key,
a.order_id AS order1_id,
a.order_ts AS order1_ts,
a.shipping_region_key AS region1,
b.order_id AS order2_id,
b.order_ts AS order2_ts,
b.shipping_region_key AS region2,
(UNIX_TIMESTAMP(b.order_ts) - UNIX_TIMESTAMP(a.order_ts)) / 60.0 AS minutes_apart
FROM retail_star.fact_order_event a
JOIN retail_star.fact_order_event b
ON a.customer_key = b.customer_key
AND a.shipping_region_key <> b.shipping_region_key
AND b.order_ts > a.order_ts
AND (UNIX_TIMESTAMP(b.order_ts) - UNIX_TIMESTAMP(a.order_ts)) <= 3600
WHERE a.status <> 'cancelled' AND b.status <> 'cancelled'
)
SELECT * FROM pairs
ORDER BY minutes_apart, customer_key
LIMIT 50This Genie Agent Runtime Behavior
SQL does not run inside the LLM. Genie is a Databricks service: the model writes SQL, the space’s SQL warehouse runs it, then Genie hands the rows back so the model can write the English answer.
One turn after you paste the Geo prompt above:
FETCHING_METADATA — pull comments and PK/FK for the attached
retail_oltp/retail_startables.FILTERING_CONTEXT — keep Case 15 instructions, the
fact_order_eventdescription, sample questions, and this thread. Drop STALE sales/inventory unless the question is merchandising.ASKING_AI — Databricks-managed LLM proposes read-only SQL. No warehouse yet. There is no model picker on
/genie; Databricks chooses the compound stack. Query History and App logs do not name Claude vs GPT.PENDING_WAREHOUSE — wait for
ecommerce-genie-ontology.EXECUTING_QUERY — warehouse runs the generated SQL as you (Unity Catalog). Compute is the author’s warehouse. Retries stay in Genie.
mcp-ecommerce-oltpis not invoked.COMPLETED — chat shows SQL + rows + short answer. Failed turns show
FAILEDand an error type (SQL_EXECUTION_EXCEPTION,NO_TABLES_TO_QUERY_EXCEPTION, …).
Do Pages come into the picture?
Sometimes — only after a page is Published in Discover. They never run SQL and they never call MCP.
What this repo actually does:
Step 04 does create and publish Discover domains (Sales, Customer, Supply Chain, Finance) via
POST/PATCH /api/discover/v1/domains.Page bodies (Impossible Geo, Order Event Fact, plus merchandising pages) are written to
{CATALOG}.retail_star._ontology_pages.There is still no public Pages create/publish API. Step 04 retries Discover page endpoints; those calls SKIP until Databricks accepts the payload. Until you Publish a page in
https://{WORKSPACE_HOST}/search/discover, Case 15 does not get page synonyms or citations.
When a page is Published, Genie can use it as extra ontology: synonyms
(impossible geo, two regions one hour, case 15), citations in the
answer, and a pointer at fact_order_event. The warehouse path stays the
same. If Case 15 works with empty Discover Pages, that is expected —
instructions + SHARED_TABLES + UC comments are enough.
Genie MCP tools this agent uses — and where to trace them
Two different clients hit the same Genie space. They do not share one tool-call log.
A. You type in /genie/rooms/{SPACE_ID}
The UI uses the Genie Conversation API, not MCP. You will not see
genie_ask / genie_poll_response / genie_get_query_result in a tool
panel. Databricks still runs the same warehouse SQL.
B. An MCP client talks to Genie MCP
https://{WORKSPACE_HOST}/api/2.0/mcp/genie/{SPACE_ID}
That server exposes only these tools (Databricks-hosted; not our App):
Tool | When it fires | What you get |
| First question (and follow-ups with |
|
| Client waits through | Progress, final text, source links |
| After a query attachment exists | Schema + rows of the warehouse SQL |
| Client aborts the turn | Cancelled |
| MCP Apps / View clients | Same ask, interactive View |
Step 05 and invoke_agents --agent-id geo use the workspace SDK
(start_conversation_and_wait) — path A, not these MCP tool names.
Cursor / Claude Desktop / Supervisor pointed at Genie MCP is path B.
mcp-ecommerce-oltp is never in either list.
Where to trace them
What | Where to open |
Path A — chat SQL + thoughts |
|
Path A — all questions | Same room → Monitor (CAN MANAGE) |
Path A or B — message JSON, statuses, |
|
Path A or B — warehouse SQL, duration, user |
|
Path A or B — who asked | Audit logs: Genie Agent events (ids and time, not SQL) |
Path B — which MCP tool ran | The MCP client transcript (Cursor / Claude / Supervisor tool calls). Databricks does not write |
Path B — Genie MCP HTTP | Client debug / proxy logs against |
Step 05 / Fraud Geo GitHub Action ask job | GitHub Actions log: |
Space id for all of the above |
|
Our App tools ( | Not this agent. App logs at |
Pages / citations | Discover |
MCP tools
There are two MCP surfaces. Databricks Genie is the managed analytics path inside the workspace. This repo also runs its own MCP server for load, ETL, and fraud evidence. Do not put generate or CDC tools on Genie.
MCP tools in Databricks Genie
Databricks hosts these servers. create_agents publishes one Retail Analytics
Genie space plus ten fraud specialist spaces on the same OLTP and star tables.
An MCP client authenticates to the workspace and calls Genie; Genie writes the
SQL.
Server | URL | When to use |
Genie One |
| Natural-language questions across the workspace |
Genie Agent |
| Questions scoped to one Genie space (retail analytics or one fraud specialist) |
Databricks SQL |
| The MCP client already has a SQL string (you typed it, Cursor/Claude wrote it, or an agent composed it). Databricks only executes it. Genie is not in this path. Not for fraud generate / CDC. |
Genie One / Genie Agent tools (the client calls genie_ask; the rest are for
the in-flight turn):
Tool | What it does |
| Ask a natural-language data question. Returns |
| Read progress, the final answer, and links back to Databricks sources. |
| Fetch the SQL result Genie ran (schema and rows). |
| Cancel an in-flight Genie turn. |
| Same ask, opens the interactive View (MCP Apps clients). |
Genie spaces created here: Retail Analytics Genie (certified metric views)
and the ten fraud specialists (velocity, address_link, ship_bill,
returns, first_order, address_surge, promo, inventory, cancel,
geo). Those specialists answer questions; they do not run Spark jobs.
MCP tools in this codebase
The custom MCP is ecommerce-oltp-mcp in
src/ecommerce_genie_ontology/mcp/. GitHub Action Step 03 publishes it as
Databricks App mcp-ecommerce-oltp (name prefix mcp- so Playground /
Supervisor list it). The App URL uses Pyctuator
(GET / → /actuator/health, plus /actuator/info and /actuator/metrics);
tools stay on {APP_URL}/mcp. LangGraph, Google ADK, Cursor, and Claude Desktop can
also call it over stdio. Portal chat reaches the same functions through
FastAPI facades. Classic Genie spaces do not attach this App; they stay on
Genie MCP. Every evidence tool returns at most 50 rows.
uv sync --extra mcp
uv run --extra mcp genie-ontology mcp
uv run --extra mcp genie-ontology mcp --httpCursor / Claude Desktop:
{
"mcpServers": {
"ecommerce-oltp": {
"command": "uv",
"args": ["run", "--extra", "mcp", "genie-ontology", "mcp"],
"cwd": "/path/to/Databricks-Genie-Ontology"
}
}
}Evidence and specialists
Tool | What it does |
| The 15 named fraud cases (evidence packs, not full tables). |
| The 10 specialists and which case ids each is assigned ( |
| Run one case ( |
| Run every pack owned by one specialist. |
| Date range in; server finds IDs; writes |
| Session header and pending customer count. |
| Page of customers (max 50) with counts and outcome. |
| One customer: counts + at most 50 evidence rows. |
| At most 25 orders and 25 postings for one customer. |
| At most 25 sales facts and 25 posting facts for one customer. |
|
|
| Status |
| One |
Load and ETL (operators; not on Genie)
Tool | What it does |
| Write customer, address, order, line, shipment, and |
| Append 100–10,000 new orders. Window: |
| Overwrite star dims and facts from OLTP. |
| Apply Delta change feed from |
| Next 100,000 OLTP rows. Writes |
| Next N months of dims/facts (1–12). No error if less OLTP remains. |
Customer-first contract is on this server, not Genie: open a session, page customers, hydrate one customer, write the outcome, then close.
Fraud agents (inside ecommerce_genie_ontology)
FastAPI never imports LangGraph or Google ADK. It calls a facade; the facade invokes that stack.
src/ecommerce_genie_ontology/
agents_langgraph/ # LgFacade → LangGraph StateGraph → MCP tools
facade.py graph.py
agents_google_adk/ # GaFacade → ADK root + 10 sub-agents → MCP tools
facade.py agent.py runtime.pyuv sync --extra agents
# or: uv sync --extra langgraph --extra google-adk --extra mcpPOST /api/v1/ontology/chat with "backend": "langgraph" or "google_adk" or "genie". The 10 Databricks Genie specialists are created by create_agents on the same OLTP + dims/facts.
Run all 15 fraud packs without an LLM:
uv run genie-ontology fraud-agent
uv run genie-ontology fraud-agent --cases 01,02,06
uv run genie-ontology run fraud --case-id 02Context management and graph databases
The agent never sees 15 million orders. Spark/SQL stay in Databricks. Each fraud case is a named query plus a small evidence pack. retail_oltp.entity_link stores 1–2 hop relationships (has_address, shared_address) so you do not need Neo4j for these 15 cases. Add a graph store later only if you need unbounded multi-hop traversal or a live investigation UI.
OLTP and CDC without GitHub Actions
Same jobs as 01 - Setup Steps 07–10. Use this only if you are not running those Actions.
uv run genie-ontology deploy
uv run genie-ontology run generate_historical --as-job --customers 200 --orders-per-year 25000 --years 3
uv run genie-ontology run etl_historical --as-job
uv run genie-ontology run generate_realtime --as-job --count 1000 --year-window latest
uv run genie-ontology run etl_cdc --as-jobRegister and run Databricks Jobs without GitHub Actions
Same as 01 - Setup Steps 01–03. Use this only if you are not running those Actions.
uv run genie-ontology deploy
uv run genie-ontology run provision --as-job
uv run genie-ontology run create_agents --as-job
uv run genie-ontology run invoke_agents --as-jobdeploy uploads this package plus thin wrapper notebooks to
DATABRICKS_WORKSPACE_PATH and creates or updates the jobs (Genie provision plus OLTP/CDC Spark jobs).
Discover domains use the public Domain API
(POST /api/discover/v1/domains, then PATCH draft=false to publish).
Step 04 and provision t04 create Sales, Customer, Supply Chain, and Finance
from the existing governed tags. Pages still have no documented public create
API. Provision stores the same content in <catalog>.<schema>._ontology_pages
and Step 04 retries Discover page endpoints after the parent domain exists.
Page bodies include Impossible Geo and Order Event Fact. fact_sales and
fact_inventory are documented as STALE merchandising snapshots.
Available Tools
9 toolsetl_star_cdcB
Apply Delta change feed from OLTP customer_order into fact_sales (append).
Inputs: as_job.
etl_star_historicalC
Rebuild star-schema dims and fact_sales from OLTP (overwrite).
Inputs: as_job.
generate_historical_oltpC
Write customer, address, order, line, shipment, and entity_link tables.
Inputs: as_job, year_count, customer_count, orders_per_year.
generate_realtime_ordersC
Append 100-10000 new OLTP orders. year_window is latest | last_2 | last_3 | all.
Inputs: count, as_job, year_window.
list_fraud_agentsA
List the 10 Databricks Genie fraud specialists that share OLTP + dims/facts.
Inputs: no named parameters. Returns: result
list_fraud_casesA
List the 15 fraud detection cases. Each case is a named SQL evidence pack.
Inputs: no named parameters. Returns: result
query_datasetA
Run a SELECT against dims, facts, or OLTP. LIMIT 50. Never dumps full tables.
Inputs: sql (required).
run_fraud_agent_casesC
Run every evidence pack owned by one of the 10 fraud specialists.
Inputs: agent_id (required).
run_fraud_caseB
Run one fraud case (ids 01-15). Returns at most 50 evidence rows.
Inputs: case_id (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Most tools have clearly distinct roles: generation, ETL, fraud case listing/execution, and querying. The main ambiguity is between run_fraud_case and run_fraud_agent_cases, but their descriptions clarify single-case versus agent-owned case batches.
All tool names follow a consistent snake_case verb_noun pattern, with recognizable prefixes like run_, list_, generate_, etl_star_, and query_. This makes the tool surface predictable and easy to navigate.
Nine tools is a well-scoped size for this server's purpose. Each tool covers a distinct phase of the workflow—data generation, ETL, fraud case evaluation, and querying—without unnecessary redundancy.
The core lifecycle of generating OLTP data, building star-schema artifacts, running fraud cases, and querying results is well covered. Minor gaps include the lack of explicit schema/reset management or direct row-level CRUD, but agents can work around these using query_dataset and generation tools.
Related MCP Connectors
Your Databricks Lakehouse in natural language: run SQL on your SQL warehouses, track long-running qu
Check your cron jobs, recent runs, workflows and webhooks, and run a job now when you confirm.
Interactive Databricks learning, certification practice and sourced engineering guidance.
List reverse-ETL sources, destinations, models, syncs and runs; trigger syncs into SaaS tools.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to explore and query a mock e-commerce store's data including customers, products, inventory, and orders through conversational interactions backed by PostgreSQL.-
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to investigate and safely resolve commerce order exceptions, such as expired inventory reservations, by providing a workflow across synthetic order, payment, inventory, and fulfillment systems.-
- FlicenseNot gradedqualityDmaintenanceProvides deterministic mock customer health, product usage, and recommended playbook data via three MCP tools for a Customer Success Orchestrator demo.-
- AlicenseAqualityDmaintenanceGenerates and deploys Cloudera Data Engineering (CDE) Airflow jobs from ODCS data contracts, validating live table data in CDW against schema and data-quality rules without WAP staging.13Apache 2.0