Logotipo de TIA-Portal MCP-Server

TIA-Portal MCP-Server

Comunidad
heilingbrunner

A Visual Studio Code extension to connect to Siemens TIA Portal and interact with TIA Portal projects directly from VS Code with GitHub Copilot.

Editorheilingbrunner
Repositoriotiaportal-mcp
IdiomaC#
Forks
40
Estrellas
100
Herramientas disponibles
0
Tipo de transportestdio
Categorías
LicenciaMIT
Enlaces
  • Conecta herramientas a flujos de trabajo con IA

    TIA-Portal MCP-Server ofrece funciones MCP que pueden usar los clientes y agentes de IA compatibles.

  • 0 herramientas disponibles

    Explora a continuación las acciones que se pueden invocar, con sus nombres y descripciones cuando el servidor los proporcione.

  • Configuración lista para copiar

    Usa los ejemplos de instalación para configurar este servidor en tu cliente MCP preferido.

  • Indicadores de interés en el código abierto

    100 estrellas y 40 forks en el repositorio enlazado.

TIA-Portal MCP-Server

A MCP server which connects to Siemens TIA Portal.

Features

  • Connect to a TIA Portal instance
  • Browse and interact with TIA Portal projects
  • Perform basic project operations from within VS Code
  • Read the full PLC software: program blocks, PLC data types, tags and constants, watch and force tables, external source files, and cross references
  • Optionally create, rename, delete, move and import project objects (see Write mode)

Command Line Arguments

ArgumentDescription
--tia-major-version <n>TIA Portal major version to bind against. Default 21.
--logging <1|2|3>1 stderr, 2 debug output, 3 Windows event log. Omit for no logging.
--doctorPrint the environment report and exit without starting the MCP server.
--allow-writeRegister the project-mutating tools. Omitted by default; see below.

Write mode

The server is read-only unless it is started with --allow-write.

  • Without the flag the 37 project-mutating tools are not registered at all, so they never appear in tools/list. A model cannot call what it cannot see, and the tool list stays small.
  • With the flag they are registered and annotated destructiveHint: true, so a client can still prompt before each call.
  • GetState and the --doctor report both expose AllowWrite, so a client can tell whether the tools are missing by configuration rather than by version.
  • Write operations change the project in memory only. Every write response says so and names the tool that persists it: SaveProject, or SaveSession when a multiuser local session is open.

Export tools are intentionally not gated. ExportBlock, ExportTagTable, ExportWatchTable and friends only write files on the machine running the server; they never modify the project. They are annotated destructiveHint: true because they can overwrite files on disk.

To enable write mode, add the argument to your client configuration, for example "args": ["--allow-write"].

Tools

Read-only tools (59) are always available.

AreaTools
Portal and stateConnect, Disconnect, GetState, Doctor
Project and sessionGetProject, OpenProject, SaveProject, SaveAsProject, CloseProject
DevicesGetProjectTree, GetDevices, GetDeviceInfo, GetDeviceItemInfo
PLC softwareGetSoftwareInfo, GetSoftwareTree, CompileSoftware
BlocksGetBlocks, GetBlockInfo, GetBlocksWithHierarchy, ExportBlock, ExportBlocks, ImportBlock
TypesGetTypes, GetTypeInfo, ExportType, ExportTypes, ImportType
Tags and constantsGetTagTables, GetTagTableInfo, GetTags, GetTagInfo, GetConstants, ExportTagTable
Watch and force tablesGetWatchTables, GetWatchTableInfo, GetForceTables, ExportWatchTable
External sourcesGetExternalSources, GetExternalSourceInfo, GenerateBlockSource, GenerateTypeSource
Cross referencesGetCrossReferences
Block documents (V20+)ExportAsDocuments, ExportBlocksAsDocuments, ImportFromDocuments, ImportBlocksFromDocuments
Type documents (V21+)ExportTypeAsDocuments, ExportTypesAsDocuments
Understand and read (comfort)GetPlcSummary, ResolveObjectPath, WhereUsed, FindInCode, GetBlockSource, GetTypeSource, GetBlockInterface, PreviewImport, OpenTiaProject, ExportPlcAsSourceTree, GenerateSources

