Tutorial

Copilota IA: Strumenti MCP per TIA Portal

Lascia che gli agenti IA vedano il tuo progetto, conoscano le tue variabili e agiscano sul tuo PLC — tramite 31 strumenti appositamente progettati.

T
Team T-IA Connect
15 min di lettura
Aggiornato l'11 mar. 2026

Perché MCP cambia tutto

Gli assistenti IA classici (ChatGPT, Copilot) soffrono di un problema importante nell'automazione industriale: l'allucinazione contestuale. Generano codice SCL sintatticamente corretto, ma utilizzano variabili inesistenti, tipi di dati errati o ignorano la configurazione hardware. Con il server MCP integrato di T-IA Connect, l'IA può vedere il tuo progetto, leggere le tabelle dei tag, ispezionare i blocchi esistenti — e creare o modificare realmente il codice in TIA Portal.

Prerequisiti

  • T-IA Connect installato e in esecuzione
  • Un progetto TIA Portal aperto (V16–V21)
  • Un client IA compatibile con MCP (Claude Desktop o qualsiasi client MCP)

Configurazione: Collega la tua IA a TIA Portal

Aggiungi T-IA Connect come server MCP nel file di configurazione di Claude Desktop (claude_desktop_config.json):

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 funge da ponte stdio-to-HTTP. Inoltra le richieste dell'IA al server API di T-IA Connect che comunica con TIA Portal tramite Openness.

Esempio 1: Verificare lo stato del progetto

Lo strumento più semplice — verifica la connessione a TIA Portal e controlla quale progetto è aperto.

MCP Tool: get_project_status
{
  "name": "get_project_status",
  "arguments": {}
}
Response
{
  "connected": true,
  "projectName": "WaterTreatment_V19",
  "projectPath": "C:\TIA_Projects\WaterTreatment_V19",
  "tiaVersion": "V19",
  "modified": false
}

Esempio 2: Aprire un progetto

Apri un file di progetto TIA Portal direttamente dall'IA. Puoi anche cercare i progetti disponibili su disco con list_project_files.

MCP Tool: open_project
{
  "name": "open_project",
  "arguments": {
    "path": "C:\TIA_Projects\WaterTreatment_V19\WaterTreatment_V19.ap19"
  }
}
Response
{
  "success": true,
  "projectName": "WaterTreatment_V19",
  "version": "V19"
}

Esempio 3: Elencare i dispositivi

Visualizza tutti i PLC, HMI e altri dispositivi nel progetto corrente.

MCP Tool: list_devices
{
  "name": "list_devices",
  "arguments": {}
}
Response
[
  {
    "name": "PLC_1",
    "type": "CPU 1516-3 PN/DP",
    "category": "PLC"
  },
  {
    "name": "HMI_1",
    "type": "TP1500 Comfort",
    "category": "HMI"
  }
]

Esempio 4: Elencare e leggere i blocchi

Esplora tutti i blocchi (FB, FC, DB, OB) di un PLC, poi leggi il codice completo e l'interfaccia di qualsiasi blocco.

MCP Tool: list_blocks → get_block_details
// 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"
  }
}
Response
// 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;"
}

Esempio 5: Creare un blocco SCL

Lo strumento più potente — crea un blocco funzione con codice SCL, variabili tipizzate e una definizione di interfaccia completa. L'IA può generare questo codice da una descrizione in linguaggio naturale dei tuoi requisiti.

MCP Tool: create_scl_block
{
  "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;"
  }
}
Response
{
  "name": "FB_ValveControl",
  "type": "FB",
  "number": 2,
  "created": true
}

Esempio 6: Gestire i tag

Elenca le tabelle dei tag, esplora le variabili e crea nuovi tag con indirizzi e tipi di dati corretti.

MCP Tools: list_tags → create_tag
// 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"
  }
}
Response
// 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
}

Esempio 7: Compilare

Avvia la compilazione di un dispositivo per validare il codice generato. Errori e avvisi vengono restituiti in modo che l'IA possa correggere automaticamente i problemi.

MCP Tool: compile_device
{
  "name": "compile_device",
  "arguments": { "deviceName": "PLC_1" }
}
Response
{
  "success": true,
  "errors": [],
  "warnings": [
    "FB_ValveControl: Variable 'Timeout' declared but not used"
  ],
  "warningCount": 1,
  "errorCount": 0
}

Esempio 8: Cercare nel catalogo hardware

Cerca nel catalogo hardware Siemens e aggiungi dispositivi al tuo progetto — tutto tramite linguaggio naturale.

