Skip to content

Commit 1d3c125

Browse files
committed
Remove temp diagnostics but add stdio process lifecycle logs
1 parent 335fca0 commit 1d3c125

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

mcp/src/main/java/io/modelcontextprotocol/client/transport/StdioClientTransport.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public StdioClientTransport(ServerParameters params, ObjectMapper objectMapper)
112112
@Override
113113
public Mono<Void> connect(Function<Mono<JSONRPCMessage>, Mono<JSONRPCMessage>> handler) {
114114
return Mono.<Void>fromRunnable(() -> {
115+
logger.info("MCP server starting.");
115116
handleIncomingMessages(handler);
116117
handleIncomingErrors();
117118

@@ -124,15 +125,13 @@ public Mono<Void> connect(Function<Mono<JSONRPCMessage>, Mono<JSONRPCMessage>> h
124125
processBuilder.command(fullCommand);
125126
processBuilder.environment().putAll(params.getEnv());
126127

127-
measureTime(() -> {
128-
// Start the process
129-
try {
130-
this.process = processBuilder.start();
131-
}
132-
catch (IOException e) {
133-
throw new RuntimeException("Failed to start process with command: " + fullCommand, e);
134-
}
135-
}, "Process start");
128+
// Start the process
129+
try {
130+
this.process = processBuilder.start();
131+
}
132+
catch (IOException e) {
133+
throw new RuntimeException("Failed to start process with command: " + fullCommand, e);
134+
}
136135

137136
// Validate process streams
138137
if (this.process.getInputStream() == null || process.getOutputStream() == null) {
@@ -144,6 +143,7 @@ public Mono<Void> connect(Function<Mono<JSONRPCMessage>, Mono<JSONRPCMessage>> h
144143
startInboundProcessing();
145144
startOutboundProcessing();
146145
startErrorProcessing();
146+
logger.info("MCP server started");
147147
}).subscribeOn(Schedulers.boundedElastic());
148148
}
149149

@@ -367,6 +367,8 @@ public Mono<Void> closeGracefully() {
367367
})).doOnNext(process -> {
368368
if (process.exitValue() != 0) {
369369
logger.warn("Process terminated with code " + process.exitValue());
370+
} else {
371+
logger.info("MCP server process stopped");
370372
}
371373
}).then(Mono.fromRunnable(() -> {
372374
try {

0 commit comments

Comments
 (0)