2727import io .modelcontextprotocol .spec .McpSchema ;
2828import io .modelcontextprotocol .spec .McpSchema .CompleteRequest ;
2929import io .modelcontextprotocol .spec .McpSchema .CompleteResult ;
30+ import io .modelcontextprotocol .spec .McpSchema .ErrorCodes ;
3031import io .modelcontextprotocol .spec .McpSchema .InitializeResult ;
3132import io .modelcontextprotocol .spec .McpSchema .Prompt ;
3233import io .modelcontextprotocol .spec .McpSchema .PromptArgument ;
3334import io .modelcontextprotocol .spec .McpSchema .ReadResourceResult ;
35+ import io .modelcontextprotocol .spec .McpSchema .Resource ;
3436import io .modelcontextprotocol .spec .McpSchema .ResourceReference ;
3537import io .modelcontextprotocol .spec .McpSchema .PromptReference ;
3638import io .modelcontextprotocol .spec .McpSchema .ServerCapabilities ;
@@ -84,7 +86,7 @@ public void after() {
8486 tomcat .destroy ();
8587 }
8688 catch (LifecycleException e ) {
87- throw new RuntimeException ( "Failed to stop Tomcat" , e );
89+ e . printStackTrace ( );
8890 }
8991 }
9092 }
@@ -99,8 +101,13 @@ void testCompletionHandlerReceivesContext() {
99101
100102 ResourceReference resourceRef = new ResourceReference ("ref/resource" , "test://resource/{param}" );
101103
102- McpSchema .Resource resource = new McpSchema .Resource ("test://resource/{param}" , "Test Resource" ,
103- "A resource for testing" , "text/plain" , 123L , null );
104+ var resource = Resource .builder ()
105+ .uri ("test://resource/{param}" )
106+ .name ("Test Resource" )
107+ .description ("A resource for testing" )
108+ .mimeType ("text/plain" )
109+ .size (123L )
110+ .build ();
104111
105112 var mcpServer = McpServer .sync (mcpServerTransportProvider )
106113 .capabilities (ServerCapabilities .builder ().completions ().build ())
@@ -199,8 +206,13 @@ else if ("products_db".equals(db)) {
199206 return new CompleteResult (new CompleteResult .CompleteCompletion (List .of (), 0 , false ));
200207 };
201208
202- McpSchema .Resource resource = new McpSchema .Resource ("db://{database}/{table}" , "Database Table" ,
203- "Resource representing a table in a database" , "application/json" , 456L , null );
209+ McpSchema .Resource resource = Resource .builder ()
210+ .uri ("db://{database}/{table}" )
211+ .name ("Database Table" )
212+ .description ("Resource representing a table in a database" )
213+ .mimeType ("application/json" )
214+ .size (456L )
215+ .build ();
204216
205217 var mcpServer = McpServer .sync (mcpServerTransportProvider )
206218 .capabilities (ServerCapabilities .builder ().completions ().build ())
@@ -254,7 +266,10 @@ void testCompletionErrorOnMissingContext() {
254266 // Check if database context is provided
255267 if (request .context () == null || request .context ().arguments () == null
256268 || !request .context ().arguments ().containsKey ("database" )) {
257- throw new McpError ("Please select a database first to see available tables" );
269+
270+ throw McpError .builder (ErrorCodes .INVALID_REQUEST )
271+ .message ("Please select a database first to see available tables" )
272+ .build ();
258273 }
259274 // Normal completion if context is provided
260275 String db = request .context ().arguments ().get ("database" );
@@ -268,8 +283,13 @@ void testCompletionErrorOnMissingContext() {
268283 return new CompleteResult (new CompleteResult .CompleteCompletion (List .of (), 0 , false ));
269284 };
270285
271- McpSchema .Resource resource = new McpSchema .Resource ("db://{database}/{table}" , "Database Table" ,
272- "Resource representing a table in a database" , "application/json" , 456L , null );
286+ McpSchema .Resource resource = Resource .builder ()
287+ .uri ("db://{database}/{table}" )
288+ .name ("Database Table" )
289+ .description ("Resource representing a table in a database" )
290+ .mimeType ("application/json" )
291+ .size (456L )
292+ .build ();
273293
274294 var mcpServer = McpServer .sync (mcpServerTransportProvider )
275295 .capabilities (ServerCapabilities .builder ().completions ().build ())
0 commit comments