WHY: connect_to_device and download_to_device against a password-protected runtime pop a modal "Device User Login" dialog in the IDE. IronPython can't marshal to the WPF UI thread to dismiss it, so headless / agent-driven sessions block forever -- and even for interactive use, the dialog pops on EVERY download, which is a constant friction point. API: ScriptOnline.set_default_credentials(username, password) was added in CODESYS scripting API 3.5.3.0. Effect lasts until end of the current script execution. Source: https://content.helpme-codesys.com/en/ScriptingEngine/ScriptOnline.html Implementation: - New helper script src/scripts/register_device_credentials.py defines a register_device_credentials_if_set() function that no-ops when DEVICE_USER or DEVICE_PASSWORD is empty, gracefully skips on older SPs that lack set_default_credentials, and never raises (always falls back to the current dialog-prompting behaviour). - connect_to_device.py and download_to_device.py call the helper as the FIRST action inside their try blocks, before ensure_project_open and any login() attempt, so credentials are registered before any code path that could trigger the dialog. - server.ts adds optional deviceUser / devicePassword args to both tools' input schemas. Resolution order: args.deviceUser (per-call override) -> process.env.CODESYS_DEVICE_USER -> '' (empty, dialog pops as before) Same for devicePassword. Env-var path is the recommended config: claude mcp add -s user codesys-sp22-patch1 \ -e CODESYS_DEVICE_USER=Karstein \ -e CODESYS_DEVICE_PASSWORD=codesys123 \ -- codesys-mcp-sp21-plus --codesys-path ... --codesys-profile ... \ --mode persistent --no-auto-launch Backward compat: when both creds are empty (default for existing users), the helper short-circuits and behaviour is byte-identical to 0.5.x. No regression. Verified by smoke-testing prepareScriptWithHelpers locally with both filled and empty inputs -- function definition + callsite are both wired in either case; only set_default_credentials() is suppressed when empty. README updated for connect_to_device and download_to_device tool rows. Version bumped 0.5.0 -> 0.6.0.
54 lines
1.6 KiB
JSON
54 lines
1.6 KiB
JSON
{
|
|
"name": "codesys-mcp-sp21-plus",
|
|
"version": "0.6.0",
|
|
"description": "Codesys-MCP-SP21+ -- fork of luke-harriman/Codesys-MCP carrying CODESYS V3.5 SP22 Patch 1 fixes (and forward-compat with later SPs): script-engine API drift, online/runtime tool auto-login, dual-SHA release classifier, set_pou_code omitted-decl wipe fix, add_library managed-overload, etc. MCP server for CODESYS with persistent UI instance and file-based IPC.",
|
|
"main": "dist/server.js",
|
|
"bin": {
|
|
"codesys-mcp-sp21-plus": "dist/bin.js"
|
|
},
|
|
"files": [
|
|
"dist/",
|
|
"README.md",
|
|
"LICENSE"
|
|
],
|
|
"scripts": {
|
|
"build": "tsc && node -e \"require('fs').cpSync('src/scripts','dist/scripts',{recursive:true})\"",
|
|
"test": "vitest --run",
|
|
"test:watch": "vitest",
|
|
"typecheck": "tsc --noEmit",
|
|
"prepublishOnly": "npm run build && npm test"
|
|
},
|
|
"keywords": [
|
|
"codesys",
|
|
"mcp",
|
|
"plc",
|
|
"automation",
|
|
"persistent",
|
|
"ui"
|
|
],
|
|
"author": "luke-harriman (upstream); phobicdotno (SP21+ fork)",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "https://github.com/phobicdotno/Codesys-MCP-SP21-plus.git"
|
|
},
|
|
"homepage": "https://github.com/phobicdotno/Codesys-MCP-SP21-plus#readme",
|
|
"license": "MIT",
|
|
"engines": {
|
|
"node": ">=18"
|
|
},
|
|
"dependencies": {
|
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
"commander": "^11.1.0",
|
|
"ssh2": "^1.17.0",
|
|
"uuid": "^9.0.0",
|
|
"zod": "^3.24.3"
|
|
},
|
|
"devDependencies": {
|
|
"@types/node": "^20.14.1",
|
|
"@types/ssh2": "^1.15.5",
|
|
"@types/uuid": "^9.0.0",
|
|
"tsx": "^4.21.0",
|
|
"typescript": "^5.5.3",
|
|
"vitest": "^1.6.0"
|
|
}
|
|
}
|