Skip to content

Commit 96569ae

Browse files
committed
Formatting
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
1 parent 2e49583 commit 96569ae

File tree

7 files changed

+221
-240
lines changed

7 files changed

+221
-240
lines changed

mcp-spring/mcp-spring-webflux/src/test/java/io/modelcontextprotocol/WebFluxSseIntegrationTests.java

Lines changed: 50 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,10 @@ void testCreateMessageWithoutSamplingCapabilities(String clientType) {
112112
return Mono.just(mock(CallToolResult.class));
113113
});
114114

115-
var server = McpServer.async(
116-
mcpServerTransportProvider)
117-
.serverInfo("test-server", "1.0.0")
118-
.tools(tool)
119-
.build();
120-
121-
try (var client = clientBuilder
122-
.clientInfo(new McpSchema.Implementation("Sample " + "client", "0.0.0"))
123-
.build();) {
115+
var server = McpServer.async(mcpServerTransportProvider).serverInfo("test-server", "1.0.0").tools(tool).build();
116+
117+
try (var client = clientBuilder.clientInfo(new McpSchema.Implementation("Sample " + "client", "0.0.0"))
118+
.build();) {
124119

125120
assertThat(client.initialize()).isNotNull();
126121

@@ -182,12 +177,11 @@ void testCreateMessageSuccess(String clientType) throws InterruptedException {
182177
.serverInfo("test-server", "1.0.0")
183178
.tools(tool)
184179
.build();
185-
186-
try (
187-
var mcpClient = clientBuilder.clientInfo(new McpSchema.Implementation("Sample client", "0.0.0"))
188-
.capabilities(ClientCapabilities.builder().sampling().build())
189-
.sampling(samplingHandler)
190-
.build()) {
180+
181+
try (var mcpClient = clientBuilder.clientInfo(new McpSchema.Implementation("Sample client", "0.0.0"))
182+
.capabilities(ClientCapabilities.builder().sampling().build())
183+
.sampling(samplingHandler)
184+
.build()) {
191185

192186
InitializeResult initResult = mcpClient.initialize();
193187
assertThat(initResult).isNotNull();
@@ -213,12 +207,12 @@ void testRootsSuccess(String clientType) {
213207
AtomicReference<List<Root>> rootsRef = new AtomicReference<>();
214208

215209
var mcpServer = McpServer.sync(mcpServerTransportProvider)
216-
.rootsChangeHandler((exchange, rootsUpdate) -> rootsRef.set(rootsUpdate))
217-
.build();
210+
.rootsChangeHandler((exchange, rootsUpdate) -> rootsRef.set(rootsUpdate))
211+
.build();
218212

219213
try (var mcpClient = clientBuilder.capabilities(ClientCapabilities.builder().roots(true).build())
220-
.roots(roots)
221-
.build()) {
214+
.roots(roots)
215+
.build()) {
222216

223217
InitializeResult initResult = mcpClient.initialize();
224218
assertThat(initResult).isNotNull();
@@ -264,16 +258,12 @@ void testRootsWithoutCapability(String clientType) {
264258
return mock(CallToolResult.class);
265259
});
266260

267-
var mcpServer = McpServer.sync(mcpServerTransportProvider)
268-
.rootsChangeHandler((exchange, rootsUpdate) -> {})
269-
.tools(tool)
270-
.build();
261+
var mcpServer = McpServer.sync(mcpServerTransportProvider).rootsChangeHandler((exchange, rootsUpdate) -> {
262+
}).tools(tool).build();
271263

272264
try (
273-
// Create client without roots capability
274-
var mcpClient = clientBuilder
275-
.capabilities(ClientCapabilities.builder().build())
276-
.build()) {
265+
// Create client without roots capability
266+
var mcpClient = clientBuilder.capabilities(ClientCapabilities.builder().build()).build()) {
277267

278268
assertThat(mcpClient.initialize()).isNotNull();
279269

@@ -297,12 +287,12 @@ void testRootsNotifciationWithEmptyRootsList(String clientType) {
297287
AtomicReference<List<Root>> rootsRef = new AtomicReference<>();
298288

299289
var mcpServer = McpServer.sync(mcpServerTransportProvider)
300-
.rootsChangeHandler((exchange, rootsUpdate) -> rootsRef.set(rootsUpdate))
301-
.build();
290+
.rootsChangeHandler((exchange, rootsUpdate) -> rootsRef.set(rootsUpdate))
291+
.build();
302292

303293
try (var mcpClient = clientBuilder.capabilities(ClientCapabilities.builder().roots(true).build())
304-
.roots(List.of()) // Empty roots list
305-
.build()) {
294+
.roots(List.of()) // Empty roots list
295+
.build()) {
306296

307297
assertThat(mcpClient.initialize()).isNotNull();
308298

@@ -328,13 +318,13 @@ void testRootsWithMultipleHandlers(String clientType) {
328318
AtomicReference<List<Root>> rootsRef2 = new AtomicReference<>();
329319

330320
var mcpServer = McpServer.sync(mcpServerTransportProvider)
331-
.rootsChangeHandler((exchange, rootsUpdate) -> rootsRef1.set(rootsUpdate))
332-
.rootsChangeHandler((exchange, rootsUpdate) -> rootsRef2.set(rootsUpdate))
333-
.build();
321+
.rootsChangeHandler((exchange, rootsUpdate) -> rootsRef1.set(rootsUpdate))
322+
.rootsChangeHandler((exchange, rootsUpdate) -> rootsRef2.set(rootsUpdate))
323+
.build();
334324

335325
try (var mcpClient = clientBuilder.capabilities(ClientCapabilities.builder().roots(true).build())
336-
.roots(roots)
337-
.build()) {
326+
.roots(roots)
327+
.build()) {
338328

339329
InitializeResult initResult = mcpClient.initialize();
340330
assertThat(initResult).isNotNull();
@@ -361,12 +351,12 @@ void testRootsServerCloseWithActiveSubscription(String clientType) {
361351
AtomicReference<List<Root>> rootsRef = new AtomicReference<>();
362352

363353
var mcpServer = McpServer.sync(mcpServerTransportProvider)
364-
.rootsChangeHandler((exchange, rootsUpdate) -> rootsRef.set(rootsUpdate))
365-
.build();
354+
.rootsChangeHandler((exchange, rootsUpdate) -> rootsRef.set(rootsUpdate))
355+
.build();
366356

367357
try (var mcpClient = clientBuilder.capabilities(ClientCapabilities.builder().roots(true).build())
368-
.roots(roots)
369-
.build()) {
358+
.roots(roots)
359+
.build()) {
370360

371361
InitializeResult initResult = mcpClient.initialize();
372362
assertThat(initResult).isNotNull();
@@ -413,9 +403,9 @@ void testToolCallSuccess(String clientType) {
413403
});
414404

415405
var mcpServer = McpServer.sync(mcpServerTransportProvider)
416-
.capabilities(ServerCapabilities.builder().tools(true).build())
417-
.tools(tool1)
418-
.build();
406+
.capabilities(ServerCapabilities.builder().tools(true).build())
407+
.tools(tool1)
408+
.build();
419409

420410
try (var mcpClient = clientBuilder.build()) {
421411

@@ -455,21 +445,20 @@ void testToolListChangeHandlingSuccess(String clientType) {
455445
AtomicReference<List<Tool>> rootsRef = new AtomicReference<>();
456446

457447
var mcpServer = McpServer.sync(mcpServerTransportProvider)
458-
.capabilities(ServerCapabilities.builder().tools(true).build())
459-
.tools(tool1)
460-
.build();
448+
.capabilities(ServerCapabilities.builder().tools(true).build())
449+
.tools(tool1)
450+
.build();
461451

462-
try (
463-
var mcpClient = clientBuilder.toolsChangeConsumer(toolsUpdate -> {
464-
// perform a blocking call to a remote service
465-
String response = RestClient.create()
466-
.get()
467-
.uri("https://raw.githubusercontent.com/modelcontextprotocol/java-sdk/refs/heads/main/README.md")
468-
.retrieve()
469-
.body(String.class);
470-
assertThat(response).isNotBlank();
471-
rootsRef.set(toolsUpdate);
472-
}).build()) {
452+
try (var mcpClient = clientBuilder.toolsChangeConsumer(toolsUpdate -> {
453+
// perform a blocking call to a remote service
454+
String response = RestClient.create()
455+
.get()
456+
.uri("https://raw.githubusercontent.com/modelcontextprotocol/java-sdk/refs/heads/main/README.md")
457+
.retrieve()
458+
.body(String.class);
459+
assertThat(response).isNotBlank();
460+
rootsRef.set(toolsUpdate);
461+
}).build()) {
473462

474463
InitializeResult initResult = mcpClient.initialize();
475464
assertThat(initResult).isNotNull();
@@ -583,10 +572,10 @@ void testLoggingNotification(String clientType) {
583572
.build();
584573

585574
try (
586-
// Create client with logging notification handler
587-
var mcpClient = clientBuilder
588-
.loggingConsumer(notification -> { receivedNotifications.add(notification); })
589-
.build()) {
575+
// Create client with logging notification handler
576+
var mcpClient = clientBuilder.loggingConsumer(notification -> {
577+
receivedNotifications.add(notification);
578+
}).build()) {
590579

591580
// Initialize client
592581
InitializeResult initResult = mcpClient.initialize();

mcp-test/src/main/java/io/modelcontextprotocol/client/AbstractMcpAsyncClientTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,12 @@ void testLoggingLevelsWithoutInitialization() {
454454
@Test
455455
void testLoggingLevels() {
456456
withClient(createMcpTransport(), mcpAsyncClient -> {
457-
StepVerifier.create(mcpAsyncClient.initialize()
458-
.thenMany(Flux.fromArray(McpSchema.LoggingLevel.values())
459-
.flatMap(mcpAsyncClient::setLoggingLevel))
460-
.collectList())
461-
.assertNext(l -> assertThat(l).hasSize(McpSchema.LoggingLevel.values().length))
462-
.verifyComplete();
457+
StepVerifier
458+
.create(mcpAsyncClient.initialize()
459+
.thenMany(Flux.fromArray(McpSchema.LoggingLevel.values()).flatMap(mcpAsyncClient::setLoggingLevel))
460+
.collectList())
461+
.assertNext(l -> assertThat(l).hasSize(McpSchema.LoggingLevel.values().length))
462+
.verifyComplete();
463463
});
464464
}
465465

mcp/src/main/java/io/modelcontextprotocol/server/McpAsyncServer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ public Mono<Void> notifyPromptsListChanged() {
218218

219219
/**
220220
* This implementation would, incorrectly, broadcast the logging message to all
221-
* connected clients, using a single minLoggingLevel for all of them. Similar to
222-
* the sampling and roots, the logging level should be set per client session and
223-
* use the ServerExchange to send the logging message to the right client.
221+
* connected clients, using a single minLoggingLevel for all of them. Similar to the
222+
* sampling and roots, the logging level should be set per client session and use the
223+
* ServerExchange to send the logging message to the right client.
224224
* @param loggingMessageNotification The logging message to send
225225
* @return A Mono that completes when the notification has been sent
226226
* @deprecated Use
@@ -697,7 +697,7 @@ private McpServerSession.RequestHandler<Object> setLoggerRequestHandler() {
697697
exchange.setMinLoggingLevel(newMinLoggingLevel.level());
698698

699699
// FIXME: this field is deprecated and should be removed together
700-
// with the broadcasting loggingNotification.
700+
// with the broadcasting loggingNotification.
701701
this.minLoggingLevel = newMinLoggingLevel.level();
702702

703703
return Mono.just(Map.of());

mcp/src/main/java/io/modelcontextprotocol/server/McpSyncServer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ public void notifyPromptsListChanged() {
150150

151151
/**
152152
* This implementation would, incorrectly, broadcast the logging message to all
153-
* connected clients, using a single minLoggingLevel for all of them. Similar to
154-
* the sampling and roots, the logging level should be set per client session and
155-
* use the ServerExchange to send the logging message to the right client.
153+
* connected clients, using a single minLoggingLevel for all of them. Similar to the
154+
* sampling and roots, the logging level should be set per client session and use the
155+
* ServerExchange to send the logging message to the right client.
156156
* @param loggingMessageNotification The logging message to send
157157
* @deprecated Use
158158
* {@link McpSyncServerExchange#loggingNotification(LoggingMessageNotification)}

mcp/src/main/java/io/modelcontextprotocol/server/McpSyncServerExchange.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,5 @@ public McpSchema.ListRootsResult listRoots(String cursor) {
8989
public void loggingNotification(LoggingMessageNotification loggingMessageNotification) {
9090
this.exchange.loggingNotification(loggingMessageNotification).block();
9191
}
92+
9293
}

0 commit comments

Comments
 (0)