Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,41 @@
import software.amazon.smithy.mcp.bundle.api.model.BundleMetadata;
import software.amazon.smithy.mcp.bundle.api.model.SmithyMcpBundle;

public class AwsMcpRegistry implements Registry {
public final class AwsMcpRegistry implements Registry {

private final List<BundleMetadata> availableMcpBundles;
private final List<RegistryEntry> availableMcpBundles;

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

private static RegistryEntry lineToEntry(String line) {
// line format: Title (which may contain spaces)|sdk-id/service/YYYY/MM/DD/sdk-id-YYYY-MM-DD.json
// sdk title, pipe character, github url to download the model (of which the first component is the sdk id)
var parts = line.split("\\|");
// this is the SDK title
var title = parts[0];
// this is id we pass to start-server
var name = parts[1].split("/")[0].toLowerCase(Locale.ROOT);
var bundle = BundleMetadata.builder().name(name).description("AWS MCP server for " + name).build();
return new RegistryEntry(title, bundle);
}

@Override
public String name() {
return "aws-mcp-registry";
}

@Override
public List<BundleMetadata> listMcpBundles() {
public List<RegistryEntry> listMcpBundles() {
return availableMcpBundles;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,18 @@ public final class AwsServiceBundler extends ModelBundler {
static final Map<String, String> GH_URIS_BY_SERVICE = new HashMap<>();

static {
// line is in the form fooService/service/version/fooService.json
// line format: Title (which may contain spaces)|sdk-id/service/YYYY/MM/DD/sdk-id-YYYY-MM-DD.json
// sdk title, pipe character, github url to download the model (of which the first component is the sdk id)
try (var models = new BufferedReader(new InputStreamReader(
Objects.requireNonNull(AwsServiceBundler.class.getResourceAsStream("/models.txt")),
StandardCharsets.UTF_8))) {
models.lines()
.forEach(line -> GH_URIS_BY_SERVICE
.put(line.substring(0, line.indexOf("/")).toLowerCase(Locale.ROOT), line));
.forEach(line -> {
var start = line.indexOf("|") + 1;
var end = line.indexOf("/", start);
GH_URIS_BY_SERVICE.put(line.substring(start, end).toLowerCase(Locale.ROOT),
line.substring(start));
});
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down
Loading