Teaching an AI to Speak Oceanography: Building an MCP Server for the NERC Vocabulary Server
By Vidya ยท 26 October 2026
The problem: confident, plausible, wrong
Ask a general-purpose AI assistant for the vocabulary code of a 'Sea-Bird SBE 911plus CTD' and you will usually get an answer. It will look right. It will often be invented.
In ocean data, that matters. Controlled vocabularies are how datasets from different ships, countries and decades stay comparable. A parameter code says exactly what was measured and how; a device code says exactly which instrument did it. One hallucinated identifier in a metadata record quietly breaks discovery, aggregation and every downstream user who trusts it.
So here is a small bridge: an MCP server that lets an AI assistant query the NERC Vocabulary Server directly, in plain English, and answer with real identifiers straight from the source.
What the NVS is
The NERC Vocabulary Server (NVS) is the authoritative home for many of the controlled vocabularies used in marine science. It is run by the British Oceanographic Data Centre (BODC) at the National Oceanography Centre, and it serves SeaDataNet, SeaVoX, CF and many more.
Under the hood it uses the W3C SKOS model, which has three ideas worth knowing:
- Collections are whole vocabularies, such as L22 (the SeaVoX Device Catalogue), P01 (parameters) or P06 (units).
- Concepts are single terms inside a collection, such as TOOL0058 in L22.
-
Relations link concepts:
broaderandnarrowerfor hierarchy,relatedfor associations, andexactMatchorcloseMatchfor mappings across vocabularies.
That graph of relations is the real value. It is also exactly what an AI cannot guess.
Why MCP fits this problem
The Model Context Protocol (MCP) is an open standard for connecting AI assistants to external tools and data. You write a server that exposes a few well-described tools; any MCP-capable client (Claude Desktop, IDE agents and others) can discover and call them.
That changes the job of the model. It no longer has to remember vocabulary codes. It has to look them up, which is something it does well when given the right tool.
Three properties made MCP the right choice over a bespoke chatbot:
- Reusable. One server works across every MCP client, with no front end to maintain.
- Grounded. Every identifier in an answer comes from a live query, so it can be traced back to the NVS.
- Composable. The vocabulary tools sit alongside whatever else the assistant can do, such as reading a NetCDF header and suggesting the right P01 codes for each variable.
The design: seven tools, one endpoint
The server is written in Python with FastMCP and httpx. It talks to the NVS SPARQL endpoint for search and graph traversal. No API key is needed.
![nvs-mcp-diagram]
The assistant never guesses a code: it calls a tool, the server queries the NVS, and the answer comes back with identifiers the reader can click through to verify.
The tools are designed around the questions people actually ask, not around the endpoint:
| Tool | Question it answers |
|---|---|
search_concepts |
"What is the code for X?" Searches labels and definitions, optionally inside one collection. |
list_collections |
"Which vocabulary should I even be looking in?" |
get_collection_info |
"What is L22, who maintains it and how big is it?" |
get_collection_concepts |
"Show me what is in P06." Paginated, because P01 alone is huge. |
get_concept_info |
"Tell me everything about this term." Labels, definition, status and mappings. |
get_concept_mappings |
"What is this connected to?" Broader, narrower, related and cross-vocabulary matches. |
sparql_query |
The escape hatch for anything the other six do not cover. |
A few deliberate choices:
- Scope by collection. Searching inside L22 or P01 is faster and far more precise than searching everything, and the tool description tells the model so.
- Hide deprecated terms by default. The model should recommend current codes unless asked otherwise.
- Return structured JSON built from Pydantic models, so the model gets consistent fields every time.
- Cap result sizes. Even the raw SPARQL tool trims to 200 rows, to protect the model's context window.
-
Accept friendly references. A concept can be a full URI or shorthand such as
L22:TOOL0058.
See it in action
Here is a real exchange, run against the live NVS while writing this post.
Prompt: "Find the NVS device code for a Sea-Bird SBE 911plus CTD."
The assistant chose search_concepts with query="SBE 911" and collection="L22". The server returned two current concepts:
| Code | Label | Note from the definition |
|---|---|---|
| L22:TOOL0058 | Sea-Bird SBE 911plus CTD | The off-the-shelf production version |
| L22:TOOL0035 | Sea-Bird SBE 911 CTD | The earlier custom-built unit, replaced by the 911plus in 1997 |
That second row is the point. Without grounding, a model has no reason to know the 911 and the 911plus are separate catalogue entries. With grounding, it can explain the difference and pick the right one.
Follow-up: "What is TOOL0058 connected to?"
get_concept_mappings returned 21 relations. In plain English, the answer reads:
- It is a kind of CTD, salinity sensor and water temperature sensor (L05 device categories).
- It is made by Sea-Bird Scientific (B75 and L35).
- It typically produces parameters such as PSALST01 (practical salinity by CTD), TEMPS901 (ITS-90 temperature), CNDCST01 (conductivity) and PRESPR01 (pressure) from P01.
One natural-language question moved from an instrument name, to its catalogue code, to the parameter codes a data manager would put in the metadata. Every identifier came from the NVS itself.
What I learned building it
Tool descriptions are the user interface. The model reads the docstring and argument annotations to decide what to call. Writing "use collection to scope the search, e.g. P01 parameters, L22 devices" changed behaviour more than any code did.
Design for questions, not endpoints. A single raw SPARQL tool would technically cover everything. In practice the model writes better queries when it has six narrow tools and one escape hatch.
Protect the context window. Vocabularies are big. Pagination, limits and trimmed results keep answers fast and keep the model focused.
Identifiers must be exact, even inside your own server. While writing this post, the shorthand L22:TOOL0058 returned zero mappings, but the full URI returned 21. The NVS triple store keys concepts on http:// URIs, while my shorthand expanded to https://. A single letter turned a correct answer into silence. It is the same lesson the project exists to teach, and the fix is to normalise to the scheme the store actually uses.
Test offline and live. Mocked HTTP tests keep CI fast and network-free. A separate live smoke test against vocab.nerc.ac.uk catches the things mocks cannot, like the one above.
What's next
The bigger opportunity is metadata authoring. Picture an assistant that reads a NetCDF or CSV header, proposes P01 parameter codes and P06 units for each variable, explains each choice, and flags anything ambiguous for a human to confirm. The vocabulary server already holds the knowledge; MCP makes it usable in a conversation.
If you work with marine data, controlled vocabularies or MCP, I would love to hear how you would use this, or what tool you would add next.
Built with Python, FastMCP and the NERC Vocabulary Server. Thanks to BODC for maintaining the vocabularies, and to ols-mcp-server for the reference design.
Top comments (0)