feat: add n8n integration with MCP Client Tool support
- Add N8N_MODE environment variable for n8n-specific behavior - Implement HTTP Streamable transport with multiple session support - Add protocol version endpoint (GET /mcp) for n8n compatibility - Support multiple initialize requests for stateless n8n clients - Add Docker configuration for n8n deployment - Add test script with persistent volume support - Add comprehensive unit tests for n8n mode - Fix session management to handle per-request transport pattern BREAKING CHANGE: Server now creates new transport for each initialize request when running in n8n mode to support n8n's stateless client architecture 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -56,21 +56,26 @@ export class Logger {
|
||||
}
|
||||
|
||||
private log(level: LogLevel, levelName: string, message: string, ...args: any[]): void {
|
||||
// Allow ERROR level logs through in more cases for debugging
|
||||
const allowErrorLogs = level === LogLevel.ERROR && (this.isHttp || process.env.DEBUG === 'true');
|
||||
|
||||
// Check environment variables FIRST, before level check
|
||||
// In stdio mode, suppress ALL console output to avoid corrupting JSON-RPC
|
||||
// In stdio mode, suppress ALL console output to avoid corrupting JSON-RPC (except errors when debugging)
|
||||
// Also suppress in test mode unless debug is explicitly enabled
|
||||
if (this.isStdio || this.isDisabled || (this.isTest && process.env.DEBUG !== 'true')) {
|
||||
// Silently drop all logs in stdio/test mode
|
||||
return;
|
||||
// Allow error logs through if debugging is enabled
|
||||
if (!allowErrorLogs) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (level <= this.config.level) {
|
||||
if (level <= this.config.level || allowErrorLogs) {
|
||||
const formattedMessage = this.formatMessage(levelName, message);
|
||||
|
||||
// In HTTP mode during request handling, suppress console output
|
||||
// In HTTP mode during request handling, suppress console output (except errors)
|
||||
// The ConsoleManager will handle this, but we add a safety check
|
||||
if (this.isHttp && process.env.MCP_REQUEST_ACTIVE === 'true') {
|
||||
// Silently drop the log during active MCP requests
|
||||
if (this.isHttp && process.env.MCP_REQUEST_ACTIVE === 'true' && !allowErrorLogs) {
|
||||
// Silently drop the log during active MCP requests (except errors)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user