Skip to content

Commit da7552a

Browse files
committed
fix: remove console logging
1 parent 4977557 commit da7552a

2 files changed

Lines changed: 6 additions & 13 deletions

File tree

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ class MinecraftDevMCPServer {
141141
await verifyJavaVersion(17);
142142
} catch (error) {
143143
logger.error('Java verification failed', error);
144-
console.error('\n❌ Java 17+ is required but not found or not working.');
145-
console.error('Please install Java 17 or higher and ensure it is in your PATH.\n');
144+
// Don't use console.error - it breaks MCP stdio protocol
145+
// Error will be logged to file and server will exit
146146
process.exit(1);
147147
}
148148

@@ -159,6 +159,6 @@ class MinecraftDevMCPServer {
159159
const server = new MinecraftDevMCPServer();
160160
server.start().catch((error) => {
161161
logger.error('Failed to start server', error);
162-
console.error('Failed to start server:', error);
162+
// Don't use console.error - it breaks MCP stdio protocol
163163
process.exit(1);
164164
});

src/utils/logger.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,12 @@ class Logger {
3838

3939
const formatted = this.format(levelName, message, meta);
4040

41-
// Console output
42-
if (level >= LogLevel.WARN) {
43-
console.error(formatted.trim());
44-
} else {
45-
console.log(formatted.trim());
46-
}
47-
48-
// File output
41+
// File output only - MCP servers must not write to stdout/stderr
42+
// as it interferes with JSON-RPC communication over stdio
4943
try {
5044
appendFileSync(this.logFile, formatted, 'utf8');
5145
} catch (error) {
52-
// Fail silently for file writes
53-
console.error('Failed to write to log file:', error);
46+
// Fail silently for file writes - cannot use console in MCP servers
5447
}
5548
}
5649

0 commit comments

Comments
 (0)