Write tools (40) require --allow-write.

AreaTools
Block and type groupsCreateBlockGroup, DeleteBlockGroup, CreateTypeGroup, DeleteTypeGroup
Blocks and typesDeleteBlock, RenameBlock, DeleteType, RenameType, CreateFB, CreateInstanceDB
Copy and moveCopyBlock, MoveBlock, CopyType, MoveType
Tag tablesCreateTagTable, DeleteTagTable, RenameTagTable, CreateTagTableGroup, DeleteTagTableGroup, ImportTagTable
Tags and constantsCreateTag, UpdateTag, DeleteTag, CreateUserConstant, UpdateUserConstant, DeleteUserConstant
Watch tablesCreateWatchTable, RenameWatchTable, DeleteWatchTable, CreateWatchTableGroup, DeleteWatchTableGroup, ImportWatchTable
External sourcesCreateExternalSourceFromFile, DeleteExternalSource, CreateExternalSourceGroup, DeleteExternalSourceGroup, GenerateBlocksFromSource, ImportSources
Type documents (V21+)ImportTypeFromDocuments, ImportTypesFromDocuments

GetSoftwareTree accepts a sections argument - any comma separated subset of blocks,types,tags,watch,sources, default all - to keep the output small on a large PLC. GetCrossReferences accepts maxDepth (1-3, default 1) for the same reason.

Paths used by these tools are root-relative: 1_Tests/FC_Block_1, not Program blocks/1_Tests/FC_Block_1. Use GetProjectTree and GetSoftwareTree to discover them.

Resources

Requirements

  • .net Framework 4.8 installed
  • Siemens TIA Portal V21 installed and running on your machine
  • Check if under Environment Variables/User variable for user <name> the variable TiaPortalLocation is set to C:\Program Files\Siemens\Automation\Portal V21
  • User must be in Windows User Group Siemens TIA Openness

Diagnose the environment

Run the server with --doctor to check all of the above without starting the MCP server:

text
> TiaMcpServer.exe --doctor
Diagnose:
├─ Connected = False
├─ Project: No project open
├─ Active Version: V21
├─ Installed TIA Portal versions:
│  └─ V21: C:\Program Files\Siemens\Automation\Portal V21
│     ├─ Engineering: OK
│     └─ Portal:      OK
├─ User in 'Siemens TIA Openness' user group: True
└─ Write mode (--allow-write): disabled, read-only tools only

The same report is available to MCP clients through the Doctor tool, which additionally returns the findings as structured content. Both are read-only: they never connect to TIA Portal, open a project, or change user group membership.

TIA-Portal Versions

  • V21 is the default version.
  • Previous versions are also supported, but must use the --tia-major-version argument to specify the version.
  • Export as documents (.s7dcl/.s7res) via ExportAsDocuments/ExportBlocksAsDocuments requires TIA Portal V20 or newer.
  • Import from documents (.s7dcl/.s7res) via ImportFromDocuments/ImportBlocksFromDocuments also requires TIA Portal V20 or newer.
  • The same for PLC data types - ExportTypeAsDocuments, ExportTypesAsDocuments, ImportTypeFromDocuments, ImportTypesFromDocuments - requires TIA Portal V21 or newer: Openness only added PlcType.ExportAsDocuments and PlcTypeComposition.ImportFromDocuments in V21.

SIMATIC Source Documents

A source document is the readable, git-diffable form of an object: <Name>.s7dcl holds the declaration and body as SCL/LAD/STL text, the optional <Name>.s7res holds comments and language resources. Every other export in this server writes SimaticML XML instead, which diffs poorly.

The file names come from TIA Portal, not from this server: an export response lists the files that were actually written, and a batch import discovers a document set by base name rather than assuming one extension. Tag tables and watch tables have no document API in Openness V21 and remain XML-only.

With preservePath the export mirrors the project tree below the system folder - Program blocks for blocks, PLC data types for types - using the folder name as TIA Portal reports it in the current interface language. ImportTypeFromDocuments and ImportTypesFromDocuments accept that folder name back as a leading segment of groupPath, so an export can be fed straight back in.

