OSMAINT

Academy / Developer

MCP tools and the AI layer

Lesson 5 of 614 minDevelopers, integrators, partners

Goal

Extend the MCP server and the AI features without breaking determinism or leaking data.

The MCP server exposes OSMAINT to AI clients as tools: whoami, list sites, search equipment, get and list work orders, list alarms, open condition events, list routes, hazards, safety plans, meter groups, create and update work orders, run a route. The tool contract is the product surface for agents.

Adding a tool

  1. Define the tool with a narrow, explicit input schema.
  2. Enforce the caller's scopes inside the tool, not only in the client.
  3. Cap list results and report truncation and total.
  4. Return structured errors the model can act on.
  5. Test the tool with a viewer token: it must not mutate.

The AI rule

Every AI feature has a deterministic path. Classification, prioritisation, root-cause suggestions, PM optimisation and report drafting all degrade to a manual choice when no model is available. That is why the AI provider is configuration, not an assumption.

Data boundaries

An AI feature that sends records to an external provider is a data-processing decision, not a UI decision. Self-hosted installations can point the AI layer at a local model, which keeps the data inside the plant. Document which provider is used and what leaves the system.

Note

Never put a secret, a token or a real customer record in a prompt, a test fixture or a documentation example. Placeholders only.

Verify

Call one read tool and one write tool with a viewer token. The read must succeed within its scope; the write must fail with a permission error.

Terms

Tool
A named function an AI client can call, with a schema and a permission boundary.
Deterministic fallback
The non-AI path that keeps the feature working when no model is available.
Progress is stored in this browser only.

OSMAINT Academy · Developer · MCP tools and the AI layer · osmaint.org/academy/