Skip to content

Commit 1d738c6

Browse files
committed
Blueprint Configuration for Prompt, Tool and Resource
1 parent 7b92d2a commit 1d738c6

File tree

21 files changed

+235
-810
lines changed

21 files changed

+235
-810
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
@Prototype.Blueprint
2525
@Prototype.Configured("mcp")
26-
//TODO will be removed when using blueprint
27-
@Prototype.CustomMethods(McpHttpFeatureConfigSupport.McpCustomMethods.class)
2826
interface McpHttpFeatureConfigBlueprint extends Prototype.Factory<McpHttpFeature> {
2927

3028
@Option.Default("/mcp")

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

Lines changed: 0 additions & 38 deletions
This file was deleted.

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

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -59,62 +59,9 @@ static Builder builder() {
5959
}
6060

6161
class Builder {
62-
List<Tool> tools = new ArrayList<>();
63-
List<Prompt> prompts = new ArrayList<>();
64-
List<Resource> resources = new ArrayList<>();
65-
List<Completion> completions = new ArrayList<>();
66-
67-
public Builder tool(Consumer<ToolInfo.Builder> info, Function<McpParameters, ToolContent> process) {
68-
ToolInfo.Builder builder = ToolInfo.builder();
69-
info.accept(builder);
70-
// tools.add(Tool.create(builder.build(), process));
71-
return this;
72-
}
73-
74-
public Builder prompt(Consumer<PromptInfo.Builder> info, Function<McpParameters, PromptContent> prompt) {
75-
PromptInfo.Builder builder = PromptInfo.builder();
76-
info.accept(builder);
77-
// this.prompts.add(Prompt.create(builder.build(), prompt));
78-
return this;
79-
}
80-
81-
public Builder resource(Consumer<ResourceInfo.Builder> info, Supplier<ResourceContent> read) {
82-
ResourceInfo.Builder builder = ResourceInfo.builder();
83-
info.accept(builder);
84-
// this.resources.add(Resource.create(builder.build(), read));
85-
return this;
86-
}
87-
88-
public Builder completion(Consumer<CompletionInfo.Builder> info, Function<McpParameters, CompletionContent> complete) {
89-
CompletionInfo.Builder builder = CompletionInfo.builder();
90-
info.accept(builder);
91-
// this.completions.add(Completion.create(builder.build(), complete));
92-
return this;
93-
}
9462

9563
public McpRouting build() {
96-
return new McpRouting() {
97-
98-
@Override
99-
public List<Tool> tools() {
100-
return tools;
101-
}
102-
103-
@Override
104-
public List<Prompt> prompts() {
105-
return prompts;
106-
}
107-
108-
@Override
109-
public List<Resource> resources() {
110-
return resources;
111-
}
112-
113-
@Override
114-
public List<Completion> completions() {
115-
return completions;
116-
}
117-
};
64+
return null;
11865
}
11966
}
12067
}

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

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@
2121
import java.util.function.Consumer;
2222
import java.util.function.Function;
2323

24+
import io.helidon.builder.api.Option;
25+
import io.helidon.builder.api.RuntimeType;
26+
2427
/**
2528
* MCP Prompt definition.
2629
*/
27-
public interface Prompt extends Jsonable {
30+
@RuntimeType.PrototypedBy(PromptConfig.class)
31+
public interface Prompt extends Jsonable, RuntimeType.Api<PromptConfig> {
2832
/**
2933
* Prompt name.
3034
*
@@ -54,41 +58,20 @@ public interface Prompt extends Jsonable {
5458
*/
5559
PromptContent prompt(McpParameters parameters);
5660

57-
static Prompt.Builder builder() {
58-
return new Prompt.Builder();
61+
@Override
62+
default PromptConfig prototype() {
63+
return PromptConfig.create();
5964
}
6065

61-
class Builder implements io.helidon.common.Builder<Prompt.Builder, Prompt> {
62-
private String name;
63-
private String description;
64-
private Function<McpParameters, PromptContent> prompt;
65-
private final Set<PromptArgument> arguments = new HashSet<>();
66-
67-
public Builder prompt(Function<McpParameters, PromptContent> process) {
68-
this.prompt = process;
69-
return this;
70-
}
71-
72-
public Builder name(String name) {
73-
this.name = name;
74-
return this;
75-
}
76-
77-
public Builder description(String description) {
78-
this.description = description;
79-
return this;
80-
}
66+
static Prompt create(PromptConfig config) {
67+
return config.build();
68+
}
8169

82-
public Builder argument(Consumer<PromptArgument.Builder> builder) {
83-
PromptArgument.Builder argumentBuilder = PromptArgument.builder();
84-
builder.accept(argumentBuilder);
85-
arguments.add(argumentBuilder.build());
86-
return this;
87-
}
70+
static Prompt create(Consumer<PromptConfig.Builder> consumer) {
71+
return PromptConfig.builder().update(consumer).build();
72+
}
8873

89-
@Override
90-
public Prompt build() {
91-
return new PromptImpl(name, description, arguments, prompt);
92-
}
74+
static PromptConfig.Builder builder() {
75+
return PromptConfig.builder();
9376
}
9477
}

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

Lines changed: 0 additions & 107 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2025 Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.helidon.integrations.mcp.server;
18+
19+
import io.helidon.builder.api.Prototype;
20+
21+
/**
22+
* Prompt argument information.
23+
*/
24+
@Prototype.Blueprint
25+
interface PromptArgumentBlueprint extends Jsonable {
26+
/**
27+
* Prompt argument name.
28+
*
29+
* @return name
30+
*/
31+
String name();
32+
33+
/**
34+
* Prompt argument description.
35+
*
36+
* @return description
37+
*/
38+
String description();
39+
40+
/**
41+
* Wether this prompt argument is required.
42+
*
43+
* @return {@code true} if is required, {@code false} otherwise
44+
*/
45+
boolean required();
46+
47+
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818

1919
import java.util.Set;
2020

21+
import io.helidon.builder.api.Option;
2122
import io.helidon.builder.api.Prototype;
2223

23-
//@Prototype.Blueprint
24-
interface PromptConfigBlueprint {
24+
@Prototype.Blueprint
25+
interface PromptConfigBlueprint extends Prototype.Factory<Prompt> {
2526
/**
2627
* Prompt name.
2728
*
@@ -41,6 +42,7 @@ interface PromptConfigBlueprint {
4142
*
4243
* @return {@link Set} of argument
4344
*/
45+
@Option.Singular
4446
Set<PromptArgument> arguments();
4547

4648
/**

0 commit comments

Comments
 (0)