fix: implement Single-Session architecture to resolve MCP stream errors
- Add ConsoleManager to prevent console output interference with StreamableHTTPServerTransport - Implement SingleSessionHTTPServer with persistent session reuse - Create N8NMCPEngine for clean service integration - Add automatic session expiry after 30 minutes of inactivity - Update logger to be HTTP-aware during active requests - Maintain backward compatibility with existing deployments This fixes the "stream is not readable" error by implementing the Hybrid Single-Session architecture as documented in MCP_ERROR_FIX_PLAN.md 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,8 @@ export interface LoggerConfig {
|
||||
export class Logger {
|
||||
private config: LoggerConfig;
|
||||
private static instance: Logger;
|
||||
private useFileLogging = false;
|
||||
private fileStream: any = null;
|
||||
|
||||
constructor(config?: Partial<LoggerConfig>) {
|
||||
this.config = {
|
||||
@@ -52,6 +54,13 @@ export class Logger {
|
||||
if (level <= this.config.level) {
|
||||
const formattedMessage = this.formatMessage(levelName, message);
|
||||
|
||||
// In HTTP mode during request handling, suppress console output
|
||||
// The ConsoleManager will handle this, but we add a safety check
|
||||
if (process.env.MCP_MODE === 'http' && process.env.MCP_REQUEST_ACTIVE === 'true') {
|
||||
// Silently drop the log during active MCP requests
|
||||
return;
|
||||
}
|
||||
|
||||
switch (level) {
|
||||
case LogLevel.ERROR:
|
||||
console.error(formattedMessage, ...args);
|
||||
|
||||
Reference in New Issue
Block a user