1616import io .modelcontextprotocol .spec .McpServerTransport ;
1717import io .modelcontextprotocol .spec .McpServerTransportProvider ;
1818import io .modelcontextprotocol .spec .ProtocolVersions ;
19- import io .modelcontextprotocol .util .Assert ;
2019import io .modelcontextprotocol .util .KeepAliveScheduler ;
2120import modelengine .fel .tool .mcp .entity .Event ;
2221import modelengine .fit .http .annotation .GetMapping ;
@@ -60,7 +59,7 @@ public class FitMcpSseServerTransportProvider implements McpServerTransportProvi
6059 private final McpJsonMapper jsonMapper ;
6160 private McpServerSession .Factory sessionFactory ;
6261 private final Map <String , McpServerSession > sessions = new ConcurrentHashMap ();
63- private McpTransportContextExtractor <HttpClassicServerRequest > contextExtractor ;
62+ private final McpTransportContextExtractor <HttpClassicServerRequest > contextExtractor ;
6463 private volatile boolean isClosing = false ;
6564 private KeepAliveScheduler keepAliveScheduler ;
6665
@@ -76,8 +75,8 @@ public class FitMcpSseServerTransportProvider implements McpServerTransportProvi
7675 */
7776 private FitMcpSseServerTransportProvider (McpJsonMapper jsonMapper , Duration keepAliveInterval ,
7877 McpTransportContextExtractor <HttpClassicServerRequest > contextExtractor ) {
79- Assert .notNull (jsonMapper , "McpJsonMapper must not be null" );
80- Assert .notNull (contextExtractor , "Context extractor must not be null" );
78+ Validation .notNull (jsonMapper , "McpJsonMapper must not be null" );
79+ Validation .notNull (contextExtractor , "Context extractor must not be null" );
8180 this .jsonMapper = jsonMapper ;
8281 this .contextExtractor = contextExtractor ;
8382 if (keepAliveInterval != null ) {
@@ -195,7 +194,6 @@ public Object handleSseConnection(HttpClassicServerRequest request, HttpClassicS
195194 new FitSseMcpSessionTransport (sessionId , emitter , response );
196195 McpServerSession session = this .sessionFactory .create (sessionTransport );
197196 this .sessions .put (sessionId , session );
198-
199197 try {
200198 String initData = MESSAGE_ENDPOINT + "?sessionId=" + sessionId ;
201199 TextEvent textEvent =
@@ -241,10 +239,9 @@ public Object handleMessage(HttpClassicServerRequest request, HttpClassicServerR
241239 if (sessionError != null ) {
242240 return sessionError ;
243241 }
244-
245242 McpServerSession session = this .sessions .get (sessionId );
246243 try {
247- final McpTransportContext transportContext = this .contextExtractor .extract (request );
244+ McpTransportContext transportContext = this .contextExtractor .extract (request );
248245
249246 String requestBody = new String (request .entityBytes (), StandardCharsets .UTF_8 );
250247 McpSchema .JSONRPCMessage message = McpSchema .deserializeJsonRpcMessage (this .jsonMapper , requestBody );
@@ -471,7 +468,7 @@ public static class Builder {
471468 * @return This builder instance for method chaining
472469 */
473470 public Builder jsonMapper (McpJsonMapper jsonMapper ) {
474- Assert .notNull (jsonMapper , "McpJsonMapper must not be null" );
471+ Validation .notNull (jsonMapper , "McpJsonMapper must not be null" );
475472 this .jsonMapper = jsonMapper ;
476473 return this ;
477474 }
@@ -501,7 +498,7 @@ public Builder keepAliveInterval(Duration keepAliveInterval) {
501498 * @throws IllegalArgumentException if contextExtractor is null
502499 */
503500 public Builder contextExtractor (McpTransportContextExtractor <HttpClassicServerRequest > contextExtractor ) {
504- Assert .notNull (contextExtractor , "contextExtractor must not be null" );
501+ Validation .notNull (contextExtractor , "contextExtractor must not be null" );
505502 this .contextExtractor = contextExtractor ;
506503 return this ;
507504 }
0 commit comments