OPC UA MCP Server

v0.6.0
io.github.midhunxavier/opcua Checked 9 hours ago Published 26 days ago

Connect AI assistants to industrial OPC UA: browse, read, history, subscriptions, events and alarms.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

read_opcua_nodes

Read the current value of one or more OPC UA nodes in a single request. Pass every node you need in one call: the OPC UA server answers them together, so reading fifty nodes costs one round trip rather than fifty. Each node comes back as its own record with the value, its data type, the OPC UA status code, and the source and server timestamps — the quality and the age are what decide whether a value can be acted on, and a bare number carries neither. A node the server rejects is one 'Bad…' status among the results, not a failure of the call.

ParameterTypeDescription
node_ids *arrayThe OPC UA node IDs to read, in the format 'ns=<namespace>;i=<identifier>'. Example: ['ns=2;i=2', 'ns=2;i=3']. A single node is a one-element list. At most 500 per call.
include_write_accessbooleanAlso report, per node, whether it can be written and what a write must look like (write_access): its type, whether it is an array, its enumeration states and labels, and the bounds a value must stay w…

browse_opcua_nodes

Explore the OPC UA address space: list a node's children, walk a subtree, resolve a human-readable browse path to a node ID, or search for nodes by name. With the defaults it lists the immediate children of `node_id`. Raise `depth` to walk further down, set `node_class` to 'Variable' to find only readable tags, and `include_values` to read each one as it is found. `browse_path` addresses a node by name instead of by ID ('/Objects/Reactor/Temperature'), which is how to start when you do not know the numeric IDs; with `depth` 0 it simply resolves that path and returns the node it names. `name_fi…

ParameterTypeDescription
browse_pathstring | nullWhere to start, as a slash-separated browse path resolved through the server ('/Objects/Reactor/Temperature', or 'Reactor/Temperature' relative to `node_id`). Use this when you know what a thing is ca…
depthinteger | nullHow many levels below the starting node to walk. 1 (the default) lists its immediate children; 0 returns only the starting node itself, which is how to resolve a `browse_path` to a node ID. Clamped to…
include_valuesboolean | nullRead each Variable's current value as it is found (default false). Costs one extra read per variable, so leave it off when mapping a large address space and read what you need with read_opcua_nodes af…
max_nodesinteger | nullStop after inspecting this many nodes (default 500, clamped to 5000). A traversal that stops early sets 'truncated' in the result.
name_filterstring | nullKeep only nodes whose browse name contains this text, case-insensitively. Searching for 'temp' below the Objects folder is how to find a tag whose exact name you do not know.
node_classstring | nullKeep only nodes of this OPC UA NodeClass: 'Variable' for readable tags, 'Object' for structure, 'Method' for callable operations. Every class is returned when unset. Filtering does not prune the walk…
node_idstring | nullWhere to start, as a node ID. Defaults to the Objects folder 'ns=0;i=85', the root of the plant's own address space. Ignored when `browse_path` is given.

read_opcua_history

Read what a node's value has been over time. Without `aggregate_function` this returns the raw stored readings, with ReturnBounds=false: no preceding/following boundary values or BadBoundNotFound placeholders. With it, the server computes one summary value per `processing_interval` over the range instead — 'Average' for a trend, 'Maximum'/'Minimum' for excursions, 'Count' for how often something was recorded — which is how to ask about a week of data without transferring a week of data. Needs a server that keeps history (AccessHistoryDataCapability) or offers aggregates, and `aggregate_fun…

ParameterTypeDescription
node_id *stringThe OPC UA node ID to read history for. Example: 'ns=2;i=2'.
aggregate_functionstring | nullSummarise each interval with this OPC UA aggregate instead of returning raw readings, by its OPC UA name: 'Average', 'Minimum', 'Maximum', 'Count', 'Total', 'Interpolative', ... Which ones the connect…
end_timestring | nullEnd of the time range, ISO-8601 with a timezone. Defaults to now.
num_valuesinteger | nullMaximum number of raw readings to return, capped at 5000. 0 (the default) means as many as that cap allows, not every reading in the range — a raw read of a year of fast data is a request that never…
processing_intervalnumber | nullWidth in milliseconds of each interval the aggregate is computed over. 0 (the default) makes the whole range a single interval, giving one result. Only meaningful with `aggregate_function`.
start_timestring | nullStart of the time range, ISO-8601 with a timezone: '2026-09-09T12:00:00Z' or '2026-09-09T14:00:00+02:00'. A timestamp with no timezone is refused rather than guessed. Required when `aggregate_function…

read_event_history

Read events the OPC UA server stored, for a time range that has already passed. subscribe_events only sees what arrives after you subscribe, so it cannot answer 'what happened overnight' or 'what fired in the ten minutes before the line stopped' — the events are gone by the time anyone asks. This reads them back out of the server's own event archive instead. Same records as read_events and the same fields, so an alarm looks identical whether it was watched live or recovered afterwards. Needs a server that reports AccessHistoryEventsCapability — storing values and storing events are separat…

ParameterTypeDescription
end_timestring | nullEnd of the time range, ISO-8601 with a timezone. Defaults to now.
node_idstring | nullThe notifier node whose stored events to read. Defaults to the Server object 'ns=0;i=2253', which is where most servers collect events. This is the same node subscribe_events takes.
num_valuesinteger | nullMaximum number of events to return, capped at 5000. 0 (the default) means as many as that cap allows, not every event in the range — an alarm burst can be tens of thousands of events, and asking for…
severity_mininteger | nullKeep only events of at least this OPC UA severity (1-1000). Default 0, which keeps every event. Filtered here rather than by the server, exactly as subscribe_events does, so a server that mishandles a…
start_timestring | nullStart of the time range, ISO-8601 with a timezone: '2026-09-09T12:00:00Z' or '2026-09-09T14:00:00+02:00'. A timestamp with no timezone is refused rather than guessed. Defaults to one hour before `end_…

