Skip to content

Commit 1a2d927

Browse files
adwsinghrhernandez35
authored andcommitted
Add a hook to add system properties to the Cli
1 parent 8a9e422 commit 1a2d927

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

mcp/mcp-cli/src/main/java/software/amazon/smithy/java/mcp/cli/McpCli.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.util.List;
99
import java.util.ServiceLoader;
1010
import picocli.CommandLine;
11-
import picocli.CommandLine.Command;
1211
import software.amazon.smithy.java.mcp.cli.commands.Configure;
1312
import software.amazon.smithy.java.mcp.cli.commands.InstallBundle;
1413
import software.amazon.smithy.java.mcp.cli.commands.ListBundles;
@@ -22,14 +21,17 @@
2221
* It discovers and registers all available configuration commands and
2322
* sets up the command hierarchy.
2423
*/
25-
@Command(name = "mcp-registry", versionProvider = VersionProvider.class, mixinStandardHelpOptions = true,
26-
scope = CommandLine.ScopeType.INHERIT)
27-
public class McpCli {
24+
public final class McpCli {
25+
26+
private McpCli() {
27+
throw new UnsupportedOperationException();
28+
}
2829

2930
public static void main(String[] args) {
31+
addSystemProperties();
3032
var configureCommand = new CommandLine(new Configure());
3133
discoverConfigurationCommands().forEach(configureCommand::addSubcommand);
32-
var commandLine = new CommandLine(new McpCli())
34+
var commandLine = new CommandLine(new McpRegistry())
3335
.addSubcommand(new StartServer())
3436
.addSubcommand(new ListBundles())
3537
.addSubcommand(new InstallBundle())
@@ -38,6 +40,10 @@ public static void main(String[] args) {
3840
commandLine.execute(args);
3941
}
4042

43+
private static void addSystemProperties() {
44+
System.setProperty("jdk.httpclient.allowRestrictedHeaders", "host"); //This is required for JavaHttpClientTransport.
45+
}
46+
4147
/**
4248
* Discovers and loads all ConfigurationCommand implementations using the Java ServiceLoader.
4349
*
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package software.amazon.smithy.java.mcp.cli;
7+
8+
import picocli.CommandLine;
9+
10+
@CommandLine.Command(name = "mcp-registry", versionProvider = VersionProvider.class, mixinStandardHelpOptions = true,
11+
scope = CommandLine.ScopeType.INHERIT)
12+
final class McpRegistry {}

0 commit comments

Comments
 (0)