Skip to content

Commit b5959a9

Browse files
authored
Improve formatting of mcp-registry list output (#706)
* Improve formatting of mcp-registry list output * Run spotless
1 parent b042229 commit b5959a9

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

mcp/mcp-cli-api/src/main/java/software/amazon/smithy/java/mcp/cli/SmithyMcpCommand.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import static software.amazon.smithy.java.mcp.cli.ConfigUtils.loadOrCreateConfig;
99

1010
import java.util.concurrent.Callable;
11+
import picocli.CommandLine;
1112
import software.amazon.smithy.java.logging.InternalLogger;
1213
import software.amazon.smithy.java.mcp.cli.model.Config;
1314

@@ -20,6 +21,9 @@
2021
*/
2122
public abstract class SmithyMcpCommand implements Callable<Integer> {
2223

24+
@CommandLine.Spec
25+
CommandLine.Model.CommandSpec commandSpec;
26+
2327
InternalLogger LOG = InternalLogger.getLogger(SmithyMcpCommand.class);
2428

2529
@Override
@@ -50,4 +54,8 @@ public final Integer call() throws Exception {
5054
protected String registryToUse(Config config) {
5155
return config.getDefaultRegistry();
5256
}
57+
58+
protected final CommandLine.Model.CommandSpec commandSpec() {
59+
return commandSpec;
60+
}
5361
}

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ protected void execute(ExecutionContext context) {
2525
registry
2626
.listMcpBundles()
2727
.forEach(bundle -> {
28-
StringBuilder builder = new StringBuilder(bundle.getName());
29-
if (bundle.getDescription() != null) {
30-
builder.append("\n").append("Description: ").append(bundle.getDescription());
31-
} else {
32-
builder.append("\n").append("MCP for ").append(bundle.getName());
28+
System.out.println(commandSpec().commandLine()
29+
.getColorScheme()
30+
.string("@|bold " + bundle.getName() + "|@"));
31+
var description = bundle.getDescription();
32+
if (description == null) {
33+
description = "MCP server for " + bundle.getName();
3334
}
34-
System.out.println(builder);
35+
System.out.print("\tDescription: ");
36+
System.out.println(description);
3537
});
3638

3739
}

0 commit comments

Comments
 (0)