LHO MCP Server
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., "@LHO MCP Server What is the positivity rate of bacterial pathogens in beef cattle?"
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.
LHO knowledge-graph assistant
Ask a question about livestock health data in plain language. The answer comes from a knowledge graph, not from the memory of a language model.
All data in this repository are synthetic. Every record is invented by a script (
src/lho_demo/generate_data.py, fixed seed). Only the structure follows the ontology. No real laboratory data were used.
In short
What it is: an MCP server with five read-only tools on an RDF knowledge graph, an agent that lets an open-source language model use those tools, and a chat page.
The graph: the Livestock Health Ontology (LHO V1.5) plus 14,800 synthetic diagnostic test records from eight laboratories (six cattle, two pig).
Why the ontology matters: the user can say "bacteria", "kweek" or "Bovine orthopneumovirus". None of these words is a value in the data; the ontology tells the tools what they mean.
How wrong answers are limited: the model never writes a query, every number in an answer must come from a tool result, and each answer shows the query behind it.
Result: 39 of 40 test questions correct with
qwen2.5:7b, running locally on a laptop without a GPU.Start it:
docker compose up, then open http://localhost:8000.
Related MCP server: ontology
How it works
Example
Question: What is the positivity rate of bacterial pathogens in beef cattle?
tool: test_statistics(pathogen="bacterial", breed="beef")
-> {"filters": {"pathogen": "Pathogenic Bacterium", "breed": "Beef"},
"tested": 2291, "positive": 635, "positivity_percent": 27.7}
Answer: 27.7% of the tests for bacterial pathogens in beef cattle were positive (635 of 2,291).The server resolved "bacterial" to the ontology class Pathogenic Bacterium and counted every pathogen that belongs to it.
Run it
With Docker
Requirement: Docker with about 8 GB of memory available to it.
git clone https://github.com/sabanoor8867/lho-mcp-demo.git
cd lho-mcp-demo
docker compose upThen open http://localhost:8000. Three containers start: Ollama, a one-off job that downloads the language model (4.7 GB, first time only), and the application. Stop with Ctrl+C.
Tool tests inside the container:
docker compose run --rm app pytest -qA smaller model:
LHO_MODEL=llama3.2:3b docker compose up
Without Docker
Requirements: Python 3.11 or newer, Ollama, and about 8 GB of free memory for the default model. Works on Windows, macOS and Linux; all paths are relative to the repository.
git clone https://github.com/sabanoor8867/lho-mcp-demo.git
cd lho-mcp-demo
python -m venv .venvActivate the environment:
System | Command |
Windows, PowerShell |
|
Windows, Git Bash |
|
macOS and Linux |
|
Install and run:
pip install -e ".[dev]"
ollama pull qwen2.5:7b # the default model, 4.7 GB
pytest -q # 34 tests of the tools, no model needed
lho-ask "How many BRSV tests were positive in 2024?"
lho-chat # chat page on http://127.0.0.1:8000The first answer takes longer, because the model is loaded into memory.
Other commands: lho-generate-data rebuilds the synthetic data (same result every time). lho-server starts the MCP server alone, for use from another MCP client (lho-server --http for HTTP).
Setting | Default | Meaning |
|
| Any Ollama model that supports tool calling |
| off |
|
|
| Port of the chat page |
What is in the repository
Part | Location | What it does |
Synthetic data |
| One RDF file per laboratory, and the same records as |
Data generator |
| Writes the 14,800 invented records (12,000 cattle, 2,800 pig) |
Ontology |
| LHO V1.5 |
Knowledge graph |
| Loads ontology and data, resolves words to ontology terms, builds and runs SPARQL |
MCP server |
| Offers the tools to any MCP client |
Agent |
| Lets the model call tools until it can answer; checks the numbers in the answer |
Chat page |
| One web page; shows the tool calls and the SPARQL behind each answer |
Tests |
| 34 tests of the tools |
Evaluation |
| 40 questions with known answers, the scorer, and the result files |
The tools
Tool | Use |
| What the graph contains and the valid values of each dimension |
| Tested, positive, negative and positivity, with filters and grouping |
| The values of one dimension with their counts |
| Find an ontology term by name or synonym, in any language |
| Definition, parent classes, synonyms and relations of a term |
| Read-only SPARQL for experts; off unless |
Design decisions
The model never writes SPARQL or IRIs. It passes plain words to typed tools. The server resolves them through ontology labels and synonyms and fills fixed query templates. Small open-source models call a tool with a few parameters reliably and write SPARQL unreliably. A model also cannot run a harmful query this way.
Calculations happen in the tools. A grouped result already names the highest and lowest group, so the model does not compare a table of numbers itself.
Errors teach. An unknown value returns the list of valid values, so the model can correct itself. A parameter that a tool does not have is an error, never ignored.
Answers are checked. Every number in an answer must appear in a tool result. If not, the model gets one chance to correct it; otherwise the answer is withheld and the user is told that it could not be verified.
Every answer is traceable. The SPARQL of each tool call is kept and shown to the user.
The model is replaceable. The agent reads the tool list from the MCP server, and the model is one setting (
LHO_MODEL).Open source, local by default. Ollama, Oxigraph and the MCP Python SDK. No data leave the machine.
Evaluation
eval/questions.json holds 40 questions in nine groups: counts, positivity rates, comparisons, time, pigs, ontology reasoning (a class such as "bacteria"), ontology knowledge, synonyms and Dutch, and questions the graph cannot answer.
The expected answers are computed with pandas from data/synthetic/records.csv. They do not pass through SPARQL, the MCP server or the model, so the test checks the whole chain independently.
An answer is correct when:
it contains the expected number (counts exactly, percentages within 0.05) or the expected name, and the agent called a tool;
for a ranking ("which ... highest"), the agent really compared the groups; a guess that happens to be right is scored as wrong;
for a question without data, it says that the graph has no data and gives no invented number.
python eval/make_questions.py # rebuild questions and expected answers
python eval/run_eval.py # default model
python eval/run_eval.py --model llama3.2:3b # another modelResult
Measured on a laptop without a GPU (Intel i5-1235U, 16 GB RAM), November 2026, with qwen2.5:7b in Ollama. Result file: eval/results/ollama_qwen2.5_7b_run6.json.
Group | Correct |
Counts | 7 of 7 |
Positivity rates | 4 of 5 |
Comparisons | 7 of 7 |
Time | 2 of 2 |
Pigs | 4 of 4 |
Ontology reasoning | 4 of 4 |
Ontology knowledge | 5 of 5 |
Synonyms and Dutch | 3 of 3 |
No data | 3 of 3 |
Total | 39 of 40 (97.5%) |
Median time per question: 28 seconds. Every answer was based on a tool call.
The one wrong answer: for "What is the positivity rate for bovine coronavirus in dairy cattle tested with PCR?" the model left out the breed, added a sample type the question did not mention, and grouped the result by laboratory. It then reported the figure of one laboratory (43.5%) instead of the expected 26.7%. The number came from a tool result, so the number check did not catch it.
Development history
All runs use qwen2.5:7b. Runs 1 to 4 used an earlier set of 40 questions on cattle data only; pig data and four pig questions were added before run 5.
Run | Correct | What changed before this run |
1 | 37 of 40 | First complete version |
3 | 35 of 40 | Number check added; new instructions made the model group results when it should not |
4 | 39 of 40 | The tools were made tolerant of the model's mistakes (see the table below) |
5 | 36 of 40 | Pig data added; the model then limited general questions to cattle |
6 | 39 of 40 | The tool description says to leave the species filter empty unless the question names an animal |
Run 2 was interrupted and is not listed. The drops in runs 3 and 5 show why the whole set is rerun after every change.
A smaller model, llama3.2:3b, scored 26 of 40 on the earlier question set and an earlier version of the tools (ollama_llama3.2_3b_run1.json). It often answered without giving the number from the tool and failed both Dutch questions. It was not rerun on the final version.
What the test found, and what changed
Problem found by the test | Change |
The model invented a parameter ( | A real |
After a tool error, the model invented an answer ("BRSV, 45%") | Number check: numbers must come from a tool result |
"Which laboratory tested the most?" was answered by guessing one laboratory, and was right by luck | The scorer requires a real comparison; the tool description says to use |
The model searched for a whole sentence and found no term | Term search also matches single words inside a phrase |
Asked for one rate, the model grouped by laboratory and reported per-laboratory figures or its own average | A grouped result also contains the overall figures |
The model sent a placeholder as a value ( | Both are repaired by the tool, with a note in the result |
A list of all breeds was scored as correct because the right name appeared in it | The scorer requires the winner to be named first |
Limits
The data are synthetic and small (14,800 records). The numbers mean nothing about real disease occurrence.
Two species are covered. Cattle (laboratories 1 to 6): seven respiratory pathogens. Pigs (laboratories 7 and 8, Spain, PCR only): PRRS, swine influenza virus, Mycoplasma hyopneumoniae and Lawsonia intracellularis, with production stages. LHO also describes poultry and salmon, for which this demo has no data.
A 7-billion-parameter model on a laptop CPU needs 30 to 70 seconds per question.
The number check ignores numbers of 12 or lower (months, laboratory numbers), so a small invented count would not be caught. It also cannot tell whether a correct number answers the question that was asked (see the wrong answer above).
The ontology file in
ontology/differs from the published LHO V1.5 in two lines: the label of the Histophilus somni class is corrected (it read "HistophilusSomnus"), and the individualHShas the exact synonym "Histophilus somni".LHO V1.5 lists laboratory references 1 to 6. The two pig laboratories (7 and 8) are declared in the data files.
Three everyday words ("bacteria", "virus", "Netherlands") have no label in LHO V1.5 and are mapped in
config.py. They are candidates for alternative labels in the ontology.
Background
The Livestock Health Ontology was developed by Saba Noor and Miel Hostens in the EU Horizon 2020 project DECIDE, to give animal health data from different laboratories, countries and species a shared structure and meaning. This demo shows one use of that shared meaning: a language model can query data it has never seen, because the ontology tells the tools what the words mean.
Author
Saba Noor, Ghent University.
License
Code: MIT (see LICENSE). Ontology: see the LHO page on BioPortal for its license.
Available Tools
5 toolsdescribe_termA
Definition of one ontology term: what it is, its parent classes, synonyms, names in other languages and its relations (which disease a pathogen causes, which species it affects, the neighbours of a country). Pass ONE term, not a sentence. Use it for "What is BRSV?", "Is PI3 a virus?", "Which countries border Belgium?" (term: Belgium).
Inputs: term (required).
graph_overviewB
What the graph contains: number of records, date range, and the valid values of every dimension (species, pathogen, country, lab, breed, sample_type, diagnostic_test, production_stage).
Inputs: no named parameters.
list_valuesA
List the valid values of one dimension with the number of tests for each. dimension: species, pathogen, country, lab, breed, sample_type, diagnostic_test or production_stage.
Inputs: dimension (required).
search_termsA
Find ontology terms by name, abbreviation or synonym, in any language. Use it when you are not sure which term the user means.
Inputs: text (required).
test_statisticsA
Count test records: tested, positive, negative and positivity_percent.
Use this for every question about numbers, percentages, comparisons or trends. Leave a filter empty when the question does not mention it.
group_by: leave EMPTY for one number or one rate ("how many", "what is the positivity"). Set it ONLY to compare groups ("which ... highest, lowest, most"): one of species, pathogen, country, lab, breed, sample_type, diagnostic_test, production_stage, year, year_month, month_of_year. The result then has "overall" (the whole selection), one row per group, and highest_positivity, lowest_positivity, most_tested, most_positive. "Which pathogen has the highest positivity?" -> group_by="pathogen". "Which laboratory tested the most samples?" -> group_by="lab". "Which breed ... for Mycoplasma bovis?" -> group_by="breed", pathogen="Mycoplasma bovis" (do not also fill the breed filter). pathogen: cattle: BRSV, BCV, PI3, "Pasteurella multocida", "Mannheimia haemolytica", "Histophilus somni", "Mycoplasma bovis". Pigs: PRRS, "Swine influenza virus", "Mycoplasma hyopneumoniae", "Lawsonia intracellularis". Or a group: "bacteria", "virus". country: Belgium, France, Ireland, The Netherlands (cattle), Spain (pigs). lab: 1 to 6 (cattle), 7 and 8 (pigs). breed: Beef, Dairy, Suckler, Veal, Mixed, Unknown (cattle), Meat (pigs). sample_type: Autopsy, BAL, Swab, TTA, Tissue, Feces, Fluid, Unknown, Missing. diagnostic_test: PCR, Culture, NPS. production_stage (pigs only): Suckling, Nursery, Weaning, Finishing, Breeding. year: four digits, for example 2024. month: "2022-01" for one month of one year, or 1 to 12 for that month in every year. date_from, date_to: 2024, 2024-03 or 2024-03-15 (both ends included). species: leave EMPTY unless the question itself names an animal. Empty means both species, which is what "overall", "in total" and "all tests" ask for. Fill "Pig" only for a question about pigs, "Cattle" only for a question about cattle. Several values for one filter may be given with commas: country="Belgium, France". Synonyms and other languages work (for example "kweek" for Culture).
Inputs: lab, year, breed, month, +9 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a fairly distinct role: graph_overview for corpus metadata, test_statistics for numeric answers, list_values for enumerating a dimension, search_terms vs describe_term for ontology lookup vs detail. The main overlap is between graph_overview (which lists valid values of every dimension) and list_values (which lists values of one dimension with counts), so an agent may hesitate between them. Other boundaries are clear.
All names are lowercase snake_case with two words, which is readable and predictable. However, the convention is mixed: list_values/search_terms/describe_term use verb_noun while graph_overview/test_statistics use noun-first forms. Minor deviation, not confusing.
Five tools for a focused domain (aggregate statistics plus ontology lookup over a diagnostic-test graph) is well scoped. Each tool covers a distinct capability: metadata, querying, value discovery, ontology search, ontology description. Nothing feels redundant or missing at the count level.
The surface covers aggregate querying, dimension discovery, and ontology term lookup, but there is no way to combine two dimensions in one query (e.g., pathogen by country), no trend/time-series tool beyond group_by year, and no record-level or free-form query escape hatch. Agents hitting a cross-tab or raw-record question will hit a dead end.
Maintenance
Related MCP Connectors
Knowledge graph ingestion, entity search, ontology analysis, and CoSync scoring.
Knowledge graph ingestion, entity search, ontology analysis, and CoPass scoring.
Read, query and check data against ODI standards hub ontologies (OWL, LinkML), and report gaps.
Read-only U.S. lab-test catalog, collection-site search, and reference-range context.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceExecutes SPARQL queries against biological and biomedical RDF databases from the RDF Portal, with additional REST API integrations for bioinformatics resources.1MIT
- AlicenseAqualityDmaintenanceEnables AI agents to inspect ontology schemas, search typed objects, and execute read-only SPARQL queries against an RDF triple store.3MIT
- AlicenseNot gradedqualityCmaintenanceEnables read-only analysis of architecture knowledge graphs converted to RDF, including ArchiMate, BPMN, C4/Structurizr, Backstage, and LeanIX models, through profile-gated SPARQL querying, pattern planning, validation, and reproducible evidence bundles.Apache 2.0
- AlicenseNot gradedqualityBmaintenanceEnables agents to resolve named entities, retrieve curated Wikidata triples, discover cross-links and inbound relations, and run guarded SPARQL queries against a local Truthy knowledge graph for executive brief enrichment.12 npm1MIT