MCP Tools: search_hardware_catalog → add_device
// 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"
  }
}
Response
// 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
}

Esempio 9: Schermate HMI

Elenca, crea e ispeziona le schermate WinCC HMI. Recupera il design XML completo per l'analisi.

MCP Tools: list_hmi_screens → create_hmi_screen
// List screens
{ "name": "list_hmi_screens", "arguments": {
    "deviceName": "HMI_1"
  }
}

// Create a new screen
{ "name": "create_hmi_screen", "arguments": {
    "deviceName": "HMI_1",
    "screenName": "MotorOverview"
  }
}
Response
// list_hmi_screens response
[
  { "name": "MainScreen", "type": "Screen" },
  { "name": "AlarmView", "type": "Screen" }
]

// create_hmi_screen response
{
  "name": "MotorOverview",
  "created": true
}

Esempio 10: Salvare, archiviare e chiudere

Gestione completa del ciclo di vita del progetto — salva il tuo lavoro, crea archivi di backup e chiudi in modo pulito.

MCP Tools: save → archive → close
{ "name": "save_project", "arguments": {} }

{ "name": "archive_project", "arguments": {
    "targetDirectory": "C:\TIA_Backups",
    "archiveName": "WaterTreatment_backup_2026-03-11"
  }
}

{ "name": "close_project", "arguments": {} }
Response
{ "saved": true }

{
  "archivePath": "C:\TIA_Backups\WaterTreatment_backup_2026-03-11.zap19",
  "size": "45.2 MB",
  "created": true
}

{ "closed": true }

Riferimento completo degli strumenti (31 strumenti)

Ecco l'elenco completo degli strumenti MCP disponibili in T-IA Connect, organizzati per categoria.

Gestione progetti

ToolDescriptionParameters
get_project_statusGet current project status
list_project_filesScan disk for TIA projectspath?
open_projectOpen a .ap* project filepath
create_projectCreate an empty TIA projectpath, name
close_projectClose the active project
save_projectSave the current project
archive_projectCreate a .zap backuptargetDirectory, archiveName
retrieve_projectRestore from .zap backuparchivePath, targetDirectory

Hardware e reti

ToolDescriptionParameters
list_devicesList all devices (PLC, HMI)
search_hardware_catalogSearch Siemens hardware catalogquery
add_deviceAdd a device to the projectdeviceName, typeIdentifier
delete_deviceRemove a devicedeviceName
rename_deviceRename a devicecurrentName, newName
configure_networkSet IP / subnet / gatewaydeviceName, ipAddress, subnetMask, gateway

Programmazione

ToolDescriptionParameters
list_blocksList all blocks (FB, FC, DB, OB)deviceName
get_block_detailsRead block interface and codedeviceName, blockName
create_scl_blockCreate SCL block with interfacedeviceName, blockName, sclCode, blockType, interface
delete_blockDelete a blockdeviceName, blockName
rename_blockRename a blockdeviceName, currentName, newName
compile_deviceCompile device codedeviceName

HMI (WinCC)

ToolDescriptionParameters
list_hmi_screensList WinCC screensdeviceName
create_hmi_screenCreate an HMI screendeviceName, screenName
delete_hmi_screenDelete an HMI screendeviceName, screenName
get_hmi_screen_xmlGet screen XML designdeviceName, screenName

Dati e variabili

ToolDescriptionParameters
list_tag_tablesList tag tablesdeviceName
create_tag_tableCreate a tag tabledeviceName, tableName
delete_tag_tableDelete a tag tabledeviceName, tableName
list_tagsList variables in a tabledeviceName, tableName
create_tagCreate a variable (I, Q, M)deviceName, tableName, name, dataType, logicalAddress
delete_tagDelete a variabledeviceName, tableName, tagName

Diagnostica di sistema

ToolDescriptionParameters
get_server_diagnosticsAPI & TIA Portal health check

Bonus: Strumenti FDS (Specifica di progetto)

T-IA Connect include anche 5 strumenti MCP aggiuntivi per il modulo FDS (Specifica di progetto funzionale). Consulta il tutorial dedicato per i dettagli.

Guida alla generazione di codice SCL da CSV

IA + PLC = Il futuro dell'ingegneria

Con 31 strumenti MCP, il tuo assistente IA diventa un vero partner ingegneristico — legge il tuo progetto, comprende il tuo hardware e scrive codice che compila davvero. Niente più variabili inventate o generazione di codice alla cieca.

Inizia con T-IA Connect e trasforma il tuo flusso di lavoro in TIA Portal.