Skip to content

Commit 18ab638

Browse files
committed
new API
1 parent 4f23aa0 commit 18ab638

36 files changed

+427
-264
lines changed

integrations/mcp/server/src/main/java/io/helidon/integrations/mcp/server/BinaryResourceReader.java

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.helidon.integrations.mcp.server;
22

3-
public enum Capabilities {
3+
public enum Capability {
44
TOOL_LIST_CHANGED,
55
RESOURCE_LIST_CHANGED,
66
RESOURCE_SUBSCRIBE,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package io.helidon.integrations.mcp.server;
2+
3+
interface Content {
4+
String type();
5+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.helidon.integrations.mcp.server;
2+
3+
public interface EmbeddedResourceContent extends Content {
4+
5+
String uri();
6+
7+
ResourceContent content();
8+
9+
default String type() {
10+
return "resource";
11+
}
12+
}

integrations/mcp/server/src/main/java/io/helidon/integrations/mcp/server/FileResourceReader.java

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package io.helidon.integrations.mcp.server;
2+
3+
interface ImageContent extends ToolContent, Content {
4+
5+
default String type() {
6+
return "image";
7+
}
8+
9+
String data();
10+
11+
String mimeType();
12+
13+
static ImageContent create(String data, String mimeType) {
14+
return new ImageContent() {
15+
16+
@Override
17+
public String data() {
18+
return data;
19+
}
20+
21+
@Override
22+
public String mimeType() {
23+
return mimeType;
24+
}
25+
};
26+
}
27+
}

integrations/mcp/server/src/main/java/io/helidon/integrations/mcp/server/InputSchema.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ private Builder() {
4646
this.properties = new HashMap<>();
4747
}
4848

49+
public Builder properties(String key, String value, boolean required) {
50+
this.properties.put(key, value);
51+
if (required) {
52+
this.required.add(key);
53+
}
54+
return this;
55+
}
56+
4957
public Builder properties(String key, String value) {
5058
this.properties.put(key, value);
5159
return this;

integrations/mcp/server/src/main/java/io/helidon/integrations/mcp/server/Mcp.java

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,48 @@
2222

2323
import static java.lang.annotation.ElementType.METHOD;
2424
import static java.lang.annotation.ElementType.PARAMETER;
25+
import static java.lang.annotation.ElementType.TYPE;
2526
import static java.lang.annotation.RetentionPolicy.RUNTIME;
2627

2728
/**
2829
* This interface contains a set of annotations for defining MCP declarative server.
2930
*/
3031
public final class Mcp {
3132

32-
@Target(METHOD)
33+
@Target(TYPE)
3334
@Retention(RUNTIME)
34-
public @interface Resource {
35-
String uri();
36-
String name();
37-
String description() default "none"; //optional
35+
public @interface Server {
36+
String value() default "Helidon MCP Server";
37+
}
38+
39+
@Target(TYPE)
40+
@Retention(RUNTIME)
41+
public @interface Capability {
42+
io.helidon.integrations.mcp.server.Capability[] value();
43+
}
44+
45+
@Target({TYPE, METHOD})
46+
@Retention(RUNTIME)
47+
public @interface Description {
48+
String value();
49+
}
50+
51+
@Target(TYPE)
52+
@Retention(RUNTIME)
53+
public @interface Version {
54+
String value();
3855
}
3956

4057
@Target(METHOD)
4158
@Retention(RUNTIME)
4259
public @interface Prompt {
43-
String name();
44-
String description() default "none"; //optional
60+
String value() default "";
4561
}
4662

4763
@Target(METHOD)
4864
@Retention(RUNTIME)
4965
public @interface Tool {
50-
String name();
51-
String description();
52-
String annotations() default ""; //optional
66+
String value() default "";
5367
}
5468

5569
@Target(PARAMETER)
@@ -58,15 +72,15 @@ public final class Mcp {
5872
String value();
5973
}
6074

61-
@Target(ElementType.TYPE)
75+
@Target(METHOD)
6276
@Retention(RUNTIME)
63-
public @interface Server {
64-
String name() default "Helidon MCP Server";
65-
String version() default "0.0.1";
66-
Capabilities[] capabilities() default {};
77+
public @interface Resource {
78+
String value() default "";
6779
}
6880

69-
70-
71-
81+
@Target(METHOD)
82+
@Retention(RUNTIME)
83+
public @interface URI {
84+
String value();
85+
}
7286
}

integrations/mcp/server/src/main/java/io/helidon/integrations/mcp/server/McpHttpFeature.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,22 @@ public class McpHttpFeature implements HttpFeature {
4242
private final Map<String, McpSession> sessions = new ConcurrentHashMap<>();
4343

4444
@Service.Inject
45-
public McpHttpFeature(McpServerConfig server) {
45+
public McpHttpFeature(McpServerDetails server) {
4646
this.server = McpServer.create(server);
4747
}
4848

49-
public McpHttpFeature(McpServerConfig... server) {
49+
public McpHttpFeature(McpServerDetails... server) {
5050
this.server = null;
5151
}
5252

53-
public static McpHttpFeature create(McpServerConfig... servers) {
53+
public static McpHttpFeature create(McpServerDetails... servers) {
5454
return new McpHttpFeature(servers);
5555
}
5656

57+
public static McpHttpFeature.Builder builder() {
58+
return new Builder();
59+
}
60+
5761
@Override
5862
public void setup(HttpRouting.Builder routing) {
5963
routing.get("/sse", this::sse)
@@ -112,4 +116,18 @@ private McpJsonRPC.JSONRPCMessage deserializeJsonRpcMessage(String content) {
112116
}
113117
}
114118

119+
public static class Builder {
120+
private McpServerDetails config;
121+
122+
public Builder server(McpServerDetails server) {
123+
this.config = server;
124+
return this;
125+
}
126+
127+
public McpHttpFeature build() {
128+
return new McpHttpFeature(config);
129+
}
130+
131+
}
132+
115133
}

integrations/mcp/server/src/main/java/io/helidon/integrations/mcp/server/McpJsonRPC.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ class McpJsonRPC {
3636
private McpJsonRPC() {
3737
}
3838

39-
static final String LATEST_PROTOCOL_VERSION = "2024-11-05";
40-
41-
static final String JSONRPC_VERSION = "2.0";
42-
4339
// ---------------------------
4440
// Method Names
4541
// ---------------------------

0 commit comments

Comments
 (0)