Skip to content
Merged
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 @@ -29,7 +29,7 @@ private PromptAdapter() {
* @return The corresponding McpSchema.Prompt object
*/
public static McpSchema.Prompt asPrompt(McpPrompt mcpPrompt) {
return new McpSchema.Prompt(mcpPrompt.name(), mcpPrompt.description(), List.of());
return new McpSchema.Prompt(mcpPrompt.name(), mcpPrompt.title(), mcpPrompt.description(), List.of());
}

/**
Expand All @@ -41,7 +41,7 @@ public static McpSchema.Prompt asPrompt(McpPrompt mcpPrompt) {
*/
public static McpSchema.Prompt asPrompt(McpPrompt mcpPrompt, Method method) {
List<McpSchema.PromptArgument> arguments = extractPromptArguments(method);
return new McpSchema.Prompt(getName(mcpPrompt, method), mcpPrompt.description(), arguments);
return new McpSchema.Prompt(getName(mcpPrompt, method), mcpPrompt.title(), mcpPrompt.description(), arguments);
}

private static String getName(McpPrompt promptAnnotation, Method method) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@
public @interface McpPrompt {

/**
* A human-readable name for this resource. This can be used by clients to populate UI
* elements.
* Unique identifier for the prompt
*/
String name() default "";

/**
* A description of what this resource represents. This can be used by clients to
* improve the LLM's understanding of available resources. It can be thought of like a
* "hint" to the model.
* Optional human-readable name of the prompt for display purposes.
*/
String title() default "";

/**
* Optional human-readable description.
*/
String description() default "";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.lang.reflect.Method;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import io.modelcontextprotocol.server.McpAsyncServerExchange;
Expand Down Expand Up @@ -120,7 +121,8 @@ public Mono<String> enumMonoTool(TestEnum enumValue) {

@McpTool(name = "primitive-types-mono-tool", description = "Mono tool with primitive types")
public Mono<String> primitiveTypesMonoTool(boolean flag, byte b, short s, int i, long l, float f, double d) {
return Mono.just(String.format("Primitives: %b, %d, %d, %d, %d, %.1f, %.1f", flag, b, s, i, l, f, d));
return Mono
.just(String.format(Locale.US, "Primitives: %b, %d, %d, %d, %d, %.1f, %.1f", flag, b, s, i, l, f, d));
Copy link
Contributor Author

@ls-rein-martha ls-rein-martha Sep 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got a failure on one of the unit tests since decimal represented as , at my machine. Thus, explicitly use Locale.US to handle it.

}

@McpTool(name = "return-object-mono-tool", description = "Mono tool that returns a complex object")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.lang.reflect.Method;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import io.modelcontextprotocol.common.McpTransportContext;
Expand Down Expand Up @@ -120,7 +121,8 @@ public Mono<String> enumMonoTool(TestEnum enumValue) {

@McpTool(name = "primitive-types-mono-tool", description = "Mono tool with primitive types")
public Mono<String> primitiveTypesMonoTool(boolean flag, byte b, short s, int i, long l, float f, double d) {
return Mono.just(String.format("Primitives: %b, %d, %d, %d, %d, %.1f, %.1f", flag, b, s, i, l, f, d));
return Mono
.just(String.format(Locale.US, "Primitives: %b, %d, %d, %d, %d, %.1f, %.1f", flag, b, s, i, l, f, d));
}

@McpTool(name = "return-object-mono-tool", description = "Mono tool that returns a complex object")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.lang.reflect.Method;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import io.modelcontextprotocol.server.McpSyncServerExchange;
Expand Down Expand Up @@ -98,7 +99,7 @@ public String enumTool(TestEnum enumValue) {

@McpTool(name = "primitive-types-tool", description = "Tool with primitive types")
public String primitiveTypesTool(boolean flag, byte b, short s, int i, long l, float f, double d) {
return String.format("Primitives: %b, %d, %d, %d, %d, %.1f, %.1f", flag, b, s, i, l, f, d);
return String.format(Locale.US, "Primitives: %b, %d, %d, %d, %d, %.1f, %.1f", flag, b, s, i, l, f, d);
}

@McpTool(name = "return-object-tool", description = "Tool that returns a complex object")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.lang.reflect.Method;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import io.modelcontextprotocol.common.McpTransportContext;
Expand Down Expand Up @@ -99,7 +100,7 @@ public String enumTool(TestEnum enumValue) {

@McpTool(name = "primitive-types-tool", description = "Tool with primitive types")
public String primitiveTypesTool(boolean flag, byte b, short s, int i, long l, float f, double d) {
return String.format("Primitives: %b, %d, %d, %d, %d, %.1f, %.1f", flag, b, s, i, l, f, d);
return String.format(Locale.US, "Primitives: %b, %d, %d, %d, %d, %.1f, %.1f", flag, b, s, i, l, f, d);
}

@McpTool(name = "return-object-tool", description = "Tool that returns a complex object")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,29 @@ public GetPromptResult methodWithDifferentName() {
assertThat(promptSpecs.get(0).prompt().description()).isEqualTo("Custom named prompt");
}

@Test
void testGetPromptSpecificationsWithTitle() {
class PromptWithTitle {

@McpPrompt(name = "prompt-name", title = "Custom Title for UI", description = "Custom Titled prompt")
public GetPromptResult methodWithDifferentName() {
return new GetPromptResult("Custom prompt result",
List.of(new PromptMessage(Role.ASSISTANT, new TextContent("Custom prompt content"))));
}

}

PromptWithTitle promptObject = new PromptWithTitle();
SyncMcpPromptProvider provider = new SyncMcpPromptProvider(List.of(promptObject));

List<SyncPromptSpecification> promptSpecs = provider.getPromptSpecifications();

assertThat(promptSpecs).hasSize(1);
assertThat(promptSpecs.get(0).prompt().name()).isEqualTo("prompt-name");
assertThat(promptSpecs.get(0).prompt().title()).isEqualTo("Custom Title for UI");
assertThat(promptSpecs.get(0).prompt().description()).isEqualTo("Custom Titled prompt");
}

@Test
void testGetPromptSpecificationsWithDefaultPromptName() {
class DefaultNamePrompt {
Expand Down