-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from mkouba/issue-71-complete-resources
Implement completion for resource templates
- Loading branch information
Showing
24 changed files
with
457 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
core/runtime/src/main/java/io/quarkiverse/mcp/server/CompleteResourceTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.quarkiverse.mcp.server; | ||
|
||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
import java.util.List; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
/** | ||
* Annotates a business method of a CDI bean used to complete an expression of a URI template of a resource template. | ||
* <p> | ||
* The result of a "complete" operation is always represented as a {@link CompletionResponse}. However, the annotated method can | ||
* also return other types that are converted according to the following rules. | ||
* <ul> | ||
* <li>If the method returns {@link String} then the reponse contains the single value.</li> | ||
* <li>If the method returns a {@link List} of {@link String}s then the reponse contains the list of values.</li> | ||
* <li>The method may return a {@link Uni} that wraps any of the type mentioned above.</li> | ||
* </ul> | ||
* In other words, the return type must be one of the following list: | ||
* <ul> | ||
* <li>{@code CompletionResponse}</li> | ||
* <li>{@code String}</li> | ||
* <li>{@code List<String>}</li> | ||
* <li>{@code Uni<CompletionResponse>}</li> | ||
* <li>{@code Uni<String>}</li> | ||
* <li>{@code Uni<List<String>>}</li> | ||
* </ul> | ||
* | ||
* @see ResourceTemplate#name() | ||
*/ | ||
@Retention(RUNTIME) | ||
@Target(METHOD) | ||
public @interface CompleteResourceTemplate { | ||
|
||
/** | ||
* The name reference to a resource template. If not such {@link ResourceTemplate} exists then the build fails. | ||
*/ | ||
String value(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...runtime/src/main/java/io/quarkiverse/mcp/server/runtime/PromptCompleteMessageHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.quarkiverse.mcp.server.runtime; | ||
|
||
import java.util.Objects; | ||
|
||
import io.quarkiverse.mcp.server.CompletionResponse; | ||
import io.vertx.core.Future; | ||
|
||
class PromptCompleteMessageHandler extends CompletionMessageHandler { | ||
|
||
private final PromptCompleteManager manager; | ||
|
||
PromptCompleteMessageHandler(PromptCompleteManager manager) { | ||
this.manager = Objects.requireNonNull(manager); | ||
} | ||
|
||
@Override | ||
protected Future<CompletionResponse> execute(String key, ArgumentProviders argProviders) throws McpException { | ||
return manager.execute(key, argProviders); | ||
} | ||
|
||
} |
Oops, something went wrong.