Skip to content

Commit d776cf6

Browse files
committed
Print human-readable titles alongside MCP server identifiers in list subcommand
1 parent 6909e19 commit d776cf6

6 files changed

Lines changed: 459 additions & 415 deletions

File tree

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,41 @@
1717
import software.amazon.smithy.mcp.bundle.api.model.BundleMetadata;
1818
import software.amazon.smithy.mcp.bundle.api.model.SmithyMcpBundle;
1919

20-
public class AwsMcpRegistry implements Registry {
20+
public final class AwsMcpRegistry implements Registry {
2121

22-
private final List<BundleMetadata> availableMcpBundles;
22+
private final List<RegistryEntry> availableMcpBundles;
2323

2424
public AwsMcpRegistry() {
2525
try (var models = new BufferedReader(new InputStreamReader(
2626
Objects.requireNonNull(AwsMcpRegistry.class.getResourceAsStream("/models.txt")),
2727
StandardCharsets.UTF_8))) {
2828
this.availableMcpBundles = models.lines()
29-
.map(line -> line.substring(0, line.indexOf("/")).toLowerCase(Locale.ROOT))
30-
.map(s -> BundleMetadata.builder().name(s).description("AWS MCP server for " + s).build())
29+
.map(AwsMcpRegistry::lineToEntry)
3130
.toList();
3231
} catch (Exception e) {
3332
throw new RuntimeException(e);
3433
}
3534
}
3635

36+
private static RegistryEntry lineToEntry(String line) {
37+
// line format: Title (which may contain spaces)|sdk-id/service/YYYY/MM/DD/sdk-id-YYYY-MM-DD.json
38+
// sdk title, pipe character, github url to download the model (of which the first component is the sdk id)
39+
var parts = line.split("\\|");
40+
// this is the SDK title
41+
var title = parts[0];
42+
// this is id we pass to start-server
43+
var name = parts[1].split("/")[0].toLowerCase(Locale.ROOT);
44+
var bundle = BundleMetadata.builder().name(name).description("AWS MCP server for " + name).build();
45+
return new RegistryEntry(title, bundle);
46+
}
47+
3748
@Override
3849
public String name() {
3950
return "aws-mcp-registry";
4051
}
4152

4253
@Override
43-
public List<BundleMetadata> listMcpBundles() {
54+
public List<RegistryEntry> listMcpBundles() {
4455
return availableMcpBundles;
4556
}
4657

aws/aws-service-bundler/src/main/java/software/amazon/smithy/java/aws/servicebundle/bundler/AwsServiceBundler.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,18 @@ public final class AwsServiceBundler extends ModelBundler {
4343
static final Map<String, String> GH_URIS_BY_SERVICE = new HashMap<>();
4444

4545
static {
46-
// line is in the form fooService/service/version/fooService.json
46+
// line format: Title (which may contain spaces)|sdk-id/service/YYYY/MM/DD/sdk-id-YYYY-MM-DD.json
47+
// sdk title, pipe character, github url to download the model (of which the first component is the sdk id)
4748
try (var models = new BufferedReader(new InputStreamReader(
4849
Objects.requireNonNull(AwsServiceBundler.class.getResourceAsStream("/models.txt")),
4950
StandardCharsets.UTF_8))) {
5051
models.lines()
51-
.forEach(line -> GH_URIS_BY_SERVICE
52-
.put(line.substring(0, line.indexOf("/")).toLowerCase(Locale.ROOT), line));
52+
.forEach(line -> {
53+
var start = line.indexOf("|") + 1;
54+
var end = line.indexOf("/", start);
55+
GH_URIS_BY_SERVICE.put(line.substring(start, end).toLowerCase(Locale.ROOT),
56+
line.substring(start));
57+
});
5358
} catch (Exception e) {
5459
throw new RuntimeException(e);
5560
}

0 commit comments

Comments
 (0)