Dlaczego MCP zmienia wszystko
Klasyczni asystenci AI (ChatGPT, Copilot) cierpią na poważny problem w automatyce przemysłowej: halucynacje kontekstowe. Generują syntaktycznie poprawny kod SCL, ale używają zmiennych, które nie istnieją, błędnych typów danych lub ignorują konfigurację sprzętową. Dzięki wbudowanemu serwerowi MCP w T-IA Connect, AI może widzieć Twój projekt, czytać tabele tagów, sprawdzać istniejące bloki — i faktycznie tworzyć lub modyfikować kod w TIA Portal.
Wymagania wstępne
- T-IA Connect zainstalowany i uruchomiony
- Otwarty projekt TIA Portal (V16–V21)
- Klient AI kompatybilny z MCP (Claude Desktop lub dowolny klient MCP)
Konfiguracja: Połącz swojego AI z TIA Portal
Dodaj T-IA Connect jako serwer MCP w pliku konfiguracyjnym Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"tia-connect": {
"command": "C:\\Program Files\\FeelAutomCorp\\TiaConnect\\TiaPortalApi.McpBridge.exe",
"args": [],
"env": {
"TIA_CONNECT_URL": "http://localhost:9000",
"TIA_CONNECT_API_KEY": "your-api-key"
}
}
}
}McpBridge.exe działa jako most stdio-to-HTTP. Przekazuje żądania AI do serwera API T-IA Connect, który komunikuje się z TIA Portal przez Openness.
Przykład 1: Sprawdź status projektu
Najprostsze narzędzie — zweryfikuj połączenie z TIA Portal i sprawdź, który projekt jest otwarty.
{
"name": "get_project_status",
"arguments": {}
}{
"connected": true,
"projectName": "WaterTreatment_V19",
"projectPath": "C:\TIA_Projects\WaterTreatment_V19",
"tiaVersion": "V19",
"modified": false
}Przykład 2: Otwórz projekt
Otwórz plik projektu TIA Portal bezpośrednio z poziomu AI. Możesz także wyszukać dostępne projekty na dysku za pomocą list_project_files.
{
"name": "open_project",
"arguments": {
"path": "C:\TIA_Projects\WaterTreatment_V19\WaterTreatment_V19.ap19"
}
}{
"success": true,
"projectName": "WaterTreatment_V19",
"version": "V19"
}Przykład 3: Lista urządzeń
Zobacz wszystkie PLC, HMI i inne urządzenia w bieżącym projekcie.
{
"name": "list_devices",
"arguments": {}
}[
{
"name": "PLC_1",
"type": "CPU 1516-3 PN/DP",
"category": "PLC"
},
{
"name": "HMI_1",
"type": "TP1500 Comfort",
"category": "HMI"
}
]Przykład 4: Lista i odczyt bloków
Przeglądaj wszystkie bloki (FB, FC, DB, OB) w PLC, a następnie odczytaj pełny kod i interfejs dowolnego bloku.
// Step 1: List all blocks
{ "name": "list_blocks", "arguments": { "deviceName": "PLC_1" } }
// Step 2: Read a specific block
{ "name": "get_block_details", "arguments": {
"deviceName": "PLC_1",
"blockName": "FB_MotorControl"
}
}// list_blocks response
[
{ "name": "Main [OB1]", "type": "OB", "language": "LAD", "number": 1 },
{ "name": "FB_MotorControl", "type": "FB", "language": "SCL", "number": 1 },
{ "name": "DB_Config", "type": "DB", "language": "DB", "number": 1 }
]
// get_block_details response
{
"name": "FB_MotorControl",
"type": "FB",
"language": "SCL",
"interface": {
"input": [
{ "name": "Start", "type": "Bool" },
{ "name": "Stop", "type": "Bool" },
{ "name": "SpeedSetpoint", "type": "Real" }
],
"output": [
{ "name": "Running", "type": "Bool" },
{ "name": "Speed", "type": "Real" }
]
},
"code": "#Running := #Start AND NOT #Stop;\nIF #Running THEN\n #Speed := #SpeedSetpoint;\nEND_IF;"
}Przykład 5: Utwórz blok SCL
Najpotężniejsze narzędzie — utwórz blok funkcyjny z kodem SCL, typowanymi zmiennymi i pełną definicją interfejsu. AI może wygenerować ten kod na podstawie opisu wymagań w języku naturalnym.
{
"name": "create_scl_block",
"arguments": {
"deviceName": "PLC_1",
"blockName": "FB_ValveControl",
"blockType": "FB",
"interface": {
"input": [
{ "name": "Open", "type": "Bool" },
{ "name": "Close", "type": "Bool" },
{ "name": "Timeout", "type": "Time", "defaultValue": "T#5s" }
],
"output": [
{ "name": "IsOpen", "type": "Bool" },
{ "name": "IsClosed", "type": "Bool" },
{ "name": "Error", "type": "Bool" }
]
},
"sclCode": "IF #Open AND NOT #Close THEN\n #IsOpen := TRUE;\n #IsClosed := FALSE;\nELSIF #Close THEN\n #IsOpen := FALSE;\n #IsClosed := TRUE;\nEND_IF;"
}
}{
"name": "FB_ValveControl",
"type": "FB",
"number": 2,
"created": true
}Przykład 6: Zarządzanie tagami
Wyświetl tabele tagów, przeglądaj zmienne i twórz nowe tagi z właściwymi adresami i typami danych.
// List existing tags
{ "name": "list_tags", "arguments": {
"deviceName": "PLC_1",
"tableName": "Motors"
}
}
// Create a new tag
{ "name": "create_tag", "arguments": {
"deviceName": "PLC_1",
"tableName": "Motors",
"name": "Motor2_Start",
"dataType": "Bool",
"logicalAddress": "%I0.2"
}
}// list_tags response
[
{ "name": "Motor1_Start", "dataType": "Bool", "address": "%I0.0" },
{ "name": "Motor1_Stop", "dataType": "Bool", "address": "%I0.1" },
{ "name": "Motor1_Running", "dataType": "Bool", "address": "%Q0.0" }
]
// create_tag response
{
"name": "Motor2_Start",
"dataType": "Bool",
"address": "%I0.2",
"created": true
}Przykład 7: Kompilacja
Uruchom kompilację urządzenia, aby zweryfikować wygenerowany kod. Błędy i ostrzeżenia są zwracane, aby AI mógł automatycznie naprawić problemy.
{
"name": "compile_device",
"arguments": { "deviceName": "PLC_1" }
}{
"success": true,
"errors": [],
"warnings": [
"FB_ValveControl: Variable 'Timeout' declared but not used"
],
"warningCount": 1,
"errorCount": 0
}Przykład 8: Wyszukiwanie w katalogu sprzętowym
Przeszukaj katalog sprzętowy Siemens i dodaj urządzenia do swojego projektu — wszystko za pomocą języka naturalnego.
// Search the catalog
{ "name": "search_hardware_catalog", "arguments": {
"query": "CPU 1511"
}
}
// Add the device
{ "name": "add_device", "arguments": {
"deviceName": "PLC_2",
"typeIdentifier": "OrderNumber:6ES7 511-1AK02-0AB0/V2.9"
}
}// search_hardware_catalog response
[
{
"name": "CPU 1511C-1 PN",
"typeIdentifier": "OrderNumber:6ES7 511-1CK01-0AB0/V2.9",
"version": "V2.9"
},
{
"name": "CPU 1511-1 PN",
"typeIdentifier": "OrderNumber:6ES7 511-1AK02-0AB0/V2.9",
"version": "V2.9"
}
]
// add_device response
{
"name": "PLC_2",
"type": "CPU 1511-1 PN",
"added": true
}Przykład 9: Ekrany HMI
Wyświetlaj, twórz i sprawdzaj ekrany WinCC HMI. Pobierz pełny projekt XML do analizy.
// List screens
{ "name": "list_hmi_screens", "arguments": {
"deviceName": "HMI_1"
}
}
// Create a new screen
{ "name": "create_hmi_screen", "arguments": {
"deviceName": "HMI_1",
"screenName": "MotorOverview"
}
}// list_hmi_screens response
[
{ "name": "MainScreen", "type": "Screen" },
{ "name": "AlarmView", "type": "Screen" }
]
// create_hmi_screen response
{
"name": "MotorOverview",
"created": true
}Przykład 10: Zapisz, archiwizuj i zamknij
Pełne zarządzanie cyklem życia projektu — zapisz swoją pracę, utwórz kopie zapasowe archiwów i zamknij w sposób uporządkowany.
{ "name": "save_project", "arguments": {} }
{ "name": "archive_project", "arguments": {
"targetDirectory": "C:\TIA_Backups",
"archiveName": "WaterTreatment_backup_2026-03-11"
}
}
{ "name": "close_project", "arguments": {} }{ "saved": true }
{
"archivePath": "C:\TIA_Backups\WaterTreatment_backup_2026-03-11.zap19",
"size": "45.2 MB",
"created": true
}
{ "closed": true }Pełna dokumentacja narzędzi (31 narzędzi)
Oto pełna lista narzędzi MCP dostępnych w T-IA Connect, uporządkowana według kategorii.
Zarządzanie projektami
| Tool | Description | Parameters |
|---|---|---|
| get_project_status | Get current project status | — |
| list_project_files | Scan disk for TIA projects | path? |
| open_project | Open a .ap* project file | path |
| create_project | Create an empty TIA project | path, name |
| close_project | Close the active project | — |
| save_project | Save the current project | — |
| archive_project | Create a .zap backup | targetDirectory, archiveName |
| retrieve_project | Restore from .zap backup | archivePath, targetDirectory |
Sprzęt i sieci
| Tool | Description | Parameters |
|---|---|---|
| list_devices | List all devices (PLC, HMI) | — |
| search_hardware_catalog | Search Siemens hardware catalog | query |
| add_device | Add a device to the project | deviceName, typeIdentifier |
| delete_device | Remove a device | deviceName |
| rename_device | Rename a device | currentName, newName |
| configure_network | Set IP / subnet / gateway | deviceName, ipAddress, subnetMask, gateway |
Programowanie
| Tool | Description | Parameters |
|---|---|---|
| list_blocks | List all blocks (FB, FC, DB, OB) | deviceName |
| get_block_details | Read block interface and code | deviceName, blockName |
| create_scl_block | Create SCL block with interface | deviceName, blockName, sclCode, blockType, interface |
| delete_block | Delete a block | deviceName, blockName |
| rename_block | Rename a block | deviceName, currentName, newName |
| compile_device | Compile device code | deviceName |
HMI (WinCC)
| Tool | Description | Parameters |
|---|---|---|
| list_hmi_screens | List WinCC screens | deviceName |
| create_hmi_screen | Create an HMI screen | deviceName, screenName |
| delete_hmi_screen | Delete an HMI screen | deviceName, screenName |
| get_hmi_screen_xml | Get screen XML design | deviceName, screenName |
Dane i zmienne
| Tool | Description | Parameters |
|---|---|---|
| list_tag_tables | List tag tables | deviceName |
| create_tag_table | Create a tag table | deviceName, tableName |
| delete_tag_table | Delete a tag table | deviceName, tableName |
| list_tags | List variables in a table | deviceName, tableName |
| create_tag | Create a variable (I, Q, M) | deviceName, tableName, name, dataType, logicalAddress |
| delete_tag | Delete a variable | deviceName, tableName, tagName |
Diagnostyka systemu
| Tool | Description | Parameters |
|---|---|---|
| get_server_diagnostics | API & TIA Portal health check | — |
Bonus: Narzędzia FDS (specyfikacja projektowa)
T-IA Connect zawiera również 5 dodatkowych narzędzi MCP dla modułu FDS (Specyfikacja Projektu Funkcjonalnego). Szczegóły znajdziesz w dedykowanym poradniku.
Przewodnik generowania kodu SCL z CSVAI + PLC = Przyszłość inżynierii
Dzięki 31 narzędziom MCP, Twój asystent AI staje się prawdziwym partnerem inżynierskim — czyta Twój projekt, rozumie Twój sprzęt i pisze kod, który naprawdę się kompiluje. Koniec z wymyślonymi zmiennymi i ślepym generowaniem kodu.
Zacznij korzystać z T-IA Connect i przekształć swój przepływ pracy w TIA Portal.