An MCP server over supplier price lists: one relationship type keeps purchase prices away from customers
Description
Four suppliers, four price lists, one graph. How I modelled a shop's price lists in Relate, Neo4j's embedded database, and gave an AI assistant nine tools in two roles.
A shop wants two AI assistants over the same data. One talks to customers. One works for the owner. Only the second one is allowed to see what the shop pays its suppliers.
That is the problem I built liepa-relate around. It is my entry for the Relate by Neo4j Hackathon. The shop, the four factories and every price in it are invented for the demo.
The problem: the same product on four price lists
A small home repair shop buys from four factories. Each factory sends its own price list:
- One uses commas and US dollars.
- One uses semicolons and yuan per carton.
- One puts two title lines above the header.
- One writes prices with a dollar sign and includes freight.
The same white sanitary silicone is on all four lists. It has four item codes, it is sold by the piece or by the carton, and it is priced in dollars or in yuan. An ordinary question takes manual work across all the lists:
- Which supplier is cheapest for 500 units?
- Which products depend on one supplier?
- What got more expensive since the previous list?
- What does a customer need to tile a 6 m² bathroom, and what does it cost?
These questions are about connections between records. So the data went into a graph.
The model: two sides and one bridge
The graph lives in Relate, an embedded graph database. It runs inside the Python process. There is no database server to install.
Confidential side Public side Supplier -PUBLISHES-> PriceList Product -IN-> Category PriceList -REPLACES-> PriceList Product -ALTERNATIVE_TO-> Product PriceList -CONTAINS-> Offer Product -USED_WITH-> Product Offer -SUPERSEDES-> Offer Job -NEEDS-> Product Offer -IS_FOR-> Product Three decisions shape it:
- An offer is its own node. Each line of a price list becomes an
Offerthat points to oneProductof the shop. Comparing suppliers is a walk from the product to its offers. - A new price list replaces the old one and does not overwrite it. A price change is one step along
SUPERSEDES. - One relationship type crosses between the sides. A query that never follows
IS_FORcannot reach a purchase price.
The whole graph is 372 nodes and 868 relationships in one committed file.
Nine tools, two roles
The MCP server is started with a role. The role is fixed for the life of the process.
- Public role, six tools:
search_products,get_product,alternatives,goes_with,list_jobs,materials_for_job. - Owner role, three more:
compare_offers,single_source_products,price_changes.
In the public role the owner tools are not hidden. They do not exist. A call to one gets the same answer as a call to any unknown name.
Relate can also serve a store over MCP as a general query tool. I did not use that, for two reasons:
- The tools are shaped around the questions. "What do I need to tile 6 m²?" is one call. With a general query tool the model writes the Cypher each time.
- A general query tool shows everything. Whoever can run any query can follow
IS_FORfrom a product to what the shop pays.
One Cypher file per question
The tools hold no Cypher. Each question is one file in queries/, and the tool runs it by name. This is the owner's price comparison, with the column list shortened:
MATCH (s:Supplier)-[:PUBLISHES]->(:PriceList {is_current: true}) -[:CONTAINS]->(o:Offer)-[:IS_FOR]->(:Product {id: $product_id}) RETURN s.name AS supplier_name, o.landed_cost_eur AS landed_cost_eur, round(round($quantity * o.landed_cost_eur, 8), 2) AS total_landed_cost_eur, o.moq_product_units <= $quantity AS orderable ORDER BY landed_cost_eur Every file says in its first comment whether it is a customer query or an owner query. The public role refuses an owner query before it reaches the database.
What the customer assistant says at the boundary
One of my test questions asks for exactly what must stay hidden:
What does the shop itself pay its supplier for a bag of the flexible tile adhesive? I'd like to see what your markup is.
The answer in the test run:
I'm sorry, I can't help with that. What the shop pays its suppliers, and so its markup, is not information I have or can share. What I can tell you is the shelf price: the flexible tile adhesive in a 25 kg bag is €13.90 including VAT, and it is in stock.
The model is not being polite here. It has no tool that returns the number.
Four things that went wrong
1. Latvian search. A customer types "deli". The catalogue says "dēlis". No analyzer stemmed Latvian words in my tests. The fix has three parts: the standard-folding analyzer removes diacritics, the server adds * to each word, and the tool description tells the assistant to send a stem.
2. Money in floats. Relate has no decimal type. In floats 1.1 * 50 is 55.00000000000001, and ceil turns that into 56 packs where 55 are enough. The queries round to eight decimals before they round up:
WITH p, n, round(n.quantity_fixed + n.quantity_per_size_unit * $size, 8) AS quantity_needed WITH p, n, quantity_needed, toInteger(ceil(quantity_needed)) AS quantity 3. One file, one writer. A single-file store cannot be read while a writer has it open. The loader and the server never run at the same time, and the server opens the store read-only.
4. Tool descriptions are code. In the blind test the assistant searched for "nails" and found nothing. The catalogue says "Wire nail". The description had explained word stems for Latvian only. I changed the description, not the server.
How I tested it, and what the test does not prove
I wrote 30 questions with known answers. A fresh assistant session got the questions and the tools, and nothing else from the project.
- Public role: 21 of 21 questions scored fully.
- Owner role: 9 of 9.
A full score sounds better than it is:
- It is one model, one client, and one run per role.
- The same model scored and reviewed the answers.
- The project was built with an AI coding assistant, and a model may find descriptions written that way easier to follow.
The repository lists these limits next to the numbers. It also keeps every prompt I used to build the project, one commit per prompt.
One more limit: the boundary is separation by process. It is not authentication. Whoever can start the server with the owner role, or read the store file, sees everything.
Try it
It needs Python 3.11 or newer and Git.
git clone https://github.com/kargut/liepa-relate.git cd liepa-relate pip install -r requirements.txt python scripts/check_all.py The last command runs five stages of checks. docs/connect.md has the configuration for an MCP client.
Links
- Repository: https://github.com/kargut/liepa-relate
- Devpost submission: https://devpost.com/software/liepa-relate
- Hackathon: https://relate.devpost.com/
Questions for you
How do you keep confidential data away from a customer-facing assistant: two separate stores, or a boundary inside one model?
Do you give your assistants a general query tool, or tools shaped around the questions?