Skip to content

feat: Added optional title field to resource, tool, prompt #349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -995,10 +995,12 @@ void testCompletionShouldReturnExpectedSuggestions(String clientType) {

var mcpServer = McpServer.sync(mcpServerTransportProvider)
.capabilities(ServerCapabilities.builder().completions().build())
.prompts(new McpServerFeatures.SyncPromptSpecification(
new Prompt("code_review", "this is code review prompt",
List.of(new PromptArgument("language", "string", false))),
(mcpSyncServerExchange, getPromptRequest) -> null))
.prompts(new McpServerFeatures.SyncPromptSpecification(Prompt.builder()
.name("code_review")
.title("Request Code Review")
.description("this is code review prompt")
.arguments(List.of(new PromptArgument("language", "string", false)))
.build(), (mcpSyncServerExchange, getPromptRequest) -> null))
.completions(new McpServerFeatures.SyncCompletionSpecification(
new McpSchema.PromptReference("ref/prompt", "code_review"), completionHandler))
.build();
Expand All @@ -1008,8 +1010,11 @@ void testCompletionShouldReturnExpectedSuggestions(String clientType) {
InitializeResult initResult = mcpClient.initialize();
assertThat(initResult).isNotNull();

CompleteRequest request = new CompleteRequest(new PromptReference("ref/prompt", "code_review"),
new CompleteRequest.CompleteArgument("language", "py"));
CompleteRequest request = new CompleteRequest(PromptReference.builder()
.type("ref/prompt")
.name("code_review")
.title("Request Code Review")
.build(), new CompleteRequest.CompleteArgument("language", "py"));

CompleteResult result = mcpClient.completeCompletion(request);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,14 @@ private List<McpSchema.ResourceTemplate> getResourceTemplates() {
.filter(uri -> uri.contains("{"))
.map(uri -> {
var resource = this.resources.get(uri).resource();
var template = new McpSchema.ResourceTemplate(resource.uri(), resource.name(), resource.description(),
resource.mimeType(), resource.annotations());
return template;
return ResourceTemplate.builder()
.uriTemplate(resource.uri())
.name(resource.name())
.title(resource.title())
.description(resource.description())
.mimeType(resource.mimeType())
.annotations(resource.annotations())
.build();
})
.toList();

Expand Down Expand Up @@ -725,7 +730,11 @@ private McpSchema.CompleteRequest parseCompletionParams(Object object) {
String refType = (String) refMap.get("type");

McpSchema.CompleteReference ref = switch (refType) {
case "ref/prompt" -> new McpSchema.PromptReference(refType, (String) refMap.get("name"));
case "ref/prompt" -> McpSchema.PromptReference.builder()
.type(refType)
.name((String) refMap.get("name"))
.title((String) refMap.get("title"))
.build();
case "ref/resource" -> new McpSchema.ResourceReference(refType, (String) refMap.get("uri"));
default -> throw new IllegalArgumentException("Invalid ref type: " + refType);
};
Expand Down
Loading