Parse IEC 61850 substation configuration files and generate SEL RTAC projects and CODESYS PLC code using AI assistance
An MCP (Model Context Protocol) server that bridges IEC 61850 substation automation with AI-powered workflows. Parse SCD/SSD files, generate SEL RTAC .EXP project files, create CODESYS IEC 61131-3 code for GOOSE/Sampled Values subscribers, and validate configurations — all through natural language prompts to Claude.
Configuring IEC 61850 GOOSE and Sampled Values in RTACs and PLCs is tedious and error-prone:
- Manually transcribing dataset members from SCD files into RTAC tag databases
- Writing boilerplate IEC 61131-3 code for GOOSE subscriber logic
- Keeping confRev values synchronized between publishers and subscribers
- Catching duplicate AppIDs, MAC address conflicts, and tag name collisions
This MCP server automates the entire pipeline. Give Claude an SCD file and a prompt like "Generate an RTAC project that subscribes to all GOOSE from PROT1 and PROT2, prefix tags with BAY1_, include a staleness watchdog" — and get a validated, ready-to-import .EXP file in seconds.
- Extract all IEDs, logical nodes, datasets, GOOSE control blocks (GoCBs), and Sampled Value control blocks (SvCBs)
- Resolve communication addresses (AppID, MAC, VLAN) from the
<Communication>section - Map dataset members to full IEC 61850 signal paths
- Complete AcSELerator RTAC project files ready for import
- IEC 61850 GOOSE subscriber configuration (AppID, MAC, VLAN, confRev)
- Tag database with CDC-aware typing (SPS →
SPS, DPS →DPS, MV →MV, etc.) - Tag Processor mappings binding GOOSE dataset members to RTAC internal tags
- IEC 61131-3 Structured Text watchdog function block:
stNum/sqNumchange detection- Staleness alarm (no GOOSE retransmission within
MaxTime) - Communication failure alarm (extended timeout)
- Function Block declarations and implementations for GOOSE subscription
- Global Variable Lists (GVLs) for cross-POU tag sharing
- CDC-to-ST type mapping (
SPS→BOOL,DPS→BYTE,MV→REAL) - Quality flag companion variables (
_Q : WORDper signal) - Ready for
@codesys/mcp-toolkitintegration (directset_pou_codecalls)
- confRev consistency checks (EXP vs SCD)
- Duplicate AppID detection
- MAC address format validation (IEC 61850-8-1 multicast range)
- RTAC tag name constraints (length, character rules)
- Dataset member type validation
- Missing quality attribute warnings on protection signals
- Python 3.10+
- Claude Desktop or Claude CLI (for MCP client)
- Optional: CODESYS V3.5 +
@codesys/mcp-toolkit(for CODESYS integration) - Optional: SEL AcSELerator RTAC (to import generated
.EXPfiles)
-
Clone the repository:
git clone https://github.com/yourusername/iec61850-mcp-server.git cd iec61850-mcp-server -
Install Python dependencies:
pip install -r requirements.txt
⚠️ Note: ThemcpPython SDK is not yet available on PyPI. You'll need to install it manually or wait for the official release. For now, the server can be tested using thetests/test_pipeline.pyscript which exercises all tools without requiring the MCP transport layer. -
Test the installation:
python tests/test_pipeline.py
You should see all tests pass with output showing parsed IEDs, generated RTAC tags, and validation results.
Add to your Claude Desktop config file (%LOCALAPPDATA%\AnthropicClaude\LocalState\mcp.json on Windows, ~/Library/Application Support/AnthropicClaude/LocalState/mcp.json on macOS):
{
"mcpServers": {
"iec61850": {
"command": "python",
"args": ["/path/to/iec61850-mcp-server/server.py"]
}
}
}Create a .mcp.json in your project directory:
{
"mcpServers": {
"iec61850": {
"command": "python",
"args": ["./server.py"]
}
}
}For the full CODESYS integration, add both servers:
{
"mcpServers": {
"iec61850": {
"command": "python",
"args": ["/path/to/iec61850-mcp-server/server.py"]
},
"codesys": {
"command": "codesys-mcp-tool",
"args": [
"--codesys-path", "C:\\Program Files\\CODESYS 3.5.22.20\\CODESYS\\Common\\CODESYS.exe",
"--codesys-profile", "CODESYS V3.5 SP22 Patch 3"
]
}
}
}"Parse the SCD file at
/data/substation1.scdand show me all GOOSE control blocks"
Claude will call parse_scd_file and get_goose_control_blocks to extract:
- IED names and logical devices
- GoCB names, datasets, AppIDs, MAC addresses, confRev values
- Dataset members with full signal paths
"Generate an SEL RTAC project for IED
RTAC1. Subscribe to GOOSE fromPROT1LD0/LLN0$GO$GCB_PROTandPROT2LD0/LLN0$GO$GCB_BUS. Prefix all tags withBAY1_. Include a staleness watchdog. Save to/output/RTAC1_Bay1.exp."
Claude will:
- Parse the SCD to resolve GoCB configurations
- Generate tag mappings with CDC-aware types
- Create the complete
.EXPXML file - Validate for confRev consistency and AppID conflicts
Import into AcSELerator RTAC:
- GUI:
File → Import Project - CLI:
AcRtacCmd importexp -p "MyProject" -f RTAC1_Bay1.exp
"Generate a CODESYS Function Block named
FB_GOOSE_Bay1that subscribes toPROT1LD0/LLN0$GO$GCB_PROT. Include quality flags and a watchdog. Show me the declaration and implementation."
Claude will call generate_codesys_pou and return:
declaration: Full VAR blocks ready forset_pou_codeimplementation: ST body with watchdog logictoolkit_steps: Ordered list of@codesys/mcp-toolkitcalls to execute
With CODESYS MCP toolkit connected:
"Generate the CODESYS FB, then create it in my project at
C:\Projects\Bay1.projectand compile."
Claude will:
- Generate the code (iec61850 server)
- Call
create_pou(codesys server) - Call
set_pou_codewith declaration and implementation - Call
compile_projectand report any errors
"Validate the GOOSE config for
PROT1LD0/LLN0$GO$GCB_PROTin/data/substation1.scd"
Claude will check:
- AppID uniqueness and range (0x0000–0x3FFF)
- MAC address format (IEC 61850-8-1 multicast range)
- Dataset member count and types
- Retransmission timing sanity (MinTime, MaxTime)
| Tool | Description |
|---|---|
parse_scd_file |
Parse an IEC 61850 SCD/SSD/ICD file and return all IEDs, logical nodes, datasets, GoCBs, and SvCBs |
get_goose_control_blocks |
Get all GOOSE control blocks for a specific IED with communication addresses and dataset members |
get_sv_control_blocks |
Get all Sampled Value control blocks for a specific IED |
generate_rtac_tag_mapping |
Generate Tag Processor mapping rows for a GOOSE control block |
generate_rtac_exp |
Generate a complete SEL RTAC .EXP project file from an SCD |
validate_rtac_exp |
Validate an .EXP file against RTAC constraints and cross-check with SCD |
validate_goose_config |
Validate a GOOSE control block configuration in an SCD file |
generate_codesys_pou |
Generate CODESYS Function Block code for GOOSE subscription |
generate_codesys_gvl |
Generate a CODESYS Global Variable List for GOOSE tags |
┌─────────────────────┐
│ Claude (AI) │
│ Natural language │
│ prompts │
└──────────┬──────────┘
│ MCP (JSON-RPC over stdio)
│
┌──────────▼──────────────────────────────────────────┐
│ IEC 61850 MCP Server (Python) │
│ │
│ ┌────────────────┐ ┌──────────────────┐ │
│ │ SCD Parser │ │ RTAC Generator │ │
│ │ (XML → dicts) │ │ (dicts → .EXP) │ │
│ └────────────────┘ └──────────────────┘ │
│ │
│ ┌────────────────┐ ┌──────────────────┐ │
│ │ CODESYS Gen │ │ Validator │ │
│ │ (dicts → ST) │ │ (confRev, AppID) │ │
│ └────────────────┘ └──────────────────┘ │
└─────────────────────────────────────────────────────┘
│
│ (Optional integration)
│
┌──────────▼──────────────────────────────────────────┐
│ @codesys/mcp-toolkit (Node.js) │
│ - create_pou, set_pou_code, compile_project │
│ - Direct CODESYS scripting engine integration │
└─────────────────────────────────────────────────────┘
The server is stateless — each tool call is independent. The XML parsing uses Python's built-in xml.etree.ElementTree (no heavy dependencies). Code generation uses string templates (Jinja2 planned for future versions).
-
.EXPXML Schema:
The SEL RTAC.EXPformat is reverse-engineered from AcSELerator exports. It works for tested RTAC firmware versions (SEL-3555, SEL-3530 with firmware 3.x/4.x), but may need adjustments for other models or versions. Always validate imported projects in AcSELerator before deployment. -
GOOSE Dataset Read Placeholders:
The CODESYS Function Block implementation generates comment placeholders for reading GOOSE dataset members. You must replace these with actual library calls (CODESYS IEC 61850 library, SysSocket + manual decode, or RTAC bridge). This is intentional — the correct approach depends on your library availability. -
Sampled Values:
SV subscriber generation creates a placeholder config block in the.EXPfile with a note that MU sync (PTP/IEEE 1588) configuration is required. Full SV automation is planned but not yet implemented. -
Tag Name Deduplication:
If multiple publishers have identically-named signals (e.g.,PROT1andPROT2both publishPDIF1.Op.general), the generator will create duplicate tag names. The validator catches this, but the generator doesn't auto-deduplicate yet. Workaround: use different tag prefixes per publisher or manually rename in the generated.EXP. -
GOOSE Subscriptions Extraction:
The parser doesn't yet extract<ExtRef>elements from subscriber IEDs. Aget_goose_subscriptions()tool to map publisher → subscriber relationships is planned. -
MCP Python SDK:
Themcppackage is not yet available on PyPI. This server'sserver.pyexpects the MCP SDK to be installed separately. Until the official release, the tool logic can be tested viatests/test_pipeline.py.
- Add
get_goose_subscriptions()tool (extract<ExtRef>mappings) - Implement tag name deduplication in RTAC generator
- Full Sampled Values subscriber support (MU sync config)
- Template-based code generation (Jinja2) for easier customization
- SCL schema validation (against IEC 61850-6 XSD)
- ICD file generation (publish IED capabilities back to SCD)
- Support for IEC 61850-90-5 (routable GOOSE/SV over IP)
- Web UI for non-Claude users (FastAPI + React)
- Docker container for easier deployment
Contributions are welcome! This project fills a real gap in the OT/ICS automation space, and there's plenty of room for improvement.
- Fork the repository and create a feature branch
- Write tests for new tools or generators (
tests/test_*.py) - Follow the existing code style:
- Tool functions return
dict[str, Any]with"error"key on failure - Generators yield structured output (lists/dicts), not formatted strings
- Validators return
{"status": "PASS"|"FAIL", "errors": [...], "warnings": [...]}
- Tool functions return
- Update documentation (docstrings, README examples)
- Submit a pull request with a clear description of what you've added
- Testing with real SCD files from different vendors (ABB, Siemens, GE, SEL)
- RTAC firmware compatibility testing (SEL-3555, SEL-3530, SEL-3505)
- CODESYS library integration examples (official IEC 61850 lib, vendor-specific libs)
- Performance optimization for large SCD files (1000+ IEDs)
- Error message improvements (more actionable diagnostics)
- Additional output formats (other RTAC/PLC vendors beyond SEL)
See CONTRIBUTING.md for detailed guidelines.
MIT License - see LICENSE file for details.
You are free to use, modify, and distribute this software for commercial or non-commercial purposes. Attribution is appreciated but not required.
- Built with assistance from Claude (Anthropic) using the Model Context Protocol
- Inspired by the need for better tooling in substation automation and OT/ICS security
- Thanks to the open-source community for
@codesys/mcp-toolkitand IEC 61850 standardization efforts - Sample SCD files follow IEC 61850-6 (SCL) structure; tested against IEC 61850-8-1 (GOOSE/SV) specifications
- Issues: Report bugs or request features via GitHub Issues
- Discussions: Ask questions or share use cases in GitHub Discussions
- Security: For security vulnerabilities, email [your-email@example.com] (do not open public issues)
@codesys/mcp-toolkit— MCP server for CODESYS V3 automationlibIEC61850— Open-source IEC 61850 client/server library (C)rapid61850— Lightweight GOOSE/SV code generator from SCD files (C/C++)- Model Context Protocol — Protocol specification for AI-tool integration
Built for protection engineers, SCADA integrators, and anyone tired of manually transcribing SCD files.