OPC UA MCP Server
A Model Context Protocol (MCP) server that provides seamless integration with OPC UA servers. This server enables AI assistants and other MCP clients to interact with industrial automation systems through standardized OPC UA communication protocols.
Overview
This MCP server acts as a bridge between AI assistants and OPC UA servers, allowing for:
- Reading sensor data and system variables
- Writing control values to actuators and systems
- Browsing OPC UA node hierarchies
- Calling OPC UA methods for system operations
- Batch operations for multiple nodes
Tools
See the central per-tool reference in ../../docs/examples.md; the shared tool surface is defined in ../../contract/tools.json.
Features
Key Capabilities
- Automatic Connection Management: Handles OPC UA client lifecycle with proper connection setup and teardown
- Type-Safe Operations: Automatic type conversion based on existing node data types
- Error Handling: Comprehensive error reporting for debugging and monitoring
- Async Support: Built on FastMCP for efficient asynchronous operations
- Configurable: Environment-based server URL configuration
Installation
Prerequisites
- Python 3.13 or higher
- Access to an OPC UA server (local or remote)
- UV package manager (recommended) or pip
Setup
-
Install dependencies for the whole workspace (run from the repo root):
uv sync --all-packages
-
Configure the OPC UA server URL:
export OPCUA_SERVER_URL="opc.tcp://localhost:4840"
Usage
Running the Server
After uv sync --all-packages from the repo root:
uv run --no-sync opcua-mcp-server
Or run it directly against this package from anywhere in the repo:
uv --directory packages/server-python run opcua-mcp-server
Integration with MCP Clients
Add to your MCP client configuration (e.g., config.json):
{
"mcpServers": {
"opcua-mcp": {
"command": "/path/to/uv",
"args": [
"--directory",
"/path/to/packages/server-python",
"run",
"opcua-mcp-server"
],
"env": {
"OPCUA_SERVER_URL": "opc.tcp://localhost:4840"
}
}
}
}
Example Usage in Conversation
Once configured, you can ask Claude to perform real-world OPC UA operations:
Reading Sensor Values
- "What is the current temperature reading from the reactor vessel?"
- "Check the pressure level in Tank A"
- "Read all temperature sensors in the cooling system"
- "Get the current flow rate on production line B"
Controlling Equipment
- "Turn on the conveyor motor"
- "Set the mixer speed to 80 RPM"
- "Open valve V-101 to 75% position"
- "Start the circulation pump"
- "Set the heating element to 150°C"
Production Operations
- "Start production on line 1 with rate 100 units/hour"
- "Stop all motors in emergency mode"
- "Initialize the batch reactor with recipe A"
- "Begin the cleaning cycle for Tank B"
System Monitoring
- "Show me all alarm states in the system"
- "Read all sensor values from the water treatment plant"
- "Check the status of all pumps and motors"
- "Get the energy consumption readings"
- "What variables are available on this OPC UA server?"
- "Show me all sensors and their current values"
Real Example Scenarios
User: "What's the temperature in reactor R-101?"
Assistant: I'll read the temperature sensor for reactor R-101.
Tool call: read_opcua_node with node_id "ns=2;i=11"
Result: "Reactor R-101 temperature: 87.3°C"
User: "Turn on the main conveyor motor"
Assistant: I'll start the main conveyor motor for you.
Tool call: write_opcua_node with node_id "ns=2;i=12" and value "true"
Result: "Main conveyor motor started successfully"
User: "Set the pump speed to 65%"
Assistant: I'll adjust the pump speed to 65%.
Tool call: write_opcua_node with node_id "ns=2;i=13" and value "65"
Result: "Pump speed set to 65%"
User: "What variables are available on this OPC UA server?"
Assistant: I'll retrieve all available variables from the OPC UA server.
Tool call: get_all_variables
Result: Found 5 variables:
- Temperature (ns=2;i=2): 25.3°C - Temperature sensor
- Pressure (ns=2;i=3): 5.0 bar - Pressure sensor
- MotorSpeed (ns=2;i=4): 1500 RPM - Motor speed
- MotorState (ns=2;i=5): True - Motor ON/OFF state
- ValvePosition (ns=2;i=6): False - Valve OPEN/CLOSED position
API Reference
See the central per-tool reference in ../../docs/examples.md for full tool signatures, parameters, and return formats. The shared tool surface is defined in ../../contract/tools.json.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opcua_mcp_server-0.2.1.tar.gz.
File metadata
- Download URL: opcua_mcp_server-0.2.1.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f8ff2fe9c8110e679046a659b17b0581bd5273c41c39357031a78792c187ca2
|
|
| MD5 |
8e211d3bc49d50ec3a67c874da96c322
|
|
| BLAKE2b-256 |
8ec49ddaff5db48dca124f47b2272f2a83d819205f8b96d7a8811545c4f0fd13
|
Provenance
The following attestation bundles were made for opcua_mcp_server-0.2.1.tar.gz:
Publisher:
publish.yml on midhunxavier/OPCUA-MCP
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opcua_mcp_server-0.2.1.tar.gz -
Subject digest:
2f8ff2fe9c8110e679046a659b17b0581bd5273c41c39357031a78792c187ca2 - Sigstore transparency entry: 2773059282
- Sigstore integration time:
-
Permalink:
midhunxavier/OPCUA-MCP@e1188c62e2b8f4bc1466afce8abfd20e728bbbae -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/midhunxavier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e1188c62e2b8f4bc1466afce8abfd20e728bbbae -
Trigger Event:
push
-
Statement type:
File details
Details for the file opcua_mcp_server-0.2.1-py3-none-any.whl.
File metadata
- Download URL: opcua_mcp_server-0.2.1-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e3cef6dd70b164fe743cb0d94bc8744c71db0cead4e6e891d3a2ab56e53dbf9
|
|
| MD5 |
212c48d581833745c9b548322c8c3579
|
|
| BLAKE2b-256 |
3f90c5d9f3eff416f60c7e2bac021fdb81638d1be2bb7f79ee7e5e372843e45f
|
Provenance
The following attestation bundles were made for opcua_mcp_server-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on midhunxavier/OPCUA-MCP
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opcua_mcp_server-0.2.1-py3-none-any.whl -
Subject digest:
5e3cef6dd70b164fe743cb0d94bc8744c71db0cead4e6e891d3a2ab56e53dbf9 - Sigstore transparency entry: 2773059315
- Sigstore integration time:
-
Permalink:
midhunxavier/OPCUA-MCP@e1188c62e2b8f4bc1466afce8abfd20e728bbbae -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/midhunxavier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e1188c62e2b8f4bc1466afce8abfd20e728bbbae -
Trigger Event:
push
-
Statement type: