MCP server for AI agents
@scadex.io/mcp is a Model Context Protocol server for a gateway. An AI agent in Claude Code, Claude Desktop or another MCP client calls it as typed tools instead of reading this reference and building REST requests. This page is for whoever sets up an agent against a gateway.
The server runs on the same machine as the client, speaks MCP over standard input and output, and calls the gateway's REST API with an API key. It is read-only unless you turn writes on.
Requirements and install
- A gateway, and an API key from Gateway, then Security, then API keys.
- Node.js 22 or newer. Tag history is read over the gateway's
/syncWebSocket, which Node provides from version 22.
The package (version 0.1.0) is not on a registry yet. Build it from the platform repository, as the TypeScript SDK is:
cd platform
pnpm install
pnpm --filter "@scadex.io/mcp..." build
node packages/mcp/dist/bin.js --help
"@scadex.io/mcp..." builds the SDK it depends on first. The program is scadex-mcp, which is dist/bin.js.
Configure
| Setting | Default | Meaning |
|---|---|---|
SCADEX_URL | http://localhost:8080 | The gateway's address. Use https:// where the gateway has it |
SCADEX_API_KEY | none | The API key, sent as Authorization: Bearer. It is never printed, logged or put in a result |
SCADEX_MCP_WRITES | off | on registers the two tools that change something. The option --allow-writes does the same |
The key goes only to the gateway's own address. The server writes its own messages to standard error and says only whether a key is set. If SCADEX_URL is plain http:// to another machine, it says at start that the key travels unencrypted.
Connect a client
Claude Code:
claude mcp add scadex \
-e SCADEX_URL=http://localhost:8080 \
-e SCADEX_API_KEY=scx_... \
-- node /absolute/path/to/platform/packages/mcp/dist/bin.js
Claude Desktop, in claude_desktop_config.json:
{
"mcpServers": {
"scadex": {
"command": "node",
"args": ["/absolute/path/to/platform/packages/mcp/dist/bin.js"],
"env": { "SCADEX_URL": "http://localhost:8080", "SCADEX_API_KEY": "scx_..." }
}
}
}
Any client that starts a stdio MCP server takes the same command and environment.
Tools
| Tool | What it does | Role |
|---|---|---|
scadex_status | Whether the gateway answers, its version and uptime, licence state, modules running or not, how many tags have a value that is not Good, what the gateway reports as wrong, and what the key may do | viewer |
scadex_search_tags | Finds tags and folders by words in the path, inside one folder, or one level at a time | viewer |
scadex_read_tags | Current value, quality, timestamp and age of up to 100 tag paths | viewer |
scadex_tag_history | A tag's values over a time range | viewer |
scadex_list_alarms | The outstanding alarms, most severe first, with the occurrenceId of each | viewer |
scadex_alarm_history | The alarm event log, newest first | viewer |
scadex_list_modules | Modules with version, kind, state, error and licence | viewer |
scadex_write_tag | Writes one value to one tag. Only with writes on | operator |
scadex_acknowledge_alarm | Acknowledges one alarm occurrence. Only with writes on | operator |
Conventions that hold for every tool:
- Lists are capped: 50 rows by default, 500 at most (
limit). A capped result carriestruncated: true, thetotalthat matched, andhowToNarrow. - Results are compact JSON, returned as text and as
structuredContentagainst the tool's output schema. Times are ISO 8601 in UTC. - Times you give are ISO 8601,
now, or back from now:-30m,-6h,-2d,-1w. - A failure is an error result (
isError) with the gateway's own message and a hint, not an exception. See When a call fails. - Annotations: the read tools are marked
readOnlyHint,idempotentHintand notdestructiveHint.scadex_write_tagis marked not read-only, destructive (it overwrites a value) and idempotent.scadex_acknowledge_alarmis marked not read-only, not destructive and idempotent.
Tag history
scadex_tag_history takes path, start (default -1h), end (default now), resolution and, for raw values, maxPoints. With resolution: "chart", the default, the gateway splits the range into equal time buckets and keeps each bucket's lowest and highest value, so a short spike survives a long range. It answers at most 290 points. A range with fewer values returns them as they are. With "raw" you get the stored values, up to maxPoints (300 by default, 500 at most).
Points are [time, value, quality] rows, oldest first, with before, the last value recorded before the range began, and plain counts in stats (minimum, maximum, first, last and how many points are not Good). The result also says who answered: source is the historian module, or backbone for the gateway's recent event timeline; retainedFrom is the oldest time that source holds; gaps are parts of the range the historian never received; catchingUp means the historian is behind the live stream. The gateway answers a path that does not exist the same way as a tag with no history, so an empty result carries a note to check the path with scadex_search_tags.
Alarms
scadex_list_alarms lists what is outstanding: active, acknowledged, and cleared and waiting for an acknowledgement (see Alarms). It filters by state, minSeverity (1 to 1000), tag text and shelving. Each alarm has its tag, condition, setpoint, the value and quality it was last evaluated on, stale when the tag's newest value could not be trusted, and occurrenceId.
Resources and the prompt
| Name | What it is |
|---|---|
scadex://tag-paths | How tag paths are written ([provider]Folder.Sub.Tag), folders, the [system] tags and what a read returns. See Tags |
scadex://alarms | Alarm states, severity, conditions, how quality affects an alarm and what acknowledging does |
scadex://access | Roles, the write gate, where a reason is recorded and what each refusal means |
scadex_investigate_alarm (prompt) | Steps for reading an alarm, its tag's value and recent history, related tags and the alarm's own history, then summarising the facts without verdicts. Arguments: alarm (id, name or tag path) and optionally hours |
The server also sends instructions when a client connects: start with scadex_status, report facts and not verdicts, and say next to a value when its quality is not Good.
Writes are off unless you turn them on
Without SCADEX_MCP_WRITES=on or --allow-writes, scadex_write_tag and scadex_acknowledge_alarm are not registered. They are not in the tool list, and calling one by name is refused as an unknown tool.
With writes on, both tools require a reason of 3 to 300 characters, and the result echoes it. What the gateway does with it differs:
| Tool | Where the reason goes |
|---|---|
scadex_write_tag | Sent as the write's correlationId, prefixed mcp: . The audit log keeps it with the value, the key (apikey:<id>) and the outcome |
scadex_acknowledge_alarm | The gateway's acknowledge route has no field for it. The gateway records who and when. The reason is echoed in the result only, with reasonStoredByGateway: false |
scadex_acknowledge_alarm needs the occurrenceId of the firing that was listed. If the alarm has fired again since, the gateway answers 409 and nothing is acknowledged.
A write needs tag.write, which the operator role holds, like any write to a tag. The gateway checks the key's roles on every request. A key is as wide as its roles: an operator key can write to every tag unless a deny in one of its roles keeps some out, and a role of your own can allow writes for one provider or branch only; see API keys.
What the key may do
At start the server asks the gateway who the key is, once, and scadex_status reports the role. A gateway of 0.2.1-preview.14 or newer answers GET /api/v1/whoami with the key's role, and nothing else is needed. An older gateway has no such route (GET /api/v1/me answers a signed-in person only), so the server works the role out from what the key is let into:
GET /api/v1/runtime/healthlists modules only to a caller the gateway accepts, which says whether the key is valid at all.GET /api/v1/admin/diagnosticsneeds the admin role andGET /api/v1/dashboards/connectionsthe engineer role. Both are reads.- With writes on only, one
POSTthat acknowledges an alarm that cannot exist. An operator is answered404, a viewer403, and nothing is recorded or changed either way.
Against an older gateway with writes off the server reports viewer or operator for a key that is neither engineer nor admin, since telling those two apart takes a write-capable request. With writes on, a viewer key gets "This key is a viewer, so it cannot write a tag: that needs operator." from the write tools, and nothing is sent to the gateway.
When a call fails
| Gateway answer | What the model is told |
|---|---|
401 | The gateway did not accept the key. Check SCADEX_API_KEY: it may be wrong, revoked or expired |
403 | The key's role is X, the call needs Y. Where the role is high enough, a deny in one of the key's roles may still keep one provider or branch out |
404 | Nothing there. Check the path with scadex_search_tags, or the id with scadex_list_alarms |
409 | The state changed: an alarm fired again since it was listed. List again and use the new occurrenceId |
| no answer | The address, the error code, and that the gateway has to be running and reachable from this machine |
Each error result has error (what happened), status and gatewayMessage when the gateway answered, and hint (what to do next).
Security
- Give the key the lowest role that does the work:
viewerto read. Make one key per agent, with an expiry, so it can be revoked alone. A key reaches what its roles allow, so a role limited to a provider or branch keeps an agent to those tags. - Keep writes off unless an agent needs them. An agent that writes changes a real plant: the client's own settings decide whether a person is asked before each call, and the tool annotations are what a client uses to decide.
- Everything the gateway shows the key reaches the model: tag paths, values and alarm names. The key's roles can keep it out of a provider's tags, or a branch of them.
- The server calls no route above the viewer role except the two reads that find out the key's role and, with writes on, the operator-level write routes. An administrator key cannot manage users, API keys or sign-in providers in any case (see API keys).
Not covered
- Only tags are read. Tag types, screens, dashboards, connections, scripts, the audit log and settings have no tool.
- Nothing subscribes. Every call is a request and an answer, so an agent that watches a value asks again.
- A write sends a number, a boolean or text, not a structured value.
- The server has been run against a gateway with memory tags, not against one with a device behind it.