S7 MCP Bridge 是一个连接AI代理到西门子工业PLC(特别是S7-1500和S7-1200型号)的MCP服务器。这使得AI代理能够通过发送命令和接收数据来自动监控和控制工业设备。
Api-Login, Api-Logout, Api-ChangePassword)Api-Ping)Api-GetPermissions)Api-Version)Api-Browse)Api-GetQuantityStructures)Api-GetPasswordPolicy)PlcProgram-Browse)PlcProgram-Read)PlcProgram-Write)Plc-ReadOperatingMode)Plc-RequestChangeOperatingMode)Plc-ReadSystemTime)Plc-SetSystemTime)Project-ReadLanguages)Alarms-Browse)Alarms-Acknowledge)DiagnosticBuffer-Browse)List-AvailablePlcs)Plc-CreateBackup)Api-CloseTicket)此服务器使用环境变量进行配置。
env variables:export PLC_IP_ADDRESSES="192.168.2.200, 192.168.2.201, 192.168.2.202"
export PLC_NAMES="PLC1, PLC2, PLC3" //可选
export MCP_SERVER_PORT=57001 //可选
export TRANSPORT="http-stream" //可选
导航到项目文件夹:
cd s7-mcp-bridge
npm install
npm run build
如上所示编辑环境变量。
启动服务器
npm run start
可以在https://hub.docker.com/r/cadugrillo/s7-mcp-bridge/tags找到Docker容器镜像。
docker run -d -p 57001:57001 -p 57002:57002 -m 512m --memory-swap=512m \
--name s7McpBridge \
-e MCP_SERVER_PORT=57001 \
-e PLC_IP_ADDRESSES="192.168.2.200, 192.168.2.201, 192.168.2.202" \
-e PLC_NAMES="PLC1, PLC2, PLC3" \
cadugrillo/s7-mcp-bridge:latest
请根据您的部署更改端口。 当TRANSPORT设置为“http-stream”时,在http://<server-ip-address>:[MCP_SERVER_PORT +1]/status有一个状态页面。
| PLC_IP_ADDRESSES | 必需 | 以逗号分隔的可用PLC的IP地址,例如:"192.168.1.10, 192.168.1.20" |
| PLC_NAMES | 可选 | 以逗号分隔的可用PLC的名称,例如:"Machine1, Machine2" |
| MCP_SERVER_PORT | 可选 | 如果未设置,默认为57001,状态页面在http://<server-ip-address>:57002/status |
| TRANSPORT | 可选 | 可以是"http-stream"或"stdio"。如果未设置,默认为http-stream |
或者作为Docker容器运行,选择其中一个选项(stdio或http-stream):
{
"mcpServers": {
"S7-MCP-Bridge": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"PLC_IP_ADDRESSES=192.168.2.200, 192.168.2.201, 192.168.2.202",
"-e",
"PLC_NAMES=PLC1, PLC2, PLC3",
"-e",
"TRANSPORT=stdio",
"cadugrillo/s7-mcp-bridge:latest"
]
}
}
}
{
"mcpServers": {
"S7-MCP-Bridge": {
"command": "npx",
"args": ["mcp-remote", "http://localhost:57001/mcp"]
}
}
}
{
"mcpServers": {
"S7-MCP-Bridge": {
"command": "node",
"args": ["path/to/your/index.js"], //对于Windows用户,请正确转义路径(例如:C:\\path\\to\\your\\index.js)
"env": {
"PLC_IP_ADDRESSES":"192.168.2.200, 192.168.2.201, 192.168.2.202",
"PLC_NAMES":"PLC1, PLC2, PLC3",
"TRANSPORT": "stdio"
}
}
}
}