mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-04-06 01:23:08 +00:00
fix: use stdio-wrapper as bin entry and preserve credentials on workflow update (v2.45.1) (#695)
Switch the npm bin entry from index.js to stdio-wrapper.js to prevent INFO-level logs from corrupting the JSON-RPC stdio transport. Also update both publish scripts so the fix persists across releases. Fixes #693. Preserve node credentials during full workflow updates. AI-generated node updates typically omit credential references, causing the n8n API to reject the PUT. The update handler now merges credentials from the current server-side workflow when user-provided nodes lack them. Fixes #689. Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
8888c63e7a
commit
ca20586eda
@@ -776,6 +776,28 @@ export async function handleUpdateWorkflow(
|
||||
const current = await client.getWorkflow(id);
|
||||
workflowBefore = JSON.parse(JSON.stringify(current));
|
||||
|
||||
// Preserve credentials from current workflow for nodes that don't specify them.
|
||||
// AI-generated node updates typically omit credential references because they
|
||||
// aren't included in the context provided to the AI. Without this merge, the
|
||||
// n8n API rejects the PUT with missing credentials.
|
||||
if (updateData.nodes && current.nodes) {
|
||||
const currentById = new Map<string, any>();
|
||||
const currentByName = new Map<string, any>();
|
||||
for (const node of current.nodes) {
|
||||
if (node.id) currentById.set(node.id, node);
|
||||
currentByName.set(node.name, node);
|
||||
}
|
||||
for (const node of updateData.nodes as any[]) {
|
||||
const hasCredentials = node.credentials && typeof node.credentials === 'object' && Object.keys(node.credentials).length > 0;
|
||||
if (!hasCredentials) {
|
||||
const match = (node.id && currentById.get(node.id)) || currentByName.get(node.name);
|
||||
if (match?.credentials) {
|
||||
node.credentials = match.credentials;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create backup before modifying workflow (default: true)
|
||||
if (createBackup !== false) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user