From ba7f8f9ea6cc8cc8a0ba1304066d5ac1aa7684f1 Mon Sep 17 00:00:00 2001 From: czlonkowski <56956555+czlonkowski@users.noreply.github.com> Date: Thu, 17 Jul 2025 21:17:35 +0200 Subject: [PATCH] fix: remove faulty auto-generated examples from MCP tools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove examples from get_node_essentials responses - Remove examples from validate_node_operation when errors occur - Update documentation to reflect removal of examples - Keep helpful format hints in get_node_for_task (different purpose) The auto-generated examples were misleading AI agents with incorrect configurations (e.g., Slack "channel" vs "select" property). Tools now focus on validation and error messages instead of examples. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- data/nodes.db | Bin 25972736 -> 25972736 bytes package-lock.json | 4 +- package.json | 2 +- src/mcp/server.ts | 6 +- .../configuration/get-node-essentials.ts | 68 ++++++----- src/services/enhanced-config-validator.ts | 113 +----------------- 6 files changed, 47 insertions(+), 146 deletions(-) diff --git a/data/nodes.db b/data/nodes.db index d1dc9b9ea46a0c4364ceeb2403f97f08698dfa6a..62e504ac996b70ce2e75de7ccb8460a4c4cbb164 100644 GIT binary patch delta 1979 zcmajg_jeR!7{&3K&60)9LJ}Ya0wj=x5FjM<-a_x8ceo@0mJ&h@T|#*XMS%daHi`v% zL&adl28xQthDuQpy9gFU1r_fle}FUR^PQddnV;sod!~5bfj}{BONdT%ocJS-6LZ3G zoD9cti%OfebQ4#@;2J!JFoV}n$q;Vv87dp982p9^L%>kgP|Xl&h%!VQsvBw;Y8qk; zv4%K9yrGt%wjse#$57W$&yZ+HGSoLTFeDpN45@~OhBQMXL%N}{p^2fXA;ZwjkZH&= zG&i&`v^2Cbv^KOcv^BIdv^R7xbTo7_bT)J`bTxD{bT?!hdKh{ddKr2f`WX5e`WgBg z1{ek!1{nq$h8S`TLk+_W!wn-0BMqYrqYYyWV-4dB;|&uG6AhCLlMQ@7Qw+I=JVU-= zs$rU8`auMbO^!J4S?cjuoMq97JmL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fh{w?~C=-mx!HmU&^lmR!C zg>n!9<)H#pgi7Fn$`A=&h=ORS0#%_J_#g&iAr7iT4Ty)DPzw?u5o$vns0&Gu4E3Ns zq(B2mg@(`w8bca1fplmJ&7e87fR>N}t)Mlufws^N+CvBE2%Vrabb+pr3EiMO^njkw z3wlEz=nMUzKMa6@FbJ|>FbsjAFbsyn2p9>Y%mE#33h?Zr28T-a1`LIB_XNyt? 0) { - this.addExamplesFromGenerator(nodeType, enhancedResult); - } + // Examples removed - use validate_node_operation for configuration guidance // Generate next steps based on errors enhancedResult.nextSteps = this.generateNextSteps(enhancedResult); @@ -253,16 +249,7 @@ export class EnhancedConfigValidator extends ConfigValidator { const { resource, operation } = result.operation || {}; if (resource === 'message' && operation === 'send') { - // Add example for sending a message - result.examples?.push({ - description: 'Send a simple text message to a channel', - config: { - resource: 'message', - operation: 'send', - channel: '#general', - text: 'Hello from n8n!' - } - }); + // Examples removed - validation focuses on error detection // Check for common issues if (!config.channel && !config.channelId) { @@ -274,15 +261,6 @@ export class EnhancedConfigValidator extends ConfigValidator { channelError.fix = 'Add channel: "#general" or use a channel ID like "C1234567890"'; } } - } else if (resource === 'user' && operation === 'get') { - result.examples?.push({ - description: 'Get user information by email', - config: { - resource: 'user', - operation: 'get', - user: 'user@example.com' - } - }); } } @@ -296,17 +274,7 @@ export class EnhancedConfigValidator extends ConfigValidator { const { operation } = result.operation || {}; if (operation === 'append') { - result.examples?.push({ - description: 'Append data to a spreadsheet', - config: { - operation: 'append', - sheetId: '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms', - range: 'Sheet1!A:B', - options: { - valueInputMode: 'USER_ENTERED' - } - } - }); + // Examples removed - validation focuses on configuration correctness // Validate range format if (config.range && !config.range.includes('!')) { @@ -327,33 +295,7 @@ export class EnhancedConfigValidator extends ConfigValidator { config: Record, result: EnhancedValidationResult ): void { - // Add common examples based on method - if (config.method === 'GET') { - result.examples?.push({ - description: 'GET request with query parameters', - config: { - method: 'GET', - url: 'https://api.example.com/users', - queryParameters: { - parameters: [ - { name: 'page', value: '1' }, - { name: 'limit', value: '10' } - ] - } - } - }); - } else if (config.method === 'POST') { - result.examples?.push({ - description: 'POST request with JSON body', - config: { - method: 'POST', - url: 'https://api.example.com/users', - sendBody: true, - bodyContentType: 'json', - jsonBody: JSON.stringify({ name: 'John Doe', email: 'john@example.com' }) - } - }); - } + // Examples removed - validation provides error messages and fixes instead } /** @@ -383,56 +325,13 @@ export class EnhancedConfigValidator extends ConfigValidator { steps.push('Consider addressing warnings for better reliability'); } - if (result.examples && result.examples.length > 0 && result.errors.length > 0) { - steps.push('See examples above for working configurations'); + if (result.errors.length > 0) { + steps.push('Fix the errors above following the provided suggestions'); } return steps; } - /** - * Add examples from ExampleGenerator to help fix validation errors - */ - private static addExamplesFromGenerator( - nodeType: string, - result: EnhancedValidationResult - ): void { - const examples = ExampleGenerator.getExamples(nodeType); - - if (!examples) { - return; - } - - // Add minimal example if there are missing required fields - if (result.errors.some(e => e.type === 'missing_required')) { - result.examples?.push({ - description: 'Minimal working configuration', - config: examples.minimal - }); - } - - // Add common example if available - if (examples.common) { - // Check if the common example matches the operation context - const { operation } = result.operation || {}; - const commonOp = examples.common.operation || examples.common.action; - - if (!operation || operation === commonOp) { - result.examples?.push({ - description: 'Common configuration pattern', - config: examples.common - }); - } - } - - // Add advanced example for complex validation errors - if (examples.advanced && result.errors.length > 2) { - result.examples?.push({ - description: 'Advanced configuration with all options', - config: examples.advanced - }); - } - } /** * Deduplicate errors based on property and type