fix: resolve Docker stdio initialization timeout issue
- Add InitializeRequestSchema handler to MCP server - Implement stdout flushing for Docker environments - Create stdio-wrapper for clean JSON-RPC communication - Update docker-entrypoint.sh to prevent stdout pollution - Fix logger to check MCP_MODE before level check These changes ensure the MCP server responds to initialization requests within Claude Desktop's 60-second timeout when running in Docker.
This commit is contained in:
@@ -51,15 +51,19 @@ export class Logger {
|
||||
}
|
||||
|
||||
private log(level: LogLevel, levelName: string, message: string, ...args: any[]): void {
|
||||
// Check environment variables FIRST, before level check
|
||||
// In stdio mode, suppress ALL console output to avoid corrupting JSON-RPC
|
||||
const isStdio = process.env.MCP_MODE === 'stdio';
|
||||
const isDisabled = process.env.DISABLE_CONSOLE_OUTPUT === 'true';
|
||||
|
||||
if (isStdio || isDisabled) {
|
||||
// Silently drop all logs in stdio mode
|
||||
return;
|
||||
}
|
||||
|
||||
if (level <= this.config.level) {
|
||||
const formattedMessage = this.formatMessage(levelName, message);
|
||||
|
||||
// In stdio mode, suppress ALL console output to avoid corrupting JSON-RPC
|
||||
if (process.env.MCP_MODE === 'stdio' || process.env.DISABLE_CONSOLE_OUTPUT === 'true') {
|
||||
// Silently drop all logs in stdio mode
|
||||
return;
|
||||
}
|
||||
|
||||
// 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') {
|
||||
|
||||
Reference in New Issue
Block a user