feat: implement n8n integration improvements and protocol version negotiation
- Add intelligent protocol version negotiation (2024-11-05 for n8n, 2025-03-26 for standard clients) - Fix memory leak potential with async cleanup and connection close handling - Enhance error sanitization for production environments - Add schema validation for n8n nested output workaround - Improve Docker security with unpredictable UIDs/GIDs - Create n8n-friendly tool descriptions to reduce schema validation errors - Add comprehensive protocol negotiation test suite Addresses code review feedback: - Protocol version inconsistency resolved - Memory management improved - Error information leakage fixed - Docker security enhanced 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,11 @@ import { isN8nApiConfigured } from './config/n8n-api';
|
||||
import dotenv from 'dotenv';
|
||||
import { readFileSync } from 'fs';
|
||||
import { getStartupBaseUrl, formatEndpointUrls, detectBaseUrl } from './utils/url-detector';
|
||||
import {
|
||||
negotiateProtocolVersion,
|
||||
logProtocolNegotiation,
|
||||
N8N_PROTOCOL_VERSION
|
||||
} from './utils/protocol-version';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@@ -342,10 +347,20 @@ export async function startFixedHTTPServer() {
|
||||
|
||||
switch (jsonRpcRequest.method) {
|
||||
case 'initialize':
|
||||
// Negotiate protocol version for this client/request
|
||||
const negotiationResult = negotiateProtocolVersion(
|
||||
jsonRpcRequest.params?.protocolVersion,
|
||||
jsonRpcRequest.params?.clientInfo,
|
||||
req.get('user-agent'),
|
||||
req.headers
|
||||
);
|
||||
|
||||
logProtocolNegotiation(negotiationResult, logger, 'HTTP_SERVER_INITIALIZE');
|
||||
|
||||
response = {
|
||||
jsonrpc: '2.0',
|
||||
result: {
|
||||
protocolVersion: '2024-11-05',
|
||||
protocolVersion: negotiationResult.version,
|
||||
capabilities: {
|
||||
tools: {},
|
||||
resources: {}
|
||||
|
||||
Reference in New Issue
Block a user