get_server_status

Report whether this MCP server is connected to the OPC UA server and what that server says about itself: its endpoint and connection security, its ServerStatus (state, current time, start time, build info) and its NamespaceArray as index -> URI. The one tool that answers while the connection is down — it reports 'connected': false and why, rather than failing — so it is both the health check and the first thing to call when another tool cannot reach the server. The namespace array is also how to tell which 'ns=' index belongs to which namespace URI on this server. 'diagnostics' is the serv…

list_subscriptions

List the active OPC UA data-change subscriptions, each with the value changes buffered for it since it was created. This is how to collect what subscribe_opcua_nodes has been watching; the same document is also readable as the 'opcua://subscriptions' resource.

list_active_alarms

List the alarm and condition instances the server is currently retaining — those that are active, unacknowledged, or both. Asks the server for them directly (the ConditionRefresh method), so the answer is the current state of the plant rather than whatever this MCP server happened to be listening for. Use this to answer 'what is wrong right now'; use read_events to see what has happened since you last looked.

ParameterTypeDescription
node_idstring | nullThe notifier node whose conditions to list. Defaults to the Server object 'ns=0;i=2253'.
timeout_secondsnumber | nullHow long to wait for the server to finish sending its retained conditions (default 5). Running out is an error, not an empty list: a partial answer cannot be told apart from 'no alarms'.

subscribe_opcua_nodes

Watch one or more OPC UA nodes for value changes instead of polling them. The OPC UA server pushes each new value into a buffer this MCP server keeps; collect them with list_subscriptions or the 'opcua://subscriptions' resource. This is the right way to answer 'tell me when this changes' or 'what has this been doing' over a short window — repeatedly calling read_opcua_nodes both misses changes between calls and costs a round trip each time. Each node gets its own subscription record and its own ID; cancel them with unsubscribe_opcua_nodes. Subscriptions are re-established automatically if th…

ParameterTypeDescription
node_ids *arrayThe OPC UA node IDs to monitor. Example: ['ns=2;i=3']. A single node is a one-element list. Each gets its own OPC UA subscription, and this server holds at most 200 at a time.
buffer_sizeinteger | nullHow many of the most recent changes to retain per subscription; older ones are discarded. Default 20, clamped to 1..1000.
data_change_triggerstring | nullWhat counts as a change. 'statusValue' (the default) reports a change of value or of OPC UA status. 'status' reports only status transitions — useful for watching a tag go bad without caring what it…
deadband_typestring | nullFilter out changes too small to be worth reporting (OPC UA Part 4 §7.22). 'none' (the default) reports every change the server samples, which on a noisy analogue tag fills the buffer with sensor jitt…
deadband_valuenumber | nullHow far the value must move to be reported, in engineering units for 'absolute' and in percent of EURange for 'percent'. Ignored when `deadband_type` is 'none' or unset; required when it is not.
publishing_intervalnumber | nullHow often (ms) the OPC UA server publishes queued changes. Default 1000. Clamped to at least 50.
sampling_intervalnumber | nullHow often (ms) the OPC UA server samples each node. 0 (the default) means sample at `publishing_interval`; a shorter interval queues several readings per publish.

unsubscribe_opcua_nodes

Cancel one or more active data-change subscriptions and discard what they had buffered. Returns the subscriptions as they were at the moment they were cancelled, so anything still buffered can be read one last time. An ID that is not active is an error naming it, and no subscription is cancelled.

ParameterTypeDescription
subscription_ids *arrayThe subscription IDs returned by subscribe_opcua_nodes, as listed by list_subscriptions. Example: ['sub-1'].

subscribe_events

Start buffering OPC UA events (alarms, condition changes, plain events) from a notifier node. Returns at once; the events themselves are collected in the background and read with read_events. Calling it again for the same node replaces the subscription and discards what it had buffered. Use this to watch for things happening; use list_active_alarms for what is wrong right now.

ParameterTypeDescription
buffer_sizeinteger | nullHow many events to hold before the oldest are dropped (default 100, clamped to 10000). read_events reports how many were dropped.
node_idstring | nullThe notifier node to subscribe to. Defaults to the Server object 'ns=0;i=2253', which is where most servers publish every event they raise.
severity_mininteger | nullBuffer only events of at least this OPC UA severity (1-1000). Default 0, which keeps every event.

read_events

Read the events buffered by subscribe_events, oldest first. The events returned are removed from the buffer, so a second call returns only what has arrived since. If the buffer overflowed in the meantime, the result says how many were dropped rather than quietly skipping them — in the structured result's `completeness`, which also says whether more are still buffered.

ParameterTypeDescription
limitinteger | nullMaximum number of events to return (default 50).
node_idstring | nullThe subscribed notifier node to read from, as passed to subscribe_events. Defaults to the Server object 'ns=0;i=2253'.