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.
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
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.
The server exposes five tools that can be used through MCP clients:
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")
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")
Lists all available OPC UA nodes.
Retrieves values from multiple OPC UA nodes simultaneously.
Writes values to multiple OPC UA nodes in a single operation.
You can interact with the OPC UA server using natural language through an MCP client such as Claude Desktop. Here are some example prompts:
These natural language commands will be interpreted by the MCP client and routed to the appropriate tool in the OPC UA MCP server.
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.
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"
]
}
}
}
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.
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.