opcua
A Python application that connects to an OPC UA server and exposes it via MCP (Model Context Protocol) using FastMCP.
claude mcp add --transport stdio vogler75-opcua-mcp-server python opcua_mcp_server.py
How to use
This MCP server connects to a configured OPC UA server and exposes its node tree as MCP resources using FastMCP. It allows you to browse nodes starting from a configurable node, read values from OPC UA nodes, and search nodes by display or browse names (with wildcard support). The server supports two transport methods: HTTP (default) and stdio, enabling integration with different tooling and deployment scenarios. Once running, you can interact with the exposed MCP resources using any MCP client to read values, browse the tree, or locate nodes by name patterns.
To use the server, start it with the OPC UA server URL as an argument, and optionally provide authentication and a custom starting node or transport. For example, you can run the server over HTTP by default, or switch to stdio transport if you’re piping MCP messages through a local process. The provided MCP tools (read-value, find-by-display-name, find-by-browse-name) allow you to query the OPC UA data programmatically via MCP messages. When you request node values or search results, the server queries the OPC UA server and returns structured responses that include node metadata such as node_id, browse_name, display_name, and node_class.
How to install
Prerequisites:
- Python 3.8+ installed on your system
- Access to install Python packages (pip)
Installation steps:
- Create and activate a virtual environment (optional but recommended):
- On macOS/Linux: python3 -m venv venv && source venv/bin/activate
- On Windows: py -3 -m venv venv && venv\Scripts\activate
- Install dependencies from requirements.txt: pip install -r requirements.txt
- Ensure you have an OPC UA server reachable (URL like opc.tcp://localhost:4840) and any required credentials if authentication is enabled on the OPC UA server.
- Place opcua_mcp_server.py in your project directory (or adjust paths as needed).
- Run the MCP server with the desired configuration (see mcp_config for command): python opcua_mcp_server.py opc.tcp://localhost:4840
Additional notes
Tips and common issues:
- If the OPC UA server requires authentication, use the --username and --password options when launching opcua_mcp_server.py as described in the README.
- By default, the server uses HTTP transport. To switch to stdio transport, pass --transport stdio when launching the server (adjust command-line invocation accordingly).
- The default starting node for browsing is i=85; you can customize this with --start-node to control the root of the node tree exposed via MCP.
- Ensure the OPC UA server URL is reachable from the MCP server host. Network firewalls or TLS settings may require additional configuration.
- MCP tool responses for read operations include node values and error information if a particular node cannot be read.
- If you modify the code or dependencies, re-run the installation steps to ensure requirements are satisfied.
Related MCP Servers
mcp-vegalite
MCP server from isaacwasserman/mcp-vegalite-server
github-chat
A Model Context Protocol (MCP) for analyzing and querying GitHub repositories using the GitHub Chat API.
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
pagerduty
PagerDuty's official local MCP (Model Context Protocol) server which provides tools to interact with your PagerDuty account directly from your MCP-enabled client.
futu-stock
mcp server for futuniuniu stock
mcp -boilerplate
Boilerplate using one of the 'better' ways to build MCP Servers. Written using FastMCP