Skip to content

Commit 92be635

Browse files
committed
WIP: Add remaining javadocs, tiny corrections here and there
Signed-off-by: Dariusz Jędrzejczyk <[email protected]>
1 parent 87a018f commit 92be635

24 files changed

+291
-42
lines changed

mcp-spring/mcp-spring-webflux/src/test/java/io/modelcontextprotocol/server/WebFluxStreamableMcpAsyncServerTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
import reactor.netty.http.server.HttpServer;
1818

1919
/**
20-
* Tests for {@link McpAsyncServer} using {@link WebFluxSseServerTransportProvider}.
20+
* Tests for {@link McpAsyncServer} using
21+
* {@link WebFluxStreamableServerTransportProvider}.
2122
*
2223
* @author Christian Tzolov
24+
* @author Dariusz Jędrzejczyk
2325
*/
2426
@Timeout(15) // Giving extra time beyond the client timeout
2527
class WebFluxStreamableMcpAsyncServerTests extends AbstractMcpAsyncServerTests {

mcp-spring/mcp-spring-webflux/src/test/java/io/modelcontextprotocol/server/WebFluxStreamableMcpSyncServerTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
import reactor.netty.http.server.HttpServer;
1717

1818
/**
19-
* Tests for {@link McpAsyncServer} using {@link WebFluxSseServerTransportProvider}.
19+
* Tests for {@link McpAsyncServer} using
20+
* {@link WebFluxStreamableServerTransportProvider}.
2021
*
2122
* @author Christian Tzolov
23+
* @author Dariusz Jędrzejczyk
2224
*/
2325
@Timeout(15) // Giving extra time beyond the client timeout
2426
class WebFluxStreamableMcpSyncServerTests extends AbstractMcpSyncServerTests {

mcp-test/src/main/java/io/modelcontextprotocol/server/AbstractMcpAsyncServerTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import io.modelcontextprotocol.spec.McpSchema.ServerCapabilities;
1919
import io.modelcontextprotocol.spec.McpSchema.Tool;
2020
import io.modelcontextprotocol.spec.McpServerTransportProvider;
21-
import io.modelcontextprotocol.spec.McpStreamableServerTransportProvider;
2221
import org.junit.jupiter.api.AfterEach;
2322
import org.junit.jupiter.api.BeforeEach;
2423
import org.junit.jupiter.api.Test;

mcp-test/src/main/java/io/modelcontextprotocol/server/AbstractMcpSyncServerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
/**
3030
* Test suite for the {@link McpSyncServer} that can be used with different
31-
* {@link McpTransportProvider} implementations.
31+
* {@link McpServerTransportProvider} implementations.
3232
*
3333
* @author Christian Tzolov
3434
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import java.util.Map;
1010

11-
public class DefaultMcpStatelessServerHandler implements McpStatelessServerHandler {
11+
class DefaultMcpStatelessServerHandler implements McpStatelessServerHandler {
1212

1313
private static final Logger logger = LoggerFactory.getLogger(DefaultMcpStatelessServerHandler.class);
1414

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@
33
import java.util.Map;
44
import java.util.concurrent.ConcurrentHashMap;
55

6+
/**
7+
* Default implementation for {@link McpTransportContext} which uses a Thread-safe map.
8+
* Objects of this kind are mutable.
9+
*
10+
* @author Dariusz Jędrzejczyk
11+
*/
612
public class DefaultMcpTransportContext implements McpTransportContext {
713

814
private final Map<String, Object> storage;
915

16+
/**
17+
* Create an empty instance.
18+
*/
1019
public DefaultMcpTransportContext() {
1120
this.storage = new ConcurrentHashMap<>();
1221
}
@@ -25,6 +34,10 @@ public void put(String key, Object value) {
2534
this.storage.put(key, value);
2635
}
2736

37+
/**
38+
* Allows copying the contents.
39+
* @return new instance with the copy of the underlying map
40+
*/
2841
public McpTransportContext copy() {
2942
return new DefaultMcpTransportContext(new ConcurrentHashMap<>(this.storage));
3043
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ public McpAsyncServerExchange(McpSession session, McpSchema.ClientCapabilities c
7575
* @param session The server session representing a 1-1 interaction.
7676
* @param clientCapabilities The client capabilities that define the supported
7777
* features and functionality.
78+
* @param clientInfo The client implementation information.
7879
* @param transportContext context associated with the client as extracted from the
7980
* transport
80-
* @param clientInfo The client implementation information.
8181
*/
8282
public McpAsyncServerExchange(String sessionId, McpLoggableSession session,
8383
McpSchema.ClientCapabilities clientCapabilities, McpSchema.Implementation clientInfo,
@@ -105,10 +105,20 @@ public McpSchema.Implementation getClientInfo() {
105105
return this.clientInfo;
106106
}
107107

108+
/**
109+
* Provides the {@link McpTransportContext} associated with the transport layer. For
110+
* HTTP transports it can contain the metadata associated with the HTTP request that
111+
* triggered the processing.
112+
* @return the transport context object
113+
*/
108114
public McpTransportContext transportContext() {
109115
return this.transportContext;
110116
}
111117

118+
/**
119+
* Provides the Session ID.
120+
* @return session ID string
121+
*/
112122
public String sessionId() {
113123
return this.sessionId;
114124
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,26 @@ static AsyncSpecification<?> async(McpStreamableServerTransportProvider transpor
183183
return new StreamableServerAsyncSpecification(transportProvider);
184184
}
185185

186+
/**
187+
* Starts building an asynchronous MCP server that provides non-blocking operations.
188+
* Asynchronous servers can handle multiple requests concurrently on a single Thread
189+
* using a functional paradigm with non-blocking server transports, making them more
190+
* scalable for high-concurrency scenarios but more complex to implement.
191+
* @param transport The transport layer implementation for MCP communication.
192+
* @return A new instance of {@link AsyncSpecification} for configuring the server.
193+
*/
186194
static StatelessAsyncSpecification async(McpStatelessServerTransport transport) {
187195
return new StatelessAsyncSpecification(transport);
188196
}
189197

198+
/**
199+
* Starts building a synchronous MCP server that provides blocking operations.
200+
* Synchronous servers block the current Thread's execution upon each request before
201+
* giving the control back to the caller, making them simpler to implement but
202+
* potentially less scalable for concurrent operations.
203+
* @param transport The transport layer implementation for MCP communication.
204+
* @return A new instance of {@link SyncSpecification} for configuring the server.
205+
*/
190206
static StatelessSyncSpecification sync(McpStatelessServerTransport transport) {
191207
return new StatelessSyncSpecification(transport);
192208
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
import java.util.function.BiFunction;
3333

3434
/**
35+
* A stateless MCP server implementation for use with Streamable HTTP transport types. It
36+
* allows simple horizontal scalability since it does not maintain a session and does not
37+
* require initialization. Each instance of the server can be reached with no prior
38+
* knowledge and can serve the clients with the capabilities it supports.
39+
*
3540
* @author Dariusz Jędrzejczyk
3641
*/
3742
public class McpStatelessAsyncServer {

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,19 @@
22

33
import reactor.core.publisher.Mono;
44

5+
/**
6+
* Handler for MCP notifications in a stateless server.
7+
*
8+
* @author Dariusz Jędrzejczyk
9+
*/
510
public interface McpStatelessNotificationHandler {
611

12+
/**
13+
* Handle to notification and complete once done.
14+
* @param transportContext {@link McpTransportContext} associated with the transport
15+
* @param params the payload of the MCP notification
16+
* @return Mono which completes once the processing is done
17+
*/
718
Mono<Void> handle(McpTransportContext transportContext, Object params);
819

920
}

0 commit comments

Comments
 (0)