OPC UA MCP server

Integrates with OPC UA industrial automation systems to enable reading and writing node values for monitoring and controlling connected devices
Back to servers
Provider
kukapay
Release date
Mar 25, 2025
Language
Python
Stats
7 stars

This MCP server connects to OPC UA-enabled industrial systems, allowing AI agents to monitor, analyze, and control operational data in real time. It serves as a bridge between AI-driven workflows and industrial automation systems, enabling natural language interaction with industrial devices.

Features

  • Read OPC UA Nodes: Retrieve real-time values from industrial devices
  • Write to OPC UA Nodes: Control devices by writing values to specified nodes
  • Browse nodes: List all OPC UA nodes
  • Read multiple OPC UA Nodes: Retrieve multiple real-time values from devices
  • Write to multiple OPC UA Nodes: Control devices by writing values to multiple nodes

Installation

Prerequisites

  • Python 3.13 or higher
  • An OPC UA server (e.g., a simulator or real industrial device)

Install Dependencies

Clone the repository and install the required Python packages:

git clone https://github.com/kukapay/opcua-mcp.git
cd opcua-mcp
pip install mcp[cli] opcua cryptography

Configuration

MCP Client Setup

To configure your MCP client to work with the OPC UA server, add the following configuration to your client's settings:

{
 "mcpServers": {
   "opcua-mcp": {
     "command": "python",
     "args": ["path/to/opcua_mcp/main.py"],
     "env": {
        "OPCUA_SERVER_URL": "your-opc-ua-server-url"
     }
   }
 }
}

Be sure to replace "your-opc-ua-server-url" with the actual URL of your OPC UA server.

Available Tools

The server exposes five tools that can be used through MCP clients:

Read OPC UA Node

Reads the value of a specific OPC UA node.

Parameters:

  • node_id (str): OPC UA node ID (e.g., ns=2;i=2)

Returns: A string with the node ID and its value (e.g., "Node ns=2;i=2 value: 42")

Write OPC UA Node

Writes a value to a specific OPC UA node.

Parameters:

  • node_id (str): OPC UA node ID (e.g., ns=2;i=3)
  • value (str): Value to write (converted based on node type)

Returns: A success or error message (e.g., "Successfully wrote 100 to node ns=2;i=3")

Browse Nodes

Lists all available OPC UA nodes.

Read Multiple OPC UA Nodes

Retrieves values from multiple OPC UA nodes simultaneously.

Write to Multiple OPC UA Nodes

Writes values to multiple OPC UA nodes in a single operation.

Usage Examples

You can interact with the OPC UA server using natural language through an MCP client such as Claude Desktop. Here are some example prompts:

  • "What's the value of node ns=2;i=2?" → Returns the current value
  • "Set node ns=2;i=3 to 100." → Writes 100 to the node
  • "List all available nodes." → Shows all browsable nodes
  • "Read values from nodes ns=2;i=2 and ns=2;i=3." → Returns multiple values
  • "Set node ns=2;i=3 to 100 and node ns=2;i=4 to 200." → Updates multiple nodes

These natural language commands will be interpreted by the MCP client and routed to the appropriate tool in the OPC UA MCP server.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later