Skip to content

Commit c38fc18

Browse files
committed
Support multiple bundles in install command
1 parent 31f85f2 commit c38fc18

1 file changed

Lines changed: 22 additions & 20 deletions

File tree

mcp/mcp-cli/src/main/java/software/amazon/smithy/java/mcp/cli/commands/InstallBundle.java

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public class InstallBundle extends SmithyMcpCommand {
2626
description = "Name of the registry to list the bundles from. If not provided it will use the default registry.")
2727
String registryName;
2828

29-
@Parameters(description = "Name of the MCP bundle to install.")
30-
String name;
29+
@Parameters(description = "Names of the MCP bundles to install.")
30+
Set<String> names;
3131

3232
@Option(names = {"--clients"},
3333
description = "Names of client configs to update. If not specified all client configs registered would be updated")
@@ -41,28 +41,30 @@ public class InstallBundle extends SmithyMcpCommand {
4141
protected void execute(ExecutionContext context) throws IOException {
4242
var registry = context.registry();
4343
var config = context.config();
44-
var bundle = registry.getMcpBundle(name);
45-
ConfigUtils.addMcpBundle(config, name, bundle);
46-
var command = "mcp-registry";
47-
var args = List.of("start-server", name);
48-
if (bundle.getValue() instanceof GenericBundle genericBundle && genericBundle.isExecuteDirectly()) {
49-
command = genericBundle.getRun().getExecutable();
50-
args = genericBundle.getRun().getArgs();
51-
}
52-
var newClientConfig = McpServerConfig.builder()
44+
for (var name : names) {
45+
var bundle = registry.getMcpBundle(name);
46+
ConfigUtils.addMcpBundle(config, name, bundle);
47+
var command = "mcp-registry";
48+
var args = List.of("start-server", name);
49+
if (bundle.getValue() instanceof GenericBundle genericBundle && genericBundle.isExecuteDirectly()) {
50+
command = genericBundle.getRun().getExecutable();
51+
args = genericBundle.getRun().getArgs();
52+
}
53+
var newClientConfig = McpServerConfig.builder()
5354
.command(command)
5455
.args(args)
5556
.build();
56-
if (print == null) {
57-
//By default, print the output if there are no configured client configs.
58-
print = !config.hasClientConfigs();
59-
}
60-
ConfigUtils.addToClientConfigs(config, name, clients, newClientConfig);
57+
if (print == null) {
58+
//By default, print the output if there are no configured client configs.
59+
print = !config.hasClientConfigs();
60+
}
61+
ConfigUtils.addToClientConfigs(config, name, clients, newClientConfig);
6162

62-
System.out.println("Successfully installed " + name);
63-
if (print) {
64-
System.out.println("You can add the following to your MCP Servers config to use " + name);
65-
System.out.println(newClientConfig);
63+
System.out.println("Successfully installed " + name);
64+
if (print) {
65+
System.out.println("You can add the following to your MCP Servers config to use " + name);
66+
System.out.println(newClientConfig);
67+
}
6668
}
6769
}
6870

0 commit comments

Comments
 (0)