A PLC data type name is unique across the whole PLC, not just within its group. Importing a name that already exists into a different group therefore fails with "an object with the name ... already exists in the plc", even with importOption: Override; point groupPath at the group the type already lives in to replace it.

Known Limitations

  • As of 2025-09-02: Importing Ladder (LAD) blocks from SIMATIC SD documents requires the companion .s7res file to contain en-US tags for all items; otherwise import may fail. This is a known limitation/bug in TIA Portal Openness.
  • ExportBlock requires a fully qualified blockPath like Group/Subgroup/Name. If only a name is provided, the tool fails with an error result that may include suggestions for likely full paths.

Limits imposed by the Openness API itself

These are not gaps in this server - the underlying API offers no operation for them.

  • No move or copy for blocks and types. CopyBlock, MoveBlock, CopyType and MoveType are composed from export, import and (for a move) deleting the source once the import succeeds. Two consequences are visible: the object must be consistent, because TIA Portal refuses to export an inconsistent one, and its block number travels with it, so importing into the same PLC can hit a number collision. Renaming during a copy is not offered - it would mean rewriting the exported XML.
  • No generic "create block". Only CreateFB and CreateInstanceDB exist; every other kind of block has to arrive through ImportBlock.
  • Read-only objects. System constants cannot be created or changed, the force table cannot be created or deleted (the system owns one per PLC), the default tag table cannot be deleted, and the system groups (Program blocks, PLC data types, PLC tags, ...) cannot be renamed or deleted. These all fail with a NotSupported message rather than an opaque Openness error.
  • No cross references for watch tables, force tables or external sources; GetCrossReferences reports NotSupported for them.
  • Watch table entries cannot be created or deleted through this server yet. The Openness composition holding them exposes only a comment-row creator, so adding a real entry needs an untyped creation call whose required attribute names must first be read from the live API.
  • Safety programs. F-blocks and safety tags reject most edits, sometimes requiring the safety password. The server does not pre-guess Siemens' rules: the underlying error is passed through with its original message.
  • Know-how protected blocks and types are rejected before any edit, with a message asking you to remove the protection in TIA Portal first.

Testing

  • See tests/TiaMcpServer.Test/README.md for environment prerequisites and test asset setup.
  • Standard command: dotnet test (run from the repo root).
  • Test execution policy: offer to run tests, but only execute after explicit user confirmation. Details in AGENTS.md.

Contributing

  • See agents.md for guidance on working with agentic assistants and the test execution policy (offer to run tests only with explicit user confirmation).

Error Handling

  • The Portal layer throws PortalException with a short message and PortalErrorCode (NotFound, InvalidParams, InvalidState, ExportFailed, ImportFailed, CreateFailed, DeleteFailed, RenameFailed, NotSupported, WriteDisabled), and attaches softwarePath, blockPath, exportPath in Exception.Data while preserving InnerException on export failures.
  • The MCP layer rethrows these as McpException. Since SDK 2.x, an McpException thrown from a tool is returned to the client as a CallToolResult with isError: true and the message as text content, rather than as a JSON-RPC error, so the model can read the reason and self-correct. For ExportFailed the message includes a concise reason from the underlying error; for NotFound it may suggest likely full block paths if a bare name was provided.
  • Consistency required: TIA Portal never exports inconsistent blocks/types. Single export returns InvalidParams with a message to compile first. Bulk export skips inconsistent items and returns them in an Inconsistent list alongside Items.
  • Standardization: Exception context metadata is attached in a single catch per portal method right before rethrow, not at inline throw sites. See docs/error-model.md.
  • Since 0.2.0 this is implemented once, in the Operation.Run helper, which every portal method added for tags, watch tables, external sources, cross references and the write operations routes through. The older export/import methods still carry their hand-written equivalent of the same block; migrating them is tracked in TODO.md.
  • Operation.Run also serializes all Openness calls behind a lock. Openness objects are not thread-safe and the MCP SDK may dispatch tool calls concurrently; with write tools enabled an unsynchronized race could corrupt project state rather than merely return stale data.

