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 @@ -9,6 +9,7 @@
import java.util.List;
import java.util.Map;

import com.logaritex.mcp.annotation.McpArg;
import io.modelcontextprotocol.spec.McpSchema.GetPromptRequest;
import io.modelcontextprotocol.spec.McpSchema.GetPromptResult;
import io.modelcontextprotocol.spec.McpSchema.Prompt;
Expand Down Expand Up @@ -143,7 +144,8 @@ else if (Map.class.isAssignableFrom(paramType)) {
}
else {
// For individual argument parameters, extract from the request arguments
String paramName = param.getName();
McpArg arg = param.getAnnotation(McpArg.class);
String paramName = arg != null && !arg.name().isBlank() ? arg.name() : param.getName();
if (request.arguments() != null && request.arguments().containsKey(paramName)) {
Object argValue = request.arguments().get(paramName);
args[i] = convertArgumentValue(argValue, paramType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Map;
import java.util.function.BiFunction;

import com.logaritex.mcp.annotation.McpArg;
import com.logaritex.mcp.annotation.McpPrompt;
import com.logaritex.mcp.method.prompt.SyncMcpPromptMethodCallback;
import io.modelcontextprotocol.server.McpSyncServerExchange;
Expand Down Expand Up @@ -55,13 +56,15 @@ public GetPromptResult getPromptWithArguments(Map<String, Object> arguments) {
}

@McpPrompt(name = "individual-args", description = "A prompt with individual arguments")
public GetPromptResult getPromptWithIndividualArgs(String name, Integer age) {
public GetPromptResult getPromptWithIndividualArgs(@McpArg(name = "name", description = "The user's name", required = true) String name,
@McpArg(name = "age", description = "The user's age", required = true) Integer age) {
return new GetPromptResult("Individual arguments prompt", List.of(new PromptMessage(Role.ASSISTANT,
new TextContent("Hello " + name + ", you are " + age + " years old"))));
}

@McpPrompt(name = "mixed-args", description = "A prompt with mixed argument types")
public GetPromptResult getPromptWithMixedArgs(McpSyncServerExchange exchange, String name, Integer age) {
public GetPromptResult getPromptWithMixedArgs(McpSyncServerExchange exchange,@McpArg(name = "name", description = "The user's name", required = true) String name,
@McpArg(name = "age", description = "The user's age", required = true) Integer age) {
return new GetPromptResult("Mixed arguments prompt", List.of(new PromptMessage(Role.ASSISTANT,
new TextContent("Hello " + name + ", you are " + age + " years old (with exchange)"))));
}
Expand Down
Loading