Skip to content

Improve formatting of mcp-registry list output #706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -8,6 +8,8 @@
import static software.amazon.smithy.java.mcp.cli.ConfigUtils.loadOrCreateConfig;

import java.util.concurrent.Callable;

import picocli.CommandLine;
import software.amazon.smithy.java.logging.InternalLogger;
import software.amazon.smithy.java.mcp.cli.model.Config;

Expand All @@ -20,6 +22,9 @@
*/
public abstract class SmithyMcpCommand implements Callable<Integer> {

@CommandLine.Spec
CommandLine.Model.CommandSpec commandSpec;

InternalLogger LOG = InternalLogger.getLogger(SmithyMcpCommand.class);

@Override
Expand All @@ -46,4 +51,8 @@ public final Integer call() throws Exception {
* @throws Exception If an error occurs during execution
*/
protected abstract void execute(Config config) throws Exception;

protected final CommandLine.Model.CommandSpec commandSpec() {
return commandSpec;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@

package software.amazon.smithy.java.mcp.cli.commands;

import static picocli.CommandLine.Command;

import picocli.CommandLine;
import picocli.CommandLine.Option;
import software.amazon.smithy.java.mcp.cli.RegistryUtils;
import software.amazon.smithy.java.mcp.cli.SmithyMcpCommand;
import software.amazon.smithy.java.mcp.cli.model.Config;
import software.amazon.smithy.java.mcp.cli.model.SmithyModeledBundleConfig;

import static picocli.CommandLine.Command;

@Command(name = "list", description = "List all the MCP Bundles available in the Registry")
public class ListBundles extends SmithyMcpCommand {
Expand All @@ -29,13 +31,14 @@ protected void execute(Config config) {
registry
.listMcpBundles()
.forEach(bundle -> {
StringBuilder builder = new StringBuilder(bundle.getName());
if (bundle.getDescription() != null) {
builder.append("\n").append("Description: ").append(bundle.getDescription());
} else {
builder.append("\n").append("MCP for ").append(bundle.getName());
System.out.println(commandSpec().commandLine().getColorScheme()
.string("@|bold " + bundle.getName() + "|@"));
var description = bundle.getDescription();
if (description == null) {
description = "MCP server for " + bundle.getName();
}
System.out.println(builder);
System.out.print("\tDescription: ");
System.out.println(description);
});

}
Expand Down