MCP Protocol

  • Built on the ModelContextProtocol .NET SDK 2.2.0.
  • Protocol revisions negotiated during initialize: 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25 (the SDK picks the highest the client also supports).
  • Every tool advertises a human-readable title and behaviour annotations (readOnlyHint, destructiveHint, idempotentHint, openWorldHint).
  • 27 read tools and all 37 write tools publish an outputSchema and return structuredContent.
  • Long-running export/import tools report progress via notifications/progress when the client supplies a progressToken.
  • Tool failures are returned as tool results with isError: true (not JSON-RPC errors), so the model can read the message and retry.

Transports

  • Supported today: stdio
    • Program wires AddMcpServer().WithStdioServerTransport().
    • For stdio, logs must go to stderr to avoid corrupting JSON-RPC.
  • Available via SDK: stream (custom streams)
    • The SDK exposes WithStreamServerTransport(Stream input, Stream output) which can be used to host over TCP sockets or other streams.
    • Not wired in this repo yet.
  • HTTP/Streamable HTTP: not implemented yet
    • ModelContextProtocol 2.2.0 ships its Streamable HTTP server transport in ModelContextProtocol.AspNetCore, which targets .NET 8+.
    • This server targets net48 (required by TIA Openness), so Streamable HTTP cannot be hosted from this process.
    • A separate .NET 8+ proxy process would be required to expose this server over HTTP.

Copilot Chat

  • Example mcp.json, when using VS Code extension TIA-Portal MCP-Server and TIA-Portal V18
    json
    {
        "servers": {
            "vscode-tiaportal-mcp": {
            "command": "c:\\Users\\<user>\\.vscode\\extensions\\jheilingbrunner.vscode-tiaportal-mcp-<version>\\srv\\net48\\TiaMcpServer.exe",
            "args": [
                "--tia-major-version",
                "18"
            ],
            "env": {}
            }
        }
    }

Claude Desktop

  • Create/Edit to add/remove server to C:\Users\<user>\AppData\Roaming\Claude\claude_desktop_config.json:

    json
    {
      "mcpServers": {
        "vscode-tiaportal-mcp": {
          "command": "<path-to>\\TiaMcpServer.exe",
          "args": [],
          "env": {}
        }
      }
    }

Instalación

TypingMind
{
  "mcpServers": {
    "tiaportal-mcp": {
      "command": "TiaMcpServer.exe",
      "args": [
        "--tia-major-version",
        "21"
      ]
    }
  }
}

Usa el MCP de TIA-Portal MCP-Server con varios modelos de IA

TypingMind conecta las herramientas MCP a nivel del espacio de trabajo, por lo que, una vez conectado TIA-Portal MCP-Server, puedes usarlo con distintos modelos de IA en TypingMind sin tener que configurarlo por separado para cada modelo. Esta integración MCP se ejecuta localmente en tu dispositivo a través del conector MCP de TypingMind.

Guía de configuración para usar el conector local

Usa esta opción si el servidor MCP necesita acceder a archivos locales, aplicaciones o recursos privados de tu ordenador.

1

Abre los ajustes de MCP

En TypingMind, ve a Ajustes, luego a Ajustes avanzados y a Model Context Protocol, y elige Configurar conector.

  1. Abre TypingMind en tu navegador.
  2. Haz clic en el icono de Ajustes.
  3. Ve a Ajustes avanzados.
  4. Abre la sección Model Context Protocol.
  5. Haz clic en Configurar conector y elige Este dispositivo.
Pantalla de configuración del conector MCP de TypingMind con «Este dispositivo» seleccionado
2

Ejecuta el comando del conector

Elige Este dispositivo, copia el comando de TypingMind y ejecútalo en Terminal. Mantén el proceso en ejecución mientras uses MCP.

  1. Copia el comando de configuración que muestra TypingMind.
  2. Abre Terminal en macOS o Windows Terminal en Windows.
  3. Pega y ejecuta el comando.
  4. Acepta la instalación del paquete si Terminal te pide confirmación para continuar.
  5. Mantén el proceso en ejecución en la ventana de Terminal mientras uses las herramientas MCP.
