0
0
Fork 0

mirror_export: default mirror root to <projectDir>/mcp-mirror

Drops the redundant MCP/ folder layer. Previous default put the
mirror at <projectDir>/MCP/mirror -- two levels deep with a folder
called "MCP" containing exactly one item called "mirror". After
real-world usage (X33 layout reorg this session) the cleaner default
is <projectDir>/mcp-mirror -- one level, descriptive name.

Existing X33 layout was already migrated:
  X33/MCP/mirror/  ->  X33/mcp-mirror/      (renamed)
  X33/MCP/library.md  ->  X33/library.md    (moved up)
  X33/MCP/pou-dump.md  ->  X33/pou-dump.md  (moved up)

Tool description and the mirrorRoot arg description updated to match.
This commit is contained in:
Karstein Phobic Nyvold Kvistad 2026-04-25 23:29:11 +02:00
parent 76b7cf485a
commit 0a4c1a0de8

View file

@ -1350,16 +1350,16 @@ export async function startMcpServer(config: ServerConfig): Promise<void> {
s.tool(
'mirror_export',
"Walks the CODESYS project tree and writes one .st file per code-bearing object into a filesystem mirror, preserving the project tree as nested directories. Programs / Function Blocks / Functions / Methods / Properties / DUTs / GVLs / Interfaces all become text files; structural nodes (Devices, Applications, Folders) become directories. Each file carries a header comment with its original CODESYS project path so a future write-back tool can map it back to set_pou_code's pouPath. Read-only -- does NOT modify the CODESYS project. UTF-8 output. If mirrorRoot is omitted, defaults to '<projectDir>/MCP/mirror'.",
"Walks the CODESYS project tree and writes one .st file per code-bearing object into a filesystem mirror, preserving the project tree as nested directories. Programs / Function Blocks / Functions / Methods / Properties / DUTs / GVLs / Interfaces all become text files; structural nodes (Devices, Applications, Folders) become directories. Each file carries a header comment with its original CODESYS project path so a future write-back tool can map it back to set_pou_code's pouPath. Read-only -- does NOT modify the CODESYS project. UTF-8 output. If mirrorRoot is omitted, defaults to '<projectDir>/mcp-mirror'.",
{
projectFilePath: z.string().describe("Path to the project file."),
mirrorRoot: z.string().optional().describe("Filesystem path where the mirror tree gets written. If omitted, defaults to '<projectDir>/MCP/mirror'. Created automatically if missing; existing files at the same paths are overwritten."),
mirrorRoot: z.string().optional().describe("Filesystem path where the mirror tree gets written. If omitted, defaults to '<projectDir>/mcp-mirror'. Created automatically if missing; existing files at the same paths are overwritten."),
},
async (args: { projectFilePath: string; mirrorRoot?: string }) => {
const escaped = resolvePath(args.projectFilePath, workspaceDir);
const mirrorRoot = args.mirrorRoot
? resolvePath(args.mirrorRoot, workspaceDir)
: path.join(path.dirname(escaped), 'MCP', 'mirror');
: path.join(path.dirname(escaped), 'mcp-mirror');
const script = scriptManager.prepareScriptWithHelpers(
'mirror_export',
{