Skip to content

Commit 335fca0

Browse files
committed
Add diagnostic log for stdio client test and increase init timeout
1 parent deb8bd8 commit 335fca0

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

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

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,15 @@ public Mono<Void> connect(Function<Mono<JSONRPCMessage>, Mono<JSONRPCMessage>> h
124124
processBuilder.command(fullCommand);
125125
processBuilder.environment().putAll(params.getEnv());
126126

127-
// Start the process
128-
try {
129-
this.process = processBuilder.start();
130-
}
131-
catch (IOException e) {
132-
throw new RuntimeException("Failed to start process with command: " + fullCommand, e);
133-
}
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");
134136

135137
// Validate process streams
136138
if (this.process.getInputStream() == null || process.getOutputStream() == null) {
@@ -391,4 +393,15 @@ public <T> T unmarshalFrom(Object data, TypeReference<T> typeRef) {
391393
return this.objectMapper.convertValue(data, typeRef);
392394
}
393395

396+
private static void measureTime(Runnable op, String opName) {
397+
long start = System.nanoTime();
398+
try {
399+
op.run();
400+
}
401+
finally {
402+
long delta = System.nanoTime() - start;
403+
logger.info("{} took {}ms", opName, Duration.ofNanos(delta).toMillis());
404+
}
405+
}
406+
394407
}

mcp/src/test/java/io/modelcontextprotocol/client/StdioMcpSyncClientTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void customErrorHandlerShouldReceiveErrors() throws InterruptedException {
6868
}
6969

7070
protected Duration getInitializationTimeout() {
71-
return Duration.ofSeconds(6);
71+
return Duration.ofSeconds(10);
7272
}
7373

7474
}

0 commit comments

Comments
 (0)