3

Añade TIA-Portal MCP-Server como servidor

Cuando el estado del conector sea «Listo», haz clic en «Edita servidores» y pega la configuración del servidor MCP.

  1. Espera hasta que el estado del conector indique «Listo».
  2. Haz clic en Edita servidores.
  3. Pega la configuración del servidor MCP de TIA-Portal MCP-Server.
  4. Guarda la lista de servidores.
  5. Actualiza para comprobar que el conector sigue listo.
Ajustes de MCP de TypingMind con un servidor activo y el botón «Edita servidores»
{
  "mcpServers": {
    "tiaportal-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Úsala con distintos modelos

Guarda la lista de servidores, abre Plugins, activa las herramientas MCP de TIA-Portal MCP-Server y selecciona cualquier modelo de IA compatible en TypingMind para usar las herramientas en el chat o asignárselas a un agente de IA.

  1. Abre la página Plugins en TypingMind.
  2. Activa las herramientas MCP de TIA-Portal MCP-Server.
  3. Inicia un chat y elige el modelo de IA que quieras usar.
  4. Usa las herramientas MCP en el chat o asígnalas a un agente de IA.
  5. Cambia a otro modelo de IA cuando lo necesites sin volver a conectar MCP.
Chat de TypingMind que usa herramientas MCP activadas con un modelo de IA seleccionado
¿Puedes usar TIA-Portal MCP-Server para ayudarme con esta tarea?
TIA-Portal MCP-Server
Claro. Lo he leído.
Esto he encontrado usando TIA-Portal MCP-Server.

Preguntas frecuentes

¿Para qué sirve el servidor MCP TIA-Portal MCP-Server?

TIA-Portal MCP-Server es un servidor MCP que permite a los clientes de IA compatibles conectarse a herramientas y contexto externos. En TypingMind, basta con añadir este servidor MCP una vez para que sus herramientas estén disponibles en tu espacio de trabajo de IA.

¿Puedo usar el servidor MCP TIA-Portal MCP-Server con varios modelos de IA en TypingMind?

Sí. TypingMind conecta las herramientas MCP a nivel del espacio de trabajo, por lo que puedes usar TIA-Portal MCP-Server con distintos modelos de IA, como Claude, ChatGPT, Gemini u otros que hayas configurado en TypingMind, sin configurar el servidor MCP por separado para cada modelo.

¿Por qué usar el conector MCP de TIA-Portal MCP-Server con TypingMind?

TypingMind es una de las mejores interfaces de chat con LLM porque reúne varios modelos de IA, prompts, plugins, agentes de IA, claves de API y herramientas MCP en un solo espacio de trabajo. Con TIA-Portal MCP-Server conectado, puedes usar sus herramientas MCP con tus modelos preferidos y mantener organizado tu flujo de trabajo de chat en TypingMind.

¿Cómo conecto el servidor MCP TIA-Portal MCP-Server a TypingMind?

TIA-Portal MCP-Server funciona a través del conector MCP local de TypingMind. Es la mejor opción cuando el servidor MCP necesita acceder a archivos locales, aplicaciones de escritorio, herramientas de línea de comandos o recursos privados de tu ordenador.

¿Qué herramientas ofrece el servidor MCP TIA-Portal MCP-Server en TypingMind?

TIA-Portal MCP-Server ofrece funciones MCP que puedes activar desde la página Plugins de TypingMind y usar en el chat o asignar a agentes de IA.

¿Tengo que compartir mis claves de API con TypingMind para usar el servidor MCP TIA-Portal MCP-Server?

No. TypingMind prioriza el funcionamiento local y te permite mantener el control de tus proveedores de modelos, claves de API, prompts y configuración MCP. Si TIA-Portal MCP-Server requiere autenticación, añade las cabeceras, los ajustes de OAuth o la configuración local necesarios para ese servidor MCP al crear la conexión.

Servidores MCP relacionados

Ver todos

Crea ya tu propio espacio de trabajo IA

Suscríbete a nuestro boletín para recibir avisos sobre nuevas funciones y próximos sorteos 👇