@@ -42,7 +42,7 @@ record Async(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities s
4242 List <McpServerFeatures .AsyncToolSpecification > tools , Map <String , AsyncResourceSpecification > resources ,
4343 List <McpSchema .ResourceTemplate > resourceTemplates ,
4444 Map <String , McpServerFeatures .AsyncPromptSpecification > prompts ,
45- Map <CompletionRefKey , McpServerFeatures .AsyncCompletionSpecification > completions ,
45+ Map <McpSchema . CompleteReference , McpServerFeatures .AsyncCompletionSpecification > completions ,
4646 List <BiFunction <McpAsyncServerExchange , List <McpSchema .Root >, Mono <Void >>> rootsChangeConsumers ,
4747 String instructions ) {
4848
@@ -62,7 +62,7 @@ record Async(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities s
6262 List <McpServerFeatures .AsyncToolSpecification > tools , Map <String , AsyncResourceSpecification > resources ,
6363 List <McpSchema .ResourceTemplate > resourceTemplates ,
6464 Map <String , McpServerFeatures .AsyncPromptSpecification > prompts ,
65- Map <CompletionRefKey , McpServerFeatures .AsyncCompletionSpecification > completions ,
65+ Map <McpSchema . CompleteReference , McpServerFeatures .AsyncCompletionSpecification > completions ,
6666 List <BiFunction <McpAsyncServerExchange , List <McpSchema .Root >, Mono <Void >>> rootsChangeConsumers ,
6767 String instructions ) {
6868
@@ -114,7 +114,7 @@ static Async fromSync(Sync syncSpec) {
114114 prompts .put (key , AsyncPromptSpecification .fromSync (prompt ));
115115 });
116116
117- Map <CompletionRefKey , McpServerFeatures .AsyncCompletionSpecification > completions = new HashMap <>();
117+ Map <McpSchema . CompleteReference , McpServerFeatures .AsyncCompletionSpecification > completions = new HashMap <>();
118118 syncSpec .completions ().forEach ((key , completion ) -> {
119119 completions .put (key , AsyncCompletionSpecification .fromSync (completion ));
120120 });
@@ -150,7 +150,7 @@ record Sync(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities se
150150 Map <String , McpServerFeatures .SyncResourceSpecification > resources ,
151151 List <McpSchema .ResourceTemplate > resourceTemplates ,
152152 Map <String , McpServerFeatures .SyncPromptSpecification > prompts ,
153- Map <CompletionRefKey , McpServerFeatures .SyncCompletionSpecification > completions ,
153+ Map <McpSchema . CompleteReference , McpServerFeatures .SyncCompletionSpecification > completions ,
154154 List <BiConsumer <McpSyncServerExchange , List <McpSchema .Root >>> rootsChangeConsumers , String instructions ) {
155155
156156 /**
@@ -170,7 +170,7 @@ record Sync(McpSchema.Implementation serverInfo, McpSchema.ServerCapabilities se
170170 Map <String , McpServerFeatures .SyncResourceSpecification > resources ,
171171 List <McpSchema .ResourceTemplate > resourceTemplates ,
172172 Map <String , McpServerFeatures .SyncPromptSpecification > prompts ,
173- Map <CompletionRefKey , McpServerFeatures .SyncCompletionSpecification > completions ,
173+ Map <McpSchema . CompleteReference , McpServerFeatures .SyncCompletionSpecification > completions ,
174174 List <BiConsumer <McpSyncServerExchange , List <McpSchema .Root >>> rootsChangeConsumers ,
175175 String instructions ) {
176176
@@ -355,7 +355,7 @@ static AsyncPromptSpecification fromSync(SyncPromptSpecification prompt) {
355355 * {@link McpAsyncServerExchange} used to interact with the client. The second
356356 * argument is a {@link io.modelcontextprotocol.spec.McpSchema.CompleteRequest}.
357357 */
358- public record AsyncCompletionSpecification (CompletionRefKey referenceKey ,
358+ public record AsyncCompletionSpecification (McpSchema . CompleteReference referenceKey ,
359359 BiFunction <McpAsyncServerExchange , McpSchema .CompleteRequest , Mono <McpSchema .CompleteResult >> completionHandler ) {
360360
361361 /**
@@ -492,46 +492,8 @@ public record SyncPromptSpecification(McpSchema.Prompt prompt,
492492 * {@link McpSyncServerExchange} used to interact with the client. The second argument
493493 * is a {@link io.modelcontextprotocol.spec.McpSchema.CompleteRequest}.
494494 */
495- public record SyncCompletionSpecification (CompletionRefKey referenceKey ,
495+ public record SyncCompletionSpecification (McpSchema . CompleteReference referenceKey ,
496496 BiFunction <McpSyncServerExchange , McpSchema .CompleteRequest , McpSchema .CompleteResult > completionHandler ) {
497497 }
498498
499- /**
500- * A unique key representing a completion reference, composed of its type and
501- * identifier. This key is used to look up asynchronous completion specifications in a
502- * map-like structure.
503- *
504- * <p>
505- * The {@code type} typically corresponds to the kind of reference, such as
506- * {@code "ref/prompt"} or {@code "ref/resource"}, while the {@code identifier} is the
507- * name or URI associated with the specific reference.
508- *
509- * @param type the reference type (e.g., "ref/prompt", "ref/resource")
510- * @param identifier the reference identifier (e.g., prompt name or resource URI)
511- */
512- public record CompletionRefKey (String type , String identifier ) {
513-
514- /**
515- * Creates a {@code CompletionRefKey} from a {@link McpSchema.CompleteRequest}.
516- * The key is derived from the request's reference type and its associated name or
517- * URI.
518- * @param request the {@code CompleteRequest} containing a prompt or resource
519- * reference
520- * @return a unique key based on the request's reference
521- * @throws IllegalArgumentException if the reference type is unsupported
522- */
523- public static CompletionRefKey from (McpSchema .CompleteRequest request ) {
524- var ref = request .ref ();
525- if (ref instanceof McpSchema .PromptReference pr ) {
526- return new CompletionRefKey (ref .type (), pr .name ());
527- }
528- else if (ref instanceof McpSchema .ResourceReference rr ) {
529- return new CompletionRefKey (ref .type (), rr .uri ());
530- }
531- else {
532- throw new IllegalArgumentException ("Unsupported reference type: " + ref );
533- }
534- }
535- }
536-
537499}
0 commit comments