Skip to content

Commit c3d8050

Browse files
authored
Merge pull request #186 from scottslewis/master
Fix for ToolAnnotation
2 parents a3ca792 + 67675d2 commit c3d8050

File tree

4 files changed

+33
-23
lines changed

4 files changed

+33
-23
lines changed

framework/bundles/org.eclipse.ecf.ai.mcp.tools/src/org/eclipse/ecf/ai/mcp/tools/annotation/Tool.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,5 @@
2222

2323
String description() default "";
2424

25-
/**
26-
* Supports the addition of ToolAnnotations to Tool spec in the MCP schema
27-
* (draft as of 5/18/2025) located <a href=
28-
* "https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/draft/schema.json#L2164">here</a>
29-
*/
30-
@Retention(RetentionPolicy.RUNTIME)
31-
@Target(ElementType.METHOD)
32-
public @interface ToolAnnotation {
33-
boolean destructiveHint() default false;
34-
35-
boolean idempotentHint() default false;
36-
37-
boolean openWorldHint() default false;
38-
39-
boolean readOnlyHint() default false;
40-
41-
String title() default "";
42-
}
43-
44-
ToolAnnotation[] annotations();
25+
ToolAnnotation[] value();
4526
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.eclipse.ecf.ai.mcp.tools.annotation;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Repeatable;
5+
import java.lang.annotation.Retention;
6+
import java.lang.annotation.RetentionPolicy;
7+
import java.lang.annotation.Target;
8+
9+
/**
10+
* Supports the addition of ToolAnnotations to Tool spec in the MCP schema
11+
* (draft as of 5/18/2025) located <a href=
12+
* "https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/draft/schema.json#L2164">here</a>
13+
*/
14+
@Repeatable(Tool.class)
15+
@Retention(RetentionPolicy.RUNTIME)
16+
@Target(ElementType.METHOD)
17+
public @interface ToolAnnotation {
18+
boolean destructiveHint() default false;
19+
20+
boolean idempotentHint() default false;
21+
22+
boolean openWorldHint() default false;
23+
24+
boolean readOnlyHint() default false;
25+
26+
String title() default "";
27+
28+
}
29+

framework/bundles/org.eclipse.ecf.ai.mcp.tools/src/org/eclipse/ecf/ai/mcp/tools/service/ToolAnnotationDescription.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import java.util.List;
1515
import java.util.stream.Collectors;
1616

17-
import org.eclipse.ecf.ai.mcp.tools.annotation.Tool;
17+
import org.eclipse.ecf.ai.mcp.tools.annotation.ToolAnnotation;
1818

1919
/**
2020
* Describes the ToolAnnotation type in the MCP schema (draft as of 5/18/2025)
@@ -24,7 +24,7 @@
2424
public record ToolAnnotationDescription(boolean destructiveHint, boolean idempotentHint, boolean openWorldHint,
2525
boolean readOnlyHint, String title) {
2626

27-
public static List<ToolAnnotationDescription> fromAnnotations(Tool.ToolAnnotation[] annotations) {
27+
public static List<ToolAnnotationDescription> fromAnnotations(ToolAnnotation[] annotations) {
2828
return (annotations != null) ? Arrays.asList(annotations).stream().map(a -> {
2929
return new ToolAnnotationDescription(a.destructiveHint(), a.idempotentHint(), a.openWorldHint(),
3030
a.readOnlyHint(), a.title());

framework/bundles/org.eclipse.ecf.ai.mcp.tools/src/org/eclipse/ecf/ai/mcp/tools/service/ToolDescription.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static List<ToolDescription> fromClass(Class<?> clazz) {
2828
? new ToolDescription(m.getName(), ma.description(),
2929
ToolParamDescription.fromParameters(m.getParameters()),
3030
ToolResultDescription.fromMethod(m),
31-
ToolAnnotationDescription.fromAnnotations(ma.annotations()))
31+
ToolAnnotationDescription.fromAnnotations(ma.value()))
3232
: null;
3333
}).filter(Objects::nonNull).collect(Collectors.toList());
3434

0 commit comments

Comments
 (0)