File tree Expand file tree Collapse file tree
main/java/io/jooby/internal/apt
jooby-mcp/src/main/java/io/jooby/annotation/mcp Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -153,28 +153,10 @@ public List<String> generateMcpDefinitionMethod(boolean kt) {
153153 || type .equals ("io.jooby.Context" )) continue ;
154154
155155 var mcpName = param .getMcpName ();
156- var javaName = param .getName ();
157156
158157 // 1. Extract the description from the @McpParam annotation
159- var paramDescription = "" ;
160- var varEl =
161- this .method .getParameters ().stream ()
162- .filter (p -> p .getSimpleName ().toString ().equals (javaName ))
163- .findFirst ()
164- .orElse (null );
165-
166- if (varEl != null ) {
167- var paramAnno =
168- AnnotationSupport .findAnnotationByName (varEl , "io.jooby.annotation.mcp.McpParam" );
169- if (paramAnno != null ) {
170- paramDescription =
171- AnnotationSupport .findAnnotationValue (paramAnno , "description" ::equals ).stream ()
172- .findFirst ()
173- .map (v -> v .replace ("\" " , "" ))
174- .orElse ("" );
175- }
176- }
177- if (paramDescription .isEmpty ()) {
158+ var paramDescription = param .getMcpDescription ();
159+ if (paramDescription == null ) {
178160 paramDescription = method .map (it -> it .getParameterDoc (param .getName ())).orElse ("" );
179161 }
180162
Original file line number Diff line number Diff line change @@ -58,6 +58,18 @@ public String getMcpName() {
5858 return getName ();
5959 }
6060
61+ public String getMcpDescription () {
62+ var annotation = annotations .get ("io.jooby.annotation.mcp.McpParam" );
63+ if (annotation != null ) {
64+ return io .jooby .internal .apt .AnnotationSupport .findAnnotationValue (
65+ annotation , "description" ::equals )
66+ .stream ()
67+ .findFirst ()
68+ .orElse (null );
69+ }
70+ return null ;
71+ }
72+
6173 public String generateMapping (boolean kt ) {
6274 var strategy =
6375 annotations .entrySet ().stream ()
Original file line number Diff line number Diff line change 99import java .util .Map ;
1010
1111import io .jooby .annotation .mcp .*;
12+ import io .modelcontextprotocol .spec .McpSchema ;
1213
1314@ McpServer ("example-server" )
1415public class ExampleServer {
@@ -46,7 +47,7 @@ public String reviewCode(
4647 size = 1024 ,
4748 annotations = {
4849 @ McpResource .McpAnnotations (
49- audience = McpResource .Role .USER ,
50+ audience = McpSchema .Role .USER ,
5051 lastModified = "1" ,
5152 priority = 1.5 )
5253 })
Original file line number Diff line number Diff line change 1010import java .lang .annotation .RetentionPolicy ;
1111import java .lang .annotation .Target ;
1212
13+ import io .modelcontextprotocol .spec .McpSchema ;
14+
1315/**
1416 * Exposes a method as an MCP Resource or Resource Template.
1517 *
5759 McpAnnotations []
5860 annotations () default {}; // Using an array is the safest way to provide an "empty" default in
5961
60- // Java annotations
61-
62- enum Role {
63- USER ,
64- ASSISTANT
65- }
66-
6762 @ Retention (RetentionPolicy .RUNTIME )
6863 @ Target (ElementType .ANNOTATION_TYPE )
6964 @interface McpAnnotations {
@@ -72,7 +67,7 @@ enum Role {
7267 * Describes who the intended customer of this object or data is. It can include multiple
7368 * entries to indicate content useful for multiple audiences (e.g., [“user”, “assistant”]).
7469 */
75- Role [] audience ();
70+ McpSchema . Role [] audience ();
7671
7772 /** The date and time (in ISO 8601 format) when the resource was last modified. */
7873 String lastModified () default "" ;
You can’t perform that action at this time.
